]> granicus.if.org Git - php/commitdiff
- add it to 5.2 too, cannot hurt and will spare some work later with pcre&co
authorPierre Joye <pajoye@php.net>
Thu, 1 Apr 2010 10:52:28 +0000 (10:52 +0000)
committerPierre Joye <pajoye@php.net>
Thu, 1 Apr 2010 10:52:28 +0000 (10:52 +0000)
win32/php_stdint.h [new file with mode: 0644]

diff --git a/win32/php_stdint.h b/win32/php_stdint.h
new file mode 100644 (file)
index 0000000..f75c9d3
--- /dev/null
@@ -0,0 +1,251 @@
+// ISO C9x  compliant stdint.h for Microsoft Visual Studio\r
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 \r
+// \r
+//  Copyright (c) 2006-2009 Alexander Chemeris\r
+// \r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are met:\r
+// \r
+//   1. Redistributions of source code must retain the above copyright notice,\r
+//      this list of conditions and the following disclaimer.\r
+// \r
+//   2. Redistributions in binary form must reproduce the above copyright\r
+//      notice, this list of conditions and the following disclaimer in the\r
+//      documentation and/or other materials provided with the distribution.\r
+// \r
+//   3. The name of the author may be used to endorse or promote products\r
+//      derived from this software without specific prior written permission.\r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED\r
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\r
+// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \r
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\r
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+// \r
+///////////////////////////////////////////////////////////////////////////////\r
+\r
+#ifndef _MSC_VER // [\r
+#error "Use this header only with Microsoft Visual C++ compilers!"\r
+#endif // _MSC_VER ]\r
+\r
+#ifndef _MSC_STDINT_H_ // [\r
+#define _MSC_STDINT_H_\r
+\r
+#if _MSC_VER > 1000\r
+#pragma once\r
+#endif\r
+\r
+#include <limits.h>\r
+\r
+// For Visual Studio 6 in C++ mode wrap <wchar.h> include with 'extern "C++" {}'\r
+// or compiler give many errors like this:\r
+//   error C2733: second C linkage of overloaded function 'wmemchr' not allowed\r
+#if (_MSC_VER < 1300) && defined(__cplusplus)\r
+   extern "C++" {\r
+#endif \r
+#     include <wchar.h>\r
+#if (_MSC_VER < 1300) && defined(__cplusplus)\r
+   }\r
+#endif\r
+\r
+// Define _W64 macros to mark types changing their size, like intptr_t.\r
+#ifndef _W64\r
+#  if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300\r
+#     define _W64 __w64\r
+#  else\r
+#     define _W64\r
+#  endif\r
+#endif\r
+\r
+\r
+// 7.18.1 Integer types\r
+\r
+// 7.18.1.1 Exact-width integer types\r
+typedef __int8            int8_t;\r
+typedef __int16           int16_t;\r
+#ifndef int32_t\r
+typedef __int32           int32_t;\r
+#endif\r
+#ifndef int64_t\r
+typedef __int64           int64_t;\r
+#endif\r
+#ifndef uint8_t\r
+typedef unsigned __int8   uint8_t;\r
+#endif\r
+#ifndef u_char\r
+typedef unsigned __int8   u_char;\r
+#endif\r
+typedef unsigned __int16  uint16_t;\r
+#ifndef uint32_t\r
+typedef unsigned __int32  uint32_t;\r
+#endif\r
+typedef unsigned __int64  uint64_t;\r
+\r
+// 7.18.1.2 Minimum-width integer types\r
+typedef int8_t    int_least8_t;\r
+typedef int16_t   int_least16_t;\r
+typedef int32_t   int_least32_t;\r
+typedef int64_t   int_least64_t;\r
+typedef uint8_t   uint_least8_t;\r
+typedef uint16_t  uint_least16_t;\r
+typedef uint32_t  uint_least32_t;\r
+typedef uint64_t  uint_least64_t;\r
+\r
+// 7.18.1.3 Fastest minimum-width integer types\r
+typedef int8_t    int_fast8_t;\r
+typedef int16_t   int_fast16_t;\r
+typedef int32_t   int_fast32_t;\r
+typedef int64_t   int_fast64_t;\r
+typedef uint8_t   uint_fast8_t;\r
+typedef uint16_t  uint_fast16_t;\r
+typedef uint32_t  uint_fast32_t;\r
+typedef uint32_t  u_int32_t;\r
+typedef uint64_t  uint_fast64_t;\r
+\r
+// 7.18.1.4 Integer types capable of holding object pointers\r
+#ifdef _WIN64 // [\r
+   typedef __int64           intptr_t;\r
+   typedef unsigned __int64  uintptr_t;\r
+#else // _WIN64 ][\r
+   typedef _W64 int               intptr_t;\r
+   typedef _W64 unsigned int      uintptr_t;\r
+#endif // _WIN64 ]\r
+\r
+// 7.18.1.5 Greatest-width integer types\r
+typedef int64_t   intmax_t;\r
+typedef uint64_t  uintmax_t;\r
+\r
+\r
+// 7.18.2 Limits of specified-width integer types\r
+\r
+#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [   See footnote 220 at page 257 and footnote 221 at page 259\r
+\r
+// 7.18.2.1 Limits of exact-width integer types\r
+#define INT8_MIN     ((int8_t)_I8_MIN)\r
+#define INT8_MAX     _I8_MAX\r
+#define INT16_MIN    ((int16_t)_I16_MIN)\r
+#define INT16_MAX    _I16_MAX\r
+#define INT32_MIN    ((int32_t)_I32_MIN)\r
+#define INT32_MAX    _I32_MAX\r
+#define INT64_MIN    ((int64_t)_I64_MIN)\r
+#define INT64_MAX    _I64_MAX\r
+#define UINT8_MAX    _UI8_MAX\r
+#define UINT16_MAX   _UI16_MAX\r
+#define UINT32_MAX   _UI32_MAX\r
+#define UINT64_MAX   _UI64_MAX\r
+\r
+// 7.18.2.2 Limits of minimum-width integer types\r
+#define INT_LEAST8_MIN    INT8_MIN\r
+#define INT_LEAST8_MAX    INT8_MAX\r
+#define INT_LEAST16_MIN   INT16_MIN\r
+#define INT_LEAST16_MAX   INT16_MAX\r
+#define INT_LEAST32_MIN   INT32_MIN\r
+#define INT_LEAST32_MAX   INT32_MAX\r
+#define INT_LEAST64_MIN   INT64_MIN\r
+#define INT_LEAST64_MAX   INT64_MAX\r
+#define UINT_LEAST8_MAX   UINT8_MAX\r
+#define UINT_LEAST16_MAX  UINT16_MAX\r
+#define UINT_LEAST32_MAX  UINT32_MAX\r
+#define UINT_LEAST64_MAX  UINT64_MAX\r
+\r
+// 7.18.2.3 Limits of fastest minimum-width integer types\r
+#define INT_FAST8_MIN    INT8_MIN\r
+#define INT_FAST8_MAX    INT8_MAX\r
+#define INT_FAST16_MIN   INT16_MIN\r
+#define INT_FAST16_MAX   INT16_MAX\r
+#define INT_FAST32_MIN   INT32_MIN\r
+#define INT_FAST32_MAX   INT32_MAX\r
+#define INT_FAST64_MIN   INT64_MIN\r
+#define INT_FAST64_MAX   INT64_MAX\r
+#define UINT_FAST8_MAX   UINT8_MAX\r
+#define UINT_FAST16_MAX  UINT16_MAX\r
+#define UINT_FAST32_MAX  UINT32_MAX\r
+#define UINT_FAST64_MAX  UINT64_MAX\r
+\r
+// 7.18.2.4 Limits of integer types capable of holding object pointers\r
+#ifdef _WIN64 // [\r
+#  define INTPTR_MIN   INT64_MIN\r
+#  define INTPTR_MAX   INT64_MAX\r
+#  define UINTPTR_MAX  UINT64_MAX\r
+#else // _WIN64 ][\r
+#  define INTPTR_MIN   INT32_MIN\r
+#  define INTPTR_MAX   INT32_MAX\r
+#  define UINTPTR_MAX  UINT32_MAX\r
+#endif // _WIN64 ]\r
+\r
+// 7.18.2.5 Limits of greatest-width integer types\r
+#define INTMAX_MIN   INT64_MIN\r
+#define INTMAX_MAX   INT64_MAX\r
+#define UINTMAX_MAX  UINT64_MAX\r
+\r
+// 7.18.3 Limits of other integer types\r
+\r
+#ifdef _WIN64 // [\r
+#  define PTRDIFF_MIN  _I64_MIN\r
+#  define PTRDIFF_MAX  _I64_MAX\r
+#else  // _WIN64 ][\r
+#  define PTRDIFF_MIN  _I32_MIN\r
+#  define PTRDIFF_MAX  _I32_MAX\r
+#endif  // _WIN64 ]\r
+\r
+#define SIG_ATOMIC_MIN  INT_MIN\r
+#define SIG_ATOMIC_MAX  INT_MAX\r
+\r
+#ifndef SIZE_MAX // [\r
+#  ifdef _WIN64 // [\r
+#     define SIZE_MAX  _UI64_MAX\r
+#  else // _WIN64 ][\r
+#     define SIZE_MAX  _UI32_MAX\r
+#  endif // _WIN64 ]\r
+#endif // SIZE_MAX ]\r
+\r
+// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>\r
+#ifndef WCHAR_MIN // [\r
+#  define WCHAR_MIN  0\r
+#endif  // WCHAR_MIN ]\r
+#ifndef WCHAR_MAX // [\r
+#  define WCHAR_MAX  _UI16_MAX\r
+#endif  // WCHAR_MAX ]\r
+\r
+#define WINT_MIN  0\r
+#define WINT_MAX  _UI16_MAX\r
+\r
+#endif // __STDC_LIMIT_MACROS ]\r
+\r
+\r
+// 7.18.4 Limits of other integer types\r
+\r
+#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [   See footnote 224 at page 260\r
+\r
+// 7.18.4.1 Macros for minimum-width integer constants\r
+\r
+#define INT8_C(val)  val##i8\r
+#define INT16_C(val) val##i16\r
+#define INT32_C(val) val##i32\r
+#define INT64_C(val) val##i64\r
+\r
+#define UINT8_C(val)  val##ui8\r
+#define UINT16_C(val) val##ui16\r
+#define UINT32_C(val) val##ui32\r
+#define UINT64_C(val) val##ui64\r
+\r
+// 7.18.4.2 Macros for greatest-width integer constants\r
+#define INTMAX_C   INT64_C\r
+#define UINTMAX_C  UINT64_C\r
+\r
+#if _MSC_VER < 1600\r
+static __inline int64_t llabs(int64_t i)\r
+{\r
+       return i >= 0 ? i: -i;\r
+}\r
+#endif\r
+\r
+#endif // __STDC_CONSTANT_MACROS ]\r
+\r
+\r
+#endif // _MSC_STDINT_H_ ]\r