types.h 973 B

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