php_stdint.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Author: Michael Wallner <mike@php.net> |
  16. +----------------------------------------------------------------------+
  17. */
  18. #ifndef PHP_STDINT_H
  19. #define PHP_STDINT_H
  20. #if defined(_MSC_VER)
  21. /* Make sure the regular stdint.h wasn't included already and prevent it to be
  22. included afterwards. Though if some other library needs some stuff from
  23. stdint.h included afterwards and misses it, we'd have to extend ours. On
  24. the other hand, if stdint.h was included before, some conflicts might
  25. happen so we'd likewise have to fix ours. */
  26. # if !defined(_STDINT)
  27. # define _STDINT
  28. # include "win32/php_stdint.h"
  29. # endif
  30. # define HAVE_INT8_T 1
  31. # define HAVE_UINT8_T 1
  32. # define HAVE_INT16_T 1
  33. # define HAVE_UINT16_T 1
  34. # define HAVE_INT32_T 1
  35. # define HAVE_UINT32_T 1
  36. # define HAVE_INT64_T 1
  37. # define HAVE_UINT64_T 1
  38. #else
  39. #include "php_config.h"
  40. #if HAVE_SYS_TYPES_H
  41. # include <sys/types.h>
  42. #endif
  43. #if HAVE_INTTYPES_H
  44. # include <inttypes.h>
  45. #endif
  46. #if HAVE_STDINT_H
  47. # include <stdint.h>
  48. #endif
  49. #ifndef HAVE_INT8_T
  50. # ifdef HAVE_INT8
  51. typedef int8 int8_t;
  52. # else
  53. typedef signed char int8_t;
  54. # endif
  55. #endif
  56. #ifndef INT8_C
  57. # define INT8_C(c) c
  58. #endif
  59. #ifndef HAVE_UINT8_T
  60. # ifdef HAVE_UINT8
  61. typedef uint8 uint8_t
  62. # elif HAVE_U_INT8_T
  63. typedef u_int8_t uint8_t;
  64. # else
  65. typedef unsigned char uint8_t;
  66. # endif
  67. #endif
  68. #ifndef UINT8_C
  69. # define UINT8_C(c) c
  70. #endif
  71. #ifndef HAVE_INT16_T
  72. # ifdef HAVE_INT16
  73. typedef int16 int16_t;
  74. # elif SIZEOF_SHORT >= 2
  75. typedef signed short int16_t;
  76. # else
  77. # error "No suitable 16bit integer type found"
  78. # endif
  79. #endif
  80. #ifndef INT16_C
  81. # define INT16_C(c) c
  82. #endif
  83. #ifndef HAVE_UINT16_T
  84. # ifdef HAVE_UINT16
  85. typedef uint16 uint16_t
  86. # elif HAVE_U_INT16_T
  87. typedef u_int16_t uint16_t;
  88. # elif SIZEOF_SHORT >= 2
  89. typedef unsigned short uint16_t;
  90. # else
  91. # error "No suitable 16bit integer type found"
  92. # endif
  93. #endif
  94. #ifndef UINT16_C
  95. # define UINT16_C(c) c
  96. #endif
  97. #ifndef HAVE_INT32_T
  98. # ifdef HAVE_INT32
  99. typedef int32 int32_t;
  100. # elif SIZEOF_INT >= 4
  101. typedef int int32_t;
  102. # elif SIZEOF_LONG >= 4
  103. typedef long int32_t;
  104. # else
  105. # error "No suitable 32bit integer type found"
  106. # endif
  107. #endif
  108. #ifndef INT32_C
  109. # define INT32_C(c) c
  110. #endif
  111. #ifndef HAVE_UINT32_T
  112. # ifdef HAVE_UINT32
  113. typedef uint32 uint32_t
  114. # elif HAVE_U_INT32_T
  115. typedef u_int32_t uint32_t;
  116. # elif SIZEOF_INT >= 4
  117. typedef unsigned int uint32_t;
  118. # elif SIZEOF_LONG >= 4
  119. typedef unsigned long uint32_t;
  120. # else
  121. # error "No suitable 32bit integer type found"
  122. # endif
  123. #endif
  124. #ifndef UINT32_C
  125. # define UINT32_C(c) c ## U
  126. #endif
  127. #ifndef HAVE_INT64_T
  128. # ifdef HAVE_INT64
  129. typedef int64 int64_t;
  130. # elif SIZEOF_INT >= 8
  131. typedef int int64_t;
  132. # elif SIZEOF_LONG >= 8
  133. typedef long int64_t;
  134. # elif SIZEOF_LONG_LONG >= 8
  135. typedef long long int64_t;
  136. # else
  137. # error "No suitable 64bit integer type found"
  138. # endif
  139. #endif
  140. #ifndef INT64_C
  141. # if SIZEOF_INT >= 8
  142. # define INT64_C(c) c
  143. # elif SIZEOF_LONG >= 8
  144. # define INT64_C(c) c ## L
  145. # elif SIZEOF_LONG_LONG >= 8
  146. # define INT64_C(c) c ## LL
  147. # endif
  148. #endif
  149. #ifndef HAVE_UINT64_T
  150. # ifdef HAVE_UINT64
  151. typedef uint64 uint64_t
  152. # elif HAVE_U_INT64_T
  153. typedef u_int64_t uint64_t;
  154. # elif SIZEOF_INT >= 8
  155. typedef unsigned int uint64_t;
  156. # elif SIZEOF_LONG >= 8
  157. typedef unsigned long uint64_t;
  158. # elif SIZEOF_LONG_LONG >= 8
  159. typedef unsigned long long uint64_t;
  160. # else
  161. # error "No suitable 64bit integer type found"
  162. # endif
  163. #endif
  164. #ifndef UINT64_C
  165. # if SIZEOF_INT >= 8
  166. # define UINT64_C(c) c ## U
  167. # elif SIZEOF_LONG >= 8
  168. # define UINT64_C(c) c ## UL
  169. # elif SIZEOF_LONG_LONG >= 8
  170. # define UINT64_C(c) c ## ULL
  171. # endif
  172. #endif
  173. #endif /* !PHP_WIN32 */
  174. #endif /* PHP_STDINT_H */
  175. /*
  176. * Local variables:
  177. * tab-width: 4
  178. * c-basic-offset: 4
  179. * End:
  180. * vim600: sw=4 ts=4 fdm=marker
  181. * vim<600: sw=4 ts=4
  182. */