fixed_types.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef __FIXED_TYPES_H
  2. #define __FIXED_TYPES_H
  3. #ifndef __STDC_LIMIT_MACROS
  4. # define __STDC_LIMIT_MACROS
  5. #endif
  6. #ifndef __STDC_CONSTANT_MACROS
  7. # define __STDC_CONSTANT_MACROS
  8. #endif
  9. #ifndef __STDC_FORMAT_MACROS
  10. # define __STDC_FORMAT_MACROS
  11. #endif
  12. #include <stdint.h>
  13. #include <inttypes.h>
  14. // We define __STDC_LIMIT_MACROS and then include stdint.h
  15. // But if someone else already included stdint.h without first defining __STDC_LIMIT_MACROS,
  16. // UINT64_MAX and friends will not be defined. Test for this here.
  17. #ifndef UINT64_MAX
  18. # error "UINT64_MAX is not defined. Make sure fixed_types.h is first in the include order."
  19. #endif
  20. #ifndef PRId64
  21. # error "PRId64 is not defined. Make sure fixed_types.h is first in the include order."
  22. #endif
  23. typedef uint64_t UInt64;
  24. typedef uint32_t UInt32;
  25. typedef uint16_t UInt16;
  26. typedef uint8_t UInt8;
  27. typedef int64_t SInt64;
  28. typedef int32_t SInt32;
  29. typedef int16_t SInt16;
  30. typedef int8_t SInt8;
  31. typedef UInt8 Byte;
  32. typedef UInt8 Boolean;
  33. typedef uintptr_t IntPtr;
  34. typedef uintptr_t carbon_reg_t;
  35. // Carbon core types
  36. typedef SInt32 thread_id_t;
  37. typedef SInt32 app_id_t;
  38. typedef SInt32 core_id_t;
  39. typedef SInt32 carbon_thread_t;
  40. #define INVALID_THREAD_ID ((thread_id_t) -1)
  41. #define INVALID_APP_ID ((app_id_t) -1)
  42. #define INVALID_CORE_ID ((core_id_t) -1)
  43. #define INVALID_ADDRESS ((IntPtr) -1)
  44. #ifdef __cplusplus
  45. // std::string isn't tread-safe when making copies
  46. // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21334
  47. #include <ext/vstring.h>
  48. typedef __gnu_cxx::__versa_string<char> String;
  49. #endif /* __cplusplus */
  50. #endif