]> granicus.if.org Git - php/commitdiff
generalize the zend_long stuff
authorAnatol Belski <ab@php.net>
Mon, 25 Aug 2014 21:28:08 +0000 (23:28 +0200)
committerAnatol Belski <ab@php.net>
Mon, 25 Aug 2014 21:52:39 +0000 (23:52 +0200)
Zend/zend_long.h
Zend/zend_types.h
main/php_stdint.h

index a5ac2157f8524d0cbd5b09b460a2269bf8947d31..bc51132f4432c7ae841b006d4a3bb792f2600a60 100644 (file)
@@ -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
index d2b562ecd984b6e81c801618dd511c9e4e57010b..8404a2aa668a15f2f2428bfcab2ff277ad1e84f4 100644 (file)
@@ -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;
index 14b32d7ca4504b23f46b9751ebe3f4e31258afd5..527ee3493d95b5b4fec6a8296aead4fbecef4b35 100644 (file)
@@ -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