Browse Source

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.
pull/1304/head
Nikita Popov 11 years ago
parent
commit
f3dde29394
  1. 2
      Zend/zend_long.h
  2. 6
      Zend/zend_types.h
  3. 2
      ext/date/lib/timelib_structs.h
  4. 2
      ext/standard/file.c
  5. 2
      ext/standard/streamsfuncs.c

2
Zend/zend_long.h

@ -25,7 +25,7 @@
#include "main/php_stdint.h" #include "main/php_stdint.h"
/* This is the heart of the whole int64 enablement in zval. */ /* 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 # define ZEND_ENABLE_ZVAL_LONG64 1
#endif #endif

6
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)); 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) \ # define ZVAL_COPY_VALUE_EX(z, v, gc, t) \
do { \ do { \
uint32_t _w2 = v->value.ww.w2; \ 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->value.ww.w2 = _w2; \
Z_TYPE_INFO_P(z) = t; \ Z_TYPE_INFO_P(z) = t; \
} while (0) } while (0)
#elif SIZEOF_ZEND_LONG == 8
#elif SIZEOF_SIZE_T == 8
# define ZVAL_COPY_VALUE_EX(z, v, gc, t) \ # define ZVAL_COPY_VALUE_EX(z, v, gc, t) \
do { \ do { \
Z_COUNTED_P(z) = gc; \ Z_COUNTED_P(z) = gc; \
Z_TYPE_INFO_P(z) = t; \ Z_TYPE_INFO_P(z) = t; \
} while (0) } while (0)
#else #else
# error "Unknbown SIZEOF_ZEND_LONG"
# error "Unknown SIZEOF_SIZE_T"
#endif #endif
#define ZVAL_COPY_VALUE(z, v) \ #define ZVAL_COPY_VALUE(z, v) \

2
ext/date/lib/timelib_structs.h

@ -121,7 +121,7 @@ typedef unsigned __int64 uint64_t;
#include <strings.h> #include <strings.h>
#endif #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 int64_t timelib_long;
typedef uint64_t timelib_ulong; typedef uint64_t timelib_ulong;
# define TIMELIB_LONG_MAX INT64_MAX # define TIMELIB_LONG_MAX INT64_MAX

2
ext/standard/file.c

@ -522,7 +522,7 @@ PHP_FUNCTION(file_get_contents)
zend_bool use_include_path = 0; zend_bool use_include_path = 0;
php_stream *stream; php_stream *stream;
zend_long offset = -1; zend_long offset = -1;
zend_long maxlen = PHP_STREAM_COPY_ALL;
zend_long maxlen = (ssize_t) PHP_STREAM_COPY_ALL;
zval *zcontext = NULL; zval *zcontext = NULL;
php_stream_context *context = NULL; php_stream_context *context = NULL;
zend_string *contents; zend_string *contents;

2
ext/standard/streamsfuncs.c

@ -397,7 +397,7 @@ PHP_FUNCTION(stream_get_contents)
{ {
php_stream *stream; php_stream *stream;
zval *zsrc; zval *zsrc;
zend_long maxlen = PHP_STREAM_COPY_ALL,
zend_long maxlen = (ssize_t) PHP_STREAM_COPY_ALL,
desiredpos = -1L; desiredpos = -1L;
zend_string *contents; zend_string *contents;

Loading…
Cancel
Save