Loading...
1#ifndef _TYPES_H_
2#define _TYPES_H_
3
4#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
5
6typedef unsigned char u8;
7typedef unsigned short u16;
8typedef unsigned int u32;
9typedef unsigned long long u64;
10typedef signed char s8;
11typedef short s16;
12typedef int s32;
13typedef long long s64;
14
15#define min(x,y) ({ \
16 typeof(x) _x = (x); \
17 typeof(y) _y = (y); \
18 (void) (&_x == &_y); \
19 _x < _y ? _x : _y; })
20
21#define max(x,y) ({ \
22 typeof(x) _x = (x); \
23 typeof(y) _y = (y); \
24 (void) (&_x == &_y); \
25 _x > _y ? _x : _y; })
26
27#endif /* _TYPES_H_ */
1#ifndef _TYPES_H_
2#define _TYPES_H_
3
4#include <stdbool.h>
5
6#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
7
8typedef unsigned char u8;
9typedef unsigned short u16;
10typedef unsigned int u32;
11typedef unsigned long long u64;
12typedef signed char s8;
13typedef short s16;
14typedef int s32;
15typedef long long s64;
16
17/* required for opal-api.h */
18typedef u8 uint8_t;
19typedef u16 uint16_t;
20typedef u32 uint32_t;
21typedef u64 uint64_t;
22typedef s8 int8_t;
23typedef s16 int16_t;
24typedef s32 int32_t;
25typedef s64 int64_t;
26
27#define min(x,y) ({ \
28 typeof(x) _x = (x); \
29 typeof(y) _y = (y); \
30 (void) (&_x == &_y); \
31 _x < _y ? _x : _y; })
32
33#define max(x,y) ({ \
34 typeof(x) _x = (x); \
35 typeof(y) _y = (y); \
36 (void) (&_x == &_y); \
37 _x > _y ? _x : _y; })
38
39#define min_t(type, a, b) min(((type) a), ((type) b))
40#define max_t(type, a, b) max(((type) a), ((type) b))
41
42typedef int bool;
43
44#ifndef true
45#define true 1
46#endif
47
48#ifndef false
49#define false 0
50#endif
51#endif /* _TYPES_H_ */