1 /* 2 +----------------------------------------------------------------------+ 3 | PHP Version 7 | 4 +----------------------------------------------------------------------+ 5 | Copyright (c) 1997-2018 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 19 #ifndef PHP_STDINT_H 20 #define PHP_STDINT_H 21 22 /* C99 requires these for C++ to get the definitions 23 * of INT64_MAX and other macros used by Zend/zend_long.h 24 * C11 drops this requirement, so these effectively 25 * just backport that piece of behavior. 26 * 27 * These defines are placed here instead of 28 * with the include below, because sys/types 29 * and inttypes may include stdint themselves. 30 * And these definitions MUST come first. 31 */ 32 #ifdef __cplusplus 33 # ifndef __STDC_LIMIT_MACROS 34 # define __STDC_LIMIT_MACROS 35 # endif 36 # ifndef __STDC_CONSTANT_MACROS 37 # define __STDC_CONSTANT_MACROS 38 # endif 39 #endif 40 41 #if defined(_MSC_VER) 42 /* Make sure the regular stdint.h wasn't included already and prevent it to be 43 included afterwards. Though if some other library needs some stuff from 44 stdint.h included afterwards and misses it, we'd have to extend ours. On 45 the other hand, if stdint.h was included before, some conflicts might 46 happen so we'd likewise have to fix ours. */ 47 # if !defined(_STDINT) 48 # define _STDINT 49 # include "win32/php_stdint.h" 50 # include "win32/php_inttypes.h" 51 # endif 52 # define HAVE_INT8_T 1 53 # define HAVE_UINT8_T 1 54 # define HAVE_INT16_T 1 55 # define HAVE_UINT16_T 1 56 # define HAVE_INT32_T 1 57 # define HAVE_UINT32_T 1 58 # define HAVE_INT64_T 1 59 # define HAVE_UINT64_T 1 60 #else 61 62 #include "php_config.h" 63 64 #if HAVE_SYS_TYPES_H 65 # include <sys/types.h> 66 #endif 67 68 #if HAVE_INTTYPES_H 69 # include <inttypes.h> 70 #endif 71 72 #if HAVE_STDINT_H 73 # include <stdint.h> 74 #endif 75 76 #ifndef HAVE_INT8_T 77 # ifdef HAVE_INT8 78 typedef int8 int8_t; 79 # else 80 typedef signed char int8_t; 81 # endif 82 #endif 83 84 #ifndef INT8_C 85 # define INT8_C(c) c 86 #endif 87 88 #ifndef HAVE_UINT8_T 89 # ifdef HAVE_UINT8 90 typedef uint8 uint8_t 91 # elif HAVE_U_INT8_T 92 typedef u_int8_t uint8_t; 93 # else 94 typedef unsigned char uint8_t; 95 # endif 96 #endif 97 98 #ifndef UINT8_C 99 # define UINT8_C(c) c 100 #endif 101 102 #ifndef HAVE_INT16_T 103 # ifdef HAVE_INT16 104 typedef int16 int16_t; 105 # elif SIZEOF_SHORT >= 2 106 typedef signed short int16_t; 107 # else 108 # error "No suitable 16bit integer type found" 109 # endif 110 #endif 111 112 #ifndef INT16_C 113 # define INT16_C(c) c 114 #endif 115 116 #ifndef HAVE_UINT16_T 117 # ifdef HAVE_UINT16 118 typedef uint16 uint16_t 119 # elif HAVE_U_INT16_T 120 typedef u_int16_t uint16_t; 121 # elif SIZEOF_SHORT >= 2 122 typedef unsigned short uint16_t; 123 # else 124 # error "No suitable 16bit integer type found" 125 # endif 126 #endif 127 128 #ifndef UINT16_C 129 # define UINT16_C(c) c 130 #endif 131 132 #ifndef HAVE_INT32_T 133 # ifdef HAVE_INT32 134 typedef int32 int32_t; 135 # elif SIZEOF_INT >= 4 136 typedef int int32_t; 137 # elif SIZEOF_LONG >= 4 138 typedef long int32_t; 139 # else 140 # error "No suitable 32bit integer type found" 141 # endif 142 #endif 143 144 #ifndef INT32_C 145 # define INT32_C(c) c 146 #endif 147 148 #ifndef HAVE_UINT32_T 149 # ifdef HAVE_UINT32 150 typedef uint32 uint32_t 151 # elif HAVE_U_INT32_T 152 typedef u_int32_t uint32_t; 153 # elif SIZEOF_INT >= 4 154 typedef unsigned int uint32_t; 155 # elif SIZEOF_LONG >= 4 156 typedef unsigned long uint32_t; 157 # else 158 # error "No suitable 32bit integer type found" 159 # endif 160 #endif 161 162 #ifndef UINT32_C 163 # define UINT32_C(c) c ## U 164 #endif 165 166 #ifndef HAVE_INT64_T 167 # ifdef HAVE_INT64 168 typedef int64 int64_t; 169 # elif SIZEOF_INT >= 8 170 typedef int int64_t; 171 # elif SIZEOF_LONG >= 8 172 typedef long int64_t; 173 # elif SIZEOF_LONG_LONG >= 8 174 typedef long long int64_t; 175 # else 176 # error "No suitable 64bit integer type found" 177 # endif 178 #endif 179 180 #ifndef INT64_C 181 # if SIZEOF_INT >= 8 182 # define INT64_C(c) c 183 # elif SIZEOF_LONG >= 8 184 # define INT64_C(c) c ## L 185 # elif SIZEOF_LONG_LONG >= 8 186 # define INT64_C(c) c ## LL 187 # endif 188 #endif 189 190 #ifndef HAVE_UINT64_T 191 # ifdef HAVE_UINT64 192 typedef uint64 uint64_t 193 # elif HAVE_U_INT64_T 194 typedef u_int64_t uint64_t; 195 # elif SIZEOF_INT >= 8 196 typedef unsigned int uint64_t; 197 # elif SIZEOF_LONG >= 8 198 typedef unsigned long uint64_t; 199 # elif SIZEOF_LONG_LONG >= 8 200 typedef unsigned long long uint64_t; 201 # else 202 # error "No suitable 64bit integer type found" 203 # endif 204 #endif 205 206 #ifndef UINT64_C 207 # if SIZEOF_INT >= 8 208 # define UINT64_C(c) c ## U 209 # elif SIZEOF_LONG >= 8 210 # define UINT64_C(c) c ## UL 211 # elif SIZEOF_LONG_LONG >= 8 212 # define UINT64_C(c) c ## ULL 213 # endif 214 #endif 215 216 #endif /* !PHP_WIN32 */ 217 #endif /* PHP_STDINT_H */ 218 219 /* 220 * Local variables: 221 * tab-width: 4 222 * c-basic-offset: 4 223 * End: 224 * vim600: sw=4 ts=4 fdm=marker 225 * vim<600: sw=4 ts=4 226 */ 227