summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-08-25 23:28:08 +0200
committerAnatol Belski <ab@php.net>2014-08-25 23:52:39 +0200
commitc429c74be966415085e781c6fbaf9fbf184ec164 (patch)
tree97dfd40f60490b630fef035196da07317e520b63
parent59848e3fbbcab3144c4d711df5d5be39cca51269 (diff)
downloadphp-git-c429c74be966415085e781c6fbaf9fbf184ec164.tar.gz
generalize the zend_long stuff
-rw-r--r--Zend/zend_long.h36
-rw-r--r--Zend/zend_types.h11
-rw-r--r--main/php_stdint.h1
3 files changed, 23 insertions, 25 deletions
diff --git a/Zend/zend_long.h b/Zend/zend_long.h
index a5ac2157f8..bc51132f44 100644
--- a/Zend/zend_long.h
+++ b/Zend/zend_long.h
@@ -61,12 +61,12 @@ typedef off_t zend_off_t;
# endif
# define SIZEOF_ZEND_LONG 8
#else
-typedef long zend_long;
-typedef unsigned long zend_ulong;
-typedef long zend_off_t;
-# define ZEND_LONG_MAX LONG_MAX
-# define ZEND_LONG_MIN LONG_MIN
-# define ZEND_ULONG_MAX ULONG_MAX
+typedef int32_t zend_long;
+typedef uint32_t zend_ulong;
+typedef int32_t zend_off_t;
+# define ZEND_LONG_MAX INT32_MAX
+# define ZEND_LONG_MIN INT32_MIN
+# define ZEND_ULONG_MAX UINT32_MAX
# define Z_L(i) i##L
# define Z_UL(i) i##UL
# define SIZEOF_ZEND_LONG SIZEOF_LONG
@@ -77,31 +77,27 @@ typedef long zend_off_t;
#define ZEND_LTOA_BUF_LEN 65
#ifdef ZEND_ENABLE_INT64
+# define ZEND_LONG_FMT "%" PRId64
+# define ZEND_ULONG_FMT "%" PRIu64
+# define ZEND_LONG_FMT_SPEC PRId64
+# define ZEND_ULONG_FMT_SPEC PRIu64
# ifdef PHP_WIN32
# define ZEND_LTOA(i, s, len) _i64toa_s((i), (s), (len), 10)
# define ZEND_ATOL(i, s) i = _atoi64((s))
# define ZEND_STRTOL(s0, s1, base) _strtoi64((s0), (s1), (base))
# define ZEND_STRTOUL(s0, s1, base) _strtoui64((s0), (s1), (base))
-# define ZEND_LONG_FMT "%I64d"
-# define ZEND_ULONG_FMT "%I64u"
-# define ZEND_LONG_FMT_SPEC "I64d"
-# define ZEND_ULONG_FMT_SPEC "I64u"
# define ZEND_STRTOL_PTR _strtoi64
# define ZEND_STRTOUL_PTR _strtoui64
# define ZEND_ABS _abs64
# else
# define ZEND_LTOA(i, s, len) \
do { \
- int st = snprintf((s), (len), "%lld", (i)); \
+ int st = snprintf((s), (len), ZEND_LONG_FMT, (i)); \
(s)[st] = '\0'; \
} while (0)
# define ZEND_ATOL(i, s) (i) = atoll((s))
# define ZEND_STRTOL(s0, s1, base) strtoll((s0), (s1), (base))
# define ZEND_STRTOUL(s0, s1, base) strtoull((s0), (s1), (base))
-# define ZEND_LONG_FMT "%" PRId64
-# define ZEND_ULONG_FMT "%" PRIu64
-# define ZEND_LONG_FMT_SPEC PRId64
-# define ZEND_ULONG_FMT_SPEC PRIu64
# define ZEND_STRTOL_PTR strtoll
# define ZEND_STRTOUL_PTR strtoull
# define ZEND_ABS llabs
@@ -109,21 +105,21 @@ typedef long zend_off_t;
#else
# define ZEND_STRTOL(s0, s1, base) strtol((s0), (s1), (base))
# define ZEND_STRTOUL(s0, s1, base) strtoul((s0), (s1), (base))
+# define ZEND_LONG_FMT "%" PRId32
+# define ZEND_ULONG_FMT "%" PRIu32
+# define ZEND_LONG_FMT_SPEC PRId32
+# define ZEND_ULONG_FMT_SPEC PRIu32
# ifdef PHP_WIN32
# define ZEND_LTOA(i, s, len) _ltoa_s((i), (s), (len), 10)
# define ZEND_ATOL(i, s) i = atol((s))
# else
# define ZEND_LTOA(i, s, len) \
do { \
- int st = snprintf((s), (len), "%ld", (i)); \
+ int st = snprintf((s), (len), ZEND_LONG_FMT, (i)); \
(s)[st] = '\0'; \
} while (0)
# define ZEND_ATOL(i, s) (i) = atol((s))
# endif
-# define ZEND_LONG_FMT "%ld"
-# define ZEND_ULONG_FMT "%lu"
-# define ZEND_LONG_FMT_SPEC "ld"
-# define ZEND_ULONG_FMT_SPEC "lu"
# define ZEND_STRTOL_PTR strtol
# define ZEND_STRTOUL_PTR strtoul
# define ZEND_ABS abs
diff --git a/Zend/zend_types.h b/Zend/zend_types.h
index d2b562ecd9..8404a2aa66 100644
--- a/Zend/zend_types.h
+++ b/Zend/zend_types.h
@@ -71,12 +71,13 @@ typedef unsigned long long zend_ulong64;
# undef HAVE_ZEND_LONG64
#endif
-#ifdef _WIN64
-typedef __int64 zend_intptr_t;
-typedef unsigned __int64 zend_uintptr_t;
+/* XXX this won't work on X32 platform */
+#ifdef ZEND_ENABLE_INT64
+typedef int64_t zend_intptr_t;
+typedef uint64_t zend_uintptr_t;
#else
-typedef long zend_intptr_t;
-typedef unsigned long zend_uintptr_t;
+typedef int32_t zend_intptr_t;
+typedef uint32_t zend_uintptr_t;
#endif
typedef struct _zend_object_handlers zend_object_handlers;
diff --git a/main/php_stdint.h b/main/php_stdint.h
index 14b32d7ca4..527ee3493d 100644
--- a/main/php_stdint.h
+++ b/main/php_stdint.h
@@ -28,6 +28,7 @@
# if !defined(_STDINT)
# define _STDINT
# include "win32/php_stdint.h"
+# include "win32/php_inttypes.h"
# endif
# define HAVE_INT8_T 1
# define HAVE_UINT8_T 1