summaryrefslogtreecommitdiff
path: root/win32/php_stdint.h
diff options
context:
space:
mode:
Diffstat (limited to 'win32/php_stdint.h')
-rw-r--r--win32/php_stdint.h46
1 files changed, 26 insertions, 20 deletions
diff --git a/win32/php_stdint.h b/win32/php_stdint.h
index cb5ad17061..e7615f1479 100644
--- a/win32/php_stdint.h
+++ b/win32/php_stdint.h
@@ -1,38 +1,42 @@
// ISO C9x compliant stdint.h for Microsoft Visual Studio
-// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
-//
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
+//
// Copyright (c) 2006-2009 Alexander Chemeris
-//
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
-//
+//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
-//
+//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
-//
+//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
-//
+//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
+//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif // _MSC_VER ]
+// Starting with vc14, many of the C11 features are now included, so we only
+// need many of these typedefs and defines for older VS suites
+#if _MSC_VER < 1900
+
#ifndef _MSC_STDINT_H_ // [
#define _MSC_STDINT_H_
@@ -51,7 +55,7 @@
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
#if (_MSC_VER < 1300) && defined(__cplusplus)
extern "C++" {
-#endif
+#endif
# include <wchar.h>
#if (_MSC_VER < 1300) && defined(__cplusplus)
}
@@ -85,9 +89,6 @@ typedef __int64 int64_t;
#ifndef uint8_t
typedef unsigned __int8 uint8_t;
#endif
-#ifndef u_char
-typedef unsigned __int8 u_char;
-#endif
typedef unsigned __int16 uint16_t;
#ifndef uint32_t
typedef unsigned __int32 uint32_t;
@@ -116,13 +117,8 @@ typedef uint32_t u_int32_t;
typedef uint64_t uint_fast64_t;
// 7.18.1.4 Integer types capable of holding object pointers
-#ifdef _WIN64 // [
- typedef __int64 intptr_t;
- typedef unsigned __int64 uintptr_t;
-#else // _WIN64 ][
- typedef _W64 int intptr_t;
- typedef _W64 unsigned int uintptr_t;
-#endif // _WIN64 ]
+/* intptr_t and uintptr_t are available from stddef.h */
+#include <stddef.h>
// 7.18.1.5 Greatest-width integer types
typedef int64_t intmax_t;
@@ -134,6 +130,7 @@ typedef uint64_t uintmax_t;
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
// 7.18.2.1 Limits of exact-width integer types
+#if _MSC_VER >= 1700 && !defined(_INTSAFE_H_INCLUDED_)
#define INT8_MIN ((int8_t)_I8_MIN)
#define INT8_MAX _I8_MAX
#define INT16_MIN ((int16_t)_I16_MIN)
@@ -146,6 +143,7 @@ typedef uint64_t uintmax_t;
#define UINT16_MAX _UI16_MAX
#define UINT32_MAX _UI32_MAX
#define UINT64_MAX _UI64_MAX
+#endif
// 7.18.2.2 Limits of minimum-width integer types
#define INT_LEAST8_MIN INT8_MIN
@@ -257,3 +255,11 @@ static __inline int64_t llabs(int64_t i)
#endif // _MSC_STDINT_H_ ]
+
+#else
+#include <stdint.h>
+#endif
+
+#ifndef u_char
+typedef unsigned __int8 u_char;
+#endif