From f3dde29394831c59fc927bd5e7a7800a3fbe8519 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 23 May 2015 21:15:11 +0200 Subject: [PATCH] Fixes for x32 ABI I'm assuming that we want to have 64bit zend_longs on x32 here. This fixes two typos in __x86_64__ macros and adds sign-extension when assigning STREAM_COPY_ALL to zend_long. --- Zend/zend_long.h | 2 +- Zend/zend_types.h | 6 +++--- ext/date/lib/timelib_structs.h | 2 +- ext/standard/file.c | 2 +- ext/standard/streamsfuncs.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Zend/zend_long.h b/Zend/zend_long.h index 1acd2cfb08..4c81105438 100644 --- a/Zend/zend_long.h +++ b/Zend/zend_long.h @@ -25,7 +25,7 @@ #include "main/php_stdint.h" /* This is the heart of the whole int64 enablement in zval. */ -#if defined(__X86_64__) || defined(__LP64__) || defined(_LP64) || defined(_WIN64) +#if defined(__x86_64__) || defined(__LP64__) || defined(_LP64) || defined(_WIN64) # define ZEND_ENABLE_ZVAL_LONG64 1 #endif diff --git a/Zend/zend_types.h b/Zend/zend_types.h index d66da1eade..3834835f86 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -802,7 +802,7 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) { return --GC_REFCOUNT(Z_COUNTED_P(pz)); } -#if SIZEOF_ZEND_LONG == 4 +#if SIZEOF_SIZE_T == 4 # define ZVAL_COPY_VALUE_EX(z, v, gc, t) \ do { \ uint32_t _w2 = v->value.ww.w2; \ @@ -810,14 +810,14 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) { z->value.ww.w2 = _w2; \ Z_TYPE_INFO_P(z) = t; \ } while (0) -#elif SIZEOF_ZEND_LONG == 8 +#elif SIZEOF_SIZE_T == 8 # define ZVAL_COPY_VALUE_EX(z, v, gc, t) \ do { \ Z_COUNTED_P(z) = gc; \ Z_TYPE_INFO_P(z) = t; \ } while (0) #else -# error "Unknbown SIZEOF_ZEND_LONG" +# error "Unknown SIZEOF_SIZE_T" #endif #define ZVAL_COPY_VALUE(z, v) \ diff --git a/ext/date/lib/timelib_structs.h b/ext/date/lib/timelib_structs.h index d68fbc1f28..33e9fce88c 100644 --- a/ext/date/lib/timelib_structs.h +++ b/ext/date/lib/timelib_structs.h @@ -121,7 +121,7 @@ typedef unsigned __int64 uint64_t; #include #endif -#if defined(__X86_64__) || defined(__LP64__) || defined(_LP64) || defined(_WIN64) +#if defined(__x86_64__) || defined(__LP64__) || defined(_LP64) || defined(_WIN64) typedef int64_t timelib_long; typedef uint64_t timelib_ulong; # define TIMELIB_LONG_MAX INT64_MAX diff --git a/ext/standard/file.c b/ext/standard/file.c index 7aa1ce7a85..01c043f0ad 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -522,7 +522,7 @@ PHP_FUNCTION(file_get_contents) zend_bool use_include_path = 0; php_stream *stream; zend_long offset = -1; - zend_long maxlen = PHP_STREAM_COPY_ALL; + zend_long maxlen = (ssize_t) PHP_STREAM_COPY_ALL; zval *zcontext = NULL; php_stream_context *context = NULL; zend_string *contents; diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index fa9758b06c..965bd67071 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -397,7 +397,7 @@ PHP_FUNCTION(stream_get_contents) { php_stream *stream; zval *zsrc; - zend_long maxlen = PHP_STREAM_COPY_ALL, + zend_long maxlen = (ssize_t) PHP_STREAM_COPY_ALL, desiredpos = -1L; zend_string *contents; -- 2.40.0