1
0
Fork 0
hash-table/src/base.h

53 lines
1.1 KiB
C

#ifndef BASE_H
#define BASE_H
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#define internal static
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t i8;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
typedef uint8_t b8;
typedef uint16_t b16;
typedef uint32_t b32;
typedef uint64_t b64;
#define KB(b) ((b) << 10)
#define MB(b) ((b) << 20)
#define STATEMENT(S) do{ S } while(0)
#define ASSERT(c) STATEMENT( if (!(c)){ (*(volatile int*)0 = 0); } )
#define STATIC_ASSERT(c,l) typedef u8 Glue(l,__LINE__) [(c)?1:-1]
#define MIN(A,B) (((A)<(B))?(A):(B))
#define STRINGIFY_(S) #S
#define STRINGIFY(S) STRINGIFY_(S)
#define array_count(a) (sizeof(a) / sizeof((a)[0]))
//= rhjr: linked-list
#define check_null(p) ((p)==0)
#define set_null(p) ((p)=0)
#define queue_push_nz(f,l,n,next,zchk,zset) (zchk(f)?\
(((f)=(l)=(n)), zset((n)->next)):\
((l)->next=(n),(l)=(n),zset((n)->next)))
#define queue_push(f,l,n) queue_push_nz(f,l,n,next,check_null,set_null)
#define stack_push(f,n,next) ((n)->next=(f), (f)=(n))
#endif // BASE_H