Commit: fcb28ea97f97cd85be1242fbb16ba5bca29f1cc7
Author: Anatol Belski <ab@php.net> Wed, 18 Dec 2013 10:52:14 +0100
Parents: 957633097913fac1780a5987da8373a8fbdb4e12
Branches: str_size_and_int64
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=fcb28ea97f97cd85be1242fbb16ba5bca29f1cc7
Log:
automated platform dependent zend_int_t declarations
Changed paths:
M Zend/zend_int.h
M Zend/zend_types.h
M configure.in
M win32/build/config.w32
diff --git a/Zend/zend_int.h b/Zend/zend_int.h
index 88b6f72..edda5ce 100644
--- a/Zend/zend_int.h
+++ b/Zend/zend_int.h
@@ -1,117 +1,120 @@
-
-
-#ifndef ZEND_INT_H
-#define ZEND_INT_H
-
-#ifndef ZEND_WIN32
-/* this probably needs more on non windows, like for C++ and C99*/
-# include <stdint.h>
-#endif
-
-/* Integer types or the old good long. This part will have to be
- reworked, obviously if we wanna some platform dependent stuff. */
-#ifdef ZEND_ENABLE_INT64
-# ifdef ZEND_WIN32
-# ifdef _WIN64
-typedef __int64 zend_int_t;
-typedef unsigned __int64 zend_uint_t;
-typedef __int64 zend_off_t;
-# define ZEND_INT_MAX _I64_MAX
-# define ZEND_INT_MIN _I64_MIN
-# define ZEND_UINT_MAX _UI64_MAX
-# define Z_I(i) i##i64
-# define Z_UI(i) i##Ui64
-# else
-# error Cant enable 64 bit integers on non 64 bit platform
-# endif
-# else
-# if defined(__LP64__) || defined(_LP64)
-typedef int64_t zend_int_t;
-typedef uint64_t zend_uint_t;
-typedef off_t zend_off_t;
-# define ZEND_INT_MAX INT64_MAX
-# define ZEND_INT_MIN INT64_MIN
-# define ZEND_UINT_MAX UINT64_MAX
-# define Z_I(i) i##LL
-# define Z_UI(i) i##ULL
-# else
-# error Cant enable 64 bit integers on non 64 bit platform
-# endif
-# endif
-# define SIZEOF_ZEND_INT 8
-#else
-typedef long zend_int_t;
-typedef unsigned long zend_uint_t;
-typedef long zend_off_t;
-# define ZEND_INT_MAX LONG_MAX
-# define ZEND_INT_MIN LONG_MIN
-# define ZEND_UINT_MAX ULONG_MAX
-# define Z_I(i) i##L
-# define Z_UI(i) i##UL
-# define SIZEOF_ZEND_INT SIZEOF_LONG
-#endif
-
-
-/* conversion macros */
-#define ZEND_ITOA_BUF_LEN 65
-
-#ifdef ZEND_ENABLE_INT64
-# ifdef PHP_WIN32
-# define ZEND_ITOA(i, s, len) _i64toa_s((i), (s), (len), 10)
-# define ZEND_ATOI(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_INT_FMT "%I64d"
-# define ZEND_UINT_FMT "%I64u"
-# define ZEND_INT_FMT_SPEC "I64d"
-# define ZEND_UINT_FMT_SPEC "I64u"
-# define ZEND_STRTOL_PTR _strtoi64
-# define ZEND_STRTOUL_PTR _strtoui64
-# else
-# define ZEND_ITOA(i, s, len) \
- do { \
- int st = snprintf((s), (len), "%lld", (i)); \
- (s)[st] = '\0'; \
- } while (0)
-# define ZEND_ATOI(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_INT_FMT "%lld"
-# define ZEND_UINT_FMT "%llu"
-# define ZEND_INT_FMT_SPEC "lld"
-# define ZEND_UINT_FMT_SPEC "llu"
-# define ZEND_STRTOL_PTR strtoll
-# define ZEND_STRTOUL_PTR strtoull
-# endif
-#else
-# define ZEND_STRTOL(s0, s1, base) strtol((s0), (s1), (base))
-# define ZEND_STRTOUL(s0, s1, base) strtoul((s0), (s1), (base))
-# ifdef PHP_WIN32
-# define ZEND_ITOA(i, s, len) _ltoa_s((i), (s), (len), 10)
-# define ZEND_ATOI(i, s) i = atol((s))
-# else
-# define ZEND_ITOA(i, s, len) \
- do { \
- int st = snprintf((s), (len), "%ld", (i)); \
- (s)[st] = '\0'; \
- } while (0)
-# define ZEND_ATOI(i, s) (i) = atol((s))
-# endif
-# define ZEND_INT_FMT "%ld"
-# define ZEND_UINT_FMT "%lu"
-# define ZEND_INT_FMT_SPEC "ld"
-# define ZEND_UINT_FMT_SPEC "lu"
-# define ZEND_STRTOL_PTR strtol
-# define ZEND_STRTOUL_PTR strtoul
-#endif
-
-
-#endif /* ZEND_INT_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * indent-tabs-mode: t
- * End:
- */
+
+
+#ifndef ZEND_INT_H
+#define ZEND_INT_H
+
+#ifndef ZEND_WIN32
+/* this probably needs more on non windows, like for C++ and C99*/
+# include <stdint.h>
+#endif
+
+#if defined(__X86_64__) || defined(__LP64__) || defined(_LP64) || defined(_WIN64)
+# define ZEND_ENABLE_INT64 1
+#endif
+
+/* Integer types or the old bad long. */
+#ifdef ZEND_ENABLE_INT64
+# ifdef ZEND_WIN32
+# ifdef _WIN64
+typedef __int64 zend_int_t;
+typedef unsigned __int64 zend_uint_t;
+typedef __int64 zend_off_t;
+# define ZEND_INT_MAX _I64_MAX
+# define ZEND_INT_MIN _I64_MIN
+# define ZEND_UINT_MAX _UI64_MAX
+# define Z_I(i) i##i64
+# define Z_UI(i) i##Ui64
+# else
+# error Cant enable 64 bit integers on non 64 bit platform
+# endif
+# else
+# if defined(__X86_64__) || defined(__LP64__) || defined(_LP64)
+typedef int64_t zend_int_t;
+typedef uint64_t zend_uint_t;
+typedef off_t zend_off_t;
+# define ZEND_INT_MAX INT64_MAX
+# define ZEND_INT_MIN INT64_MIN
+# define ZEND_UINT_MAX UINT64_MAX
+# define Z_I(i) i##LL
+# define Z_UI(i) i##ULL
+# else
+# error Cant enable 64 bit integers on non 64 bit platform
+# endif
+# endif
+# define SIZEOF_ZEND_INT 8
+#else
+typedef long zend_int_t;
+typedef unsigned long zend_uint_t;
+typedef long zend_off_t;
+# define ZEND_INT_MAX LONG_MAX
+# define ZEND_INT_MIN LONG_MIN
+# define ZEND_UINT_MAX ULONG_MAX
+# define Z_I(i) i##L
+# define Z_UI(i) i##UL
+# define SIZEOF_ZEND_INT SIZEOF_LONG
+#endif
+
+
+/* conversion macros */
+#define ZEND_ITOA_BUF_LEN 65
+
+#ifdef ZEND_ENABLE_INT64
+# ifdef PHP_WIN32
+# define ZEND_ITOA(i, s, len) _i64toa_s((i), (s), (len), 10)
+# define ZEND_ATOI(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_INT_FMT "%I64d"
+# define ZEND_UINT_FMT "%I64u"
+# define ZEND_INT_FMT_SPEC "I64d"
+# define ZEND_UINT_FMT_SPEC "I64u"
+# define ZEND_STRTOL_PTR _strtoi64
+# define ZEND_STRTOUL_PTR _strtoui64
+# else
+# define ZEND_ITOA(i, s, len) \
+ do { \
+ int st = snprintf((s), (len), "%lld", (i)); \
+ (s)[st] = '\0'; \
+ } while (0)
+# define ZEND_ATOI(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_INT_FMT "%lld"
+# define ZEND_UINT_FMT "%llu"
+# define ZEND_INT_FMT_SPEC "lld"
+# define ZEND_UINT_FMT_SPEC "llu"
+# define ZEND_STRTOL_PTR strtoll
+# define ZEND_STRTOUL_PTR strtoull
+# endif
+#else
+# define ZEND_STRTOL(s0, s1, base) strtol((s0), (s1), (base))
+# define ZEND_STRTOUL(s0, s1, base) strtoul((s0), (s1), (base))
+# ifdef PHP_WIN32
+# define ZEND_ITOA(i, s, len) _ltoa_s((i), (s), (len), 10)
+# define ZEND_ATOI(i, s) i = atol((s))
+# else
+# define ZEND_ITOA(i, s, len) \
+ do { \
+ int st = snprintf((s), (len), "%ld", (i)); \
+ (s)[st] = '\0'; \
+ } while (0)
+# define ZEND_ATOI(i, s) (i) = atol((s))
+# endif
+# define ZEND_INT_FMT "%ld"
+# define ZEND_UINT_FMT "%lu"
+# define ZEND_INT_FMT_SPEC "ld"
+# define ZEND_UINT_FMT_SPEC "lu"
+# define ZEND_STRTOL_PTR strtol
+# define ZEND_STRTOUL_PTR strtoul
+#endif
+
+
+#endif /* ZEND_INT_H */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * End:
+ */
diff --git a/Zend/zend_types.h b/Zend/zend_types.h
index 6f2097e..ea3f299 100644
--- a/Zend/zend_types.h
+++ b/Zend/zend_types.h
@@ -22,38 +22,40 @@
#ifndef ZEND_TYPES_H
#define ZEND_TYPES_H
+#include "zend_int.h"
+
typedef unsigned char zend_bool;
typedef unsigned char zend_uchar;
typedef unsigned int zend_uint;
typedef unsigned long zend_ulong;
typedef unsigned short zend_ushort;
-#ifdef ZEND_USE_LEGACY_STRING_TYPES
-# define zend_str_size_int int
-# define zend_str_size_uint unsigned int
-# define zend_str_size_size_t size_t
-# define zend_str_size_long long
-# define ZEND_SIZE_MAX_LONG LONG_MAX
-# define ZEND_SIZE_MAX_INT INT_MAX
-typedef int zend_str_size;
-#else
+#ifdef ZEND_ENABLE_INT64
# define zend_str_size_int zend_str_size
# define zend_str_size_uint zend_str_size
# define zend_str_size_size_t zend_str_size
# define zend_str_size_long zend_str_size
-# ifdef PHP_WIN32
-# ifdef _WIN64
-# define ZEND_SIZE_MAX_LONG _UI64_MAX
-# define ZEND_SIZE_MAX_INT _UI64_MAX
-# else
-# define ZEND_SIZE_MAX_LONG _UI32_MAX
-# define ZEND_SIZE_MAX_INT _UI32_MAX
-# endif
+# ifdef ZEND_WIN32
+# define ZEND_SIZE_MAX_LONG _UI64_MAX
+# define ZEND_SIZE_MAX_INT _UI64_MAX
# else
# define ZEND_SIZE_MAX_LONG SIZE_MAX
# define ZEND_SIZE_MAX_INT SIZE_MAX
# endif
typedef size_t zend_str_size;
+#else
+# define zend_str_size_int int
+# define zend_str_size_uint unsigned int
+# define zend_str_size_size_t size_t
+# define zend_str_size_long long
+# if defined(ZEND_WIN32)
+# define ZEND_SIZE_MAX_LONG _UI32_MAX
+# define ZEND_SIZE_MAX_INT _UI32_MAX
+# else
+# define ZEND_SIZE_MAX_LONG LONG_MAX
+# define ZEND_SIZE_MAX_INT INT_MAX
+# endif
+typedef int zend_str_size;
#endif
#define HAVE_ZEND_LONG64
diff --git a/configure.in b/configure.in
index 9fa6762..6f508b0 100644
--- a/configure.in
+++ b/configure.in
@@ -864,19 +864,21 @@ else
ZEND_DEBUG=no
fi
+#XXX remove this option, placebo for now
PHP_ARG_ENABLE(zstrlen, whether to include Z_STRLEN macros,
[ --enable-zstrlen Enable legacy Z_STRLEN macros and types], no, no)
-if test "$PHP_ZSTRLEN" = "yes"; then
- AC_DEFINE(ZEND_USE_LEGACY_STRING_TYPES, "1", [ ])
-fi
+#if test "$PHP_ZSTRLEN" = "yes"; then
+# AC_DEFINE(ZEND_USE_LEGACY_STRING_TYPES, "1", [ ])
+#fi
+#XXX remove this option, placebo for now
PHP_ARG_ENABLE(zint64, whether to enable 64 bit integers,
[ --enable-zint64 Enable 64 bit integers], no, no)
-if test "$PHP_ZINT64" = "yes"; then
- AC_DEFINE(ZEND_ENABLE_INT64, "1", [ ])
-fi
+#if test "$PHP_ZINT64" = "yes"; then
+# AC_DEFINE(ZEND_ENABLE_INT64, "1", [ ])
+#fi
PHP_ARG_WITH(layout, layout of installed files,
[ --with-layout=TYPE Set how installed files will be laid out. Type can
diff --git a/win32/build/config.w32 b/win32/build/config.w32
index b3b7c11..3efdcfe 100644
--- a/win32/build/config.w32
+++ b/win32/build/config.w32
@@ -452,11 +452,11 @@ if (PHP_STATIC_ANALYZE == "yes") {
ARG_ENABLE("zstrlen", "Include Z_STRLEN macros enabling size_t for string length", "no");
if (PHP_ZSTRLEN == "yes") {
- AC_DEFINE('ZEND_USE_LEGACY_STRING_TYPES', 1, "");
+ // XXX remove this option, placebo for now
}
ARG_ENABLE("zint64", "Enable 64 bit integers", "no");
if (PHP_ZINT64== "yes") {
- AC_DEFINE('ZEND_ENABLE_INT64', 1, "");
+ // XXX remove this option, placebo for now
}