torint.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /* Copyright 2003 Roger Dingledine */
  2. /* See LICENSE for licensing information */
  3. /* $Id$ */
  4. /**
  5. * \file torint.h
  6. * \brief Header file to define uint32_t and friends
  7. **/
  8. #ifndef __TORINT_H
  9. #define __TORINT_H
  10. #include "orconfig.h"
  11. #ifdef HAVE_STDINT_H
  12. #include <stdint.h>
  13. #endif
  14. #ifdef HAVE_SYS_TYPES_H
  15. #include <sys/types.h>
  16. #endif
  17. #if (SIZEOF_INT8_T != 0)
  18. #define HAVE_INT8_T
  19. #endif
  20. #if (SIZEOF_INT16_T != 0)
  21. #define HAVE_INT16_T
  22. #endif
  23. #if (SIZEOF_INT32_T != 0)
  24. #define HAVE_INT32_T
  25. #endif
  26. #if (SIZEOF_INT64_T != 0)
  27. #define HAVE_INT64_T
  28. #endif
  29. #if (SIZEOF_UINT8_T != 0)
  30. #define HAVE_UINT8_T
  31. #endif
  32. #if (SIZEOF_UINT16_T != 0)
  33. #define HAVE_UINT16_T
  34. #endif
  35. #if (SIZEOF_UINT32_T != 0)
  36. #define HAVE_UINT32_T
  37. #endif
  38. #if (SIZEOF_UINT64_T != 0)
  39. #define HAVE_UINT64_T
  40. #endif
  41. #if (SIZEOF_INTPTR_T != 0)
  42. #define HAVE_INTPTR_T
  43. #endif
  44. #if (SIZEOF_UINTPTR_T != 0)
  45. #define HAVE_UINTPTR_T
  46. #endif
  47. #if (SIZEOF_CHAR == 1)
  48. #ifndef HAVE_INT8_T
  49. typedef signed char int8_t;
  50. #define HAVE_INT8_T
  51. #endif
  52. #ifndef HAVE_UINT8_T
  53. typedef unsigned char uint8_t;
  54. #define HAVE_UINT8_T
  55. #endif
  56. #endif
  57. #if (SIZEOF_SHORT == 2)
  58. #ifndef HAVE_INT16_T
  59. typedef signed short int16_t;
  60. #define HAVE_INT16_T
  61. #endif
  62. #ifndef HAVE_UINT16_T
  63. typedef unsigned short uint16_t;
  64. #define HAVE_UINT16_T
  65. #endif
  66. #endif
  67. #if (SIZEOF_INT == 2)
  68. #ifndef HAVE_INT16_T
  69. typedef signed int int16_t;
  70. #define HAVE_INT16_T
  71. #endif
  72. #ifndef HAVE_UINT16_T
  73. typedef unsigned int uint16_t;
  74. #define HAVE_UINT16_T
  75. #endif
  76. #elif (SIZEOF_INT == 4)
  77. #ifndef HAVE_INT32_T
  78. typedef signed int int32_t;
  79. #define HAVE_INT32_T
  80. #endif
  81. #ifndef HAVE_UINT32_T
  82. typedef unsigned int uint32_t;
  83. #define HAVE_UINT32_T
  84. #endif
  85. #endif
  86. #if (SIZEOF_LONG == 4)
  87. #ifndef HAVE_INT32_T
  88. typedef signed long int32_t;
  89. #define HAVE_INT32_T
  90. #endif
  91. #ifndef HAVE_UINT32_T
  92. typedef unsigned long uint32_t;
  93. #define HAVE_UINT32_T
  94. #endif
  95. #elif (SIZEOF_LONG == 8)
  96. #ifndef HAVE_INT64_T
  97. typedef signed long int64_t;
  98. #define HAVE_INT64_T
  99. #endif
  100. #ifndef HAVE_UINT32_T
  101. typedef unsigned long uint64_t;
  102. #define HAVE_UINT32_T
  103. #endif
  104. #endif
  105. #if (SIZEOF_LONG_LONG == 8)
  106. #ifndef HAVE_INT64_T
  107. typedef signed long long int64_t;
  108. #define HAVE_INT64_T
  109. #endif
  110. #ifndef HAVE_UINT64_T
  111. typedef unsigned long long uint64_t;
  112. #define HAVE_UINT64_T
  113. #endif
  114. #endif
  115. #if (SIZEOF___INT64 == 8)
  116. #ifndef HAVE_INT64_T
  117. typedef signed __int64 int64_t;
  118. #define HAVE_INT64_T
  119. #endif
  120. #ifndef HAVE_UINT64_T
  121. typedef unsigned __int64 uint64_t;
  122. #define HAVE_UINT64_T
  123. #endif
  124. #endif
  125. #if (SIZEOF_VOID_P > 4 && SIZEOF_VOID_P <= 8)
  126. #ifndef HAVE_INTPTR_T
  127. typedef int64_t intptr_t;
  128. #endif
  129. #ifndef HAVE_UINTPTR_T
  130. typedef uint64_t uintptr_t;
  131. #endif
  132. #elif (SIZEOF_VOID_P > 2 && SIZEOF_VOID_P <= 4)
  133. #ifndef HAVE_INTPTR_T
  134. typedef int32_t intptr_t;
  135. #endif
  136. #ifndef HAVE_UINTPTR_T
  137. typedef uint32_t uintptr_t;
  138. #endif
  139. #else
  140. #error "void * is either >8 bytes or <= 2. In either case, I am confused."
  141. #endif
  142. #ifndef HAVE_INT8_T
  143. #error "Missing type int8_t"
  144. #endif
  145. #ifndef HAVE_UINT8_T
  146. #error "Missing type uint8_t"
  147. #endif
  148. #ifndef HAVE_INT16_T
  149. #error "Missing type int16_t"
  150. #endif
  151. #ifndef HAVE_UINT16_T
  152. #error "Missing type uint16_t"
  153. #endif
  154. #ifndef HAVE_INT32_T
  155. #error "Missing type int32_t"
  156. #endif
  157. #ifndef HAVE_UINT32_T
  158. #error "Missing type uint32_t"
  159. #endif
  160. #ifndef HAVE_INT64_T
  161. #error "Missing type int64_t"
  162. #endif
  163. #ifndef HAVE_UINT64_T
  164. #error "Missing type uint64_t"
  165. #endif
  166. #endif /* __TORINT_H */
  167. /*
  168. Local Variables:
  169. mode:c
  170. indent-tabs-mode:nil
  171. c-basic-offset:2
  172. End:
  173. */