blob: 39b5af596e6803eb3c27e054ed32c655f08c2d33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#pragma once
#include "sys/types.h"
#define inline __attribute__((always_inline, used))
#define offsetof(type, member) \
((uintptr_t)((char *)&((type *)(0))->member - (char *)0))
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
#define CONTAINER_OF(obj, type, member) \
((type *)((char *)(obj)-offsetof(type, member)))
/* This truly atrocious macro hack taken from the wikipedia article on the C
* preprocessor, use to "quote" the value (or name) of another macro:
* QUOTE_BY_NAME(NTERMS) -> "NTERMS"
* QUOTE(NTERMS) -> "3"
*/
#define QUOTE_BY_NAME(x) #x
#define QUOTE_BY_VALUE(x) QUOTE_BY_NAME(x)
/* By default, we quote by value */
#define QUOTE(x) QUOTE_BY_NAME(x)
|