mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-26 18:35:42 +00:00
automated platform dependent zend_int_t declarations
This commit is contained in:
1 parent
9576330979
commit
fcb28ea97f
4 files changed
+149
-142
No files matched your search
+120
-117
@@ -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:
|
||||
*/
|
||||
+19
-17
@@ -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
|
||||
|
||||
+8
-6
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user