plan to cleanup the fd generation code
[trinity.git] / include / utils.h
blob1660e7fc4934ed50ded1e6f1d9002c2c47afc709
1 #pragma once
3 #include <types.h>
5 #define MB (1024 * 1024UL)
6 #define GB (1024 * MB)
8 void * alloc_shared(unsigned int size);
9 void * zmalloc(size_t size);
11 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
13 #define max(x, y) ((x) >= (y) ? (x) : (y))
14 #define min(x, y) ((x) <= (y) ? (x) : (y))
16 #ifndef offsetof
17 # define offsetof(type, member) ((size_t) &((type *) 0)->member)
18 #endif
20 #define MAX_ERRNO 4095
21 #define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO)
22 static inline long IS_ERR(unsigned long x)
24 return IS_ERR_VALUE(x);
27 void sizeunit(unsigned long size, char *buf);