generalize the zend_long stuff

This commit is contained in:
Anatol Belski 2014-08-25 23:28:08 +02:00
parent 59848e3fbb
commit c429c74be9
3 changed files with 23 additions and 25 deletions

View 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

View 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;

View 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