Skip to content

Commit

Permalink
[mapscript/php] Fix build problems for PHP 7.3
Browse files Browse the repository at this point in the history
 * array_init is no longer function-like
   * generally was probably never worth checking the return type, so all
     checks for failure removed

 * Changes in API for reference counting for GC
  • Loading branch information
ejn committed Mar 4, 2019
1 parent ce2169f commit f1a579a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
4 changes: 1 addition & 3 deletions mapscript/php/php_mapscript.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -898,9 +898,7 @@ PHP_FUNCTION(ms_tokenizeMap)
filename); filename);
return; return;
} else { } else {
if (array_init(return_value) == FAILURE) { array_init(return_value);
RETURN_FALSE;
}


for (i=0; i<numtokens; i++) { for (i=0; i<numtokens; i++) {
#if PHP_VERSION_ID < 70000 #if PHP_VERSION_ID < 70000
Expand Down
26 changes: 21 additions & 5 deletions mapscript/php/php_mapscript_util.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -145,19 +145,34 @@ static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isre
FREE_HASHTABLE(zobj->std.properties); FREE_HASHTABLE(zobj->std.properties);
#endif /* PHP_VERSION_ID < 70000 */ #endif /* PHP_VERSION_ID < 70000 */


#if PHP_VERSION_ID >= 70300
#define MAPSCRIPT_ADDREF(zv) zend_gc_addref(&(Z_COUNTED(zv))->gc)
#define MAPSCRIPT_ADDREF_P(p) zend_gc_addref(&(Z_COUNTED_P(p))->gc)
#else
#if PHP_VERSION_ID >= 70000 #if PHP_VERSION_ID >= 70000
#define MAPSCRIPT_ADDREF(zv) if(!(Z_ISUNDEF(zv))) GC_REFCOUNT(Z_COUNTED(zv))++; #define MAPSCRIPT_ADDREF(zv) if(!(Z_ISUNDEF(zv))) GC_REFCOUNT(Z_COUNTED(zv))++;
#define MAPSCRIPT_ADDREF_P(zv) if(!(Z_ISUNDEF(*zv))) GC_REFCOUNT(Z_COUNTED_P(zv))++; #define MAPSCRIPT_ADDREF_P(zv) if(!(Z_ISUNDEF(*zv))) GC_REFCOUNT(Z_COUNTED_P(zv))++;
#else #else
#define MAPSCRIPT_ADDREF(zobj) if (zobj) Z_ADDREF_P(zobj) #define MAPSCRIPT_ADDREF(zobj) if (zobj) Z_ADDREF_P(zobj)
#define MAPSCRIPT_ADDREF_P(zv) MAPSCRIPT_ADDREF(zv) #define MAPSCRIPT_ADDREF_P(zv) MAPSCRIPT_ADDREF(zv)
#endif #endif /* PHP_VERSION_ID >= 70000 */
#endif /* PHP_VERSION_ID >= 70300 */


#if PHP_VERSION_ID >= 70300
#define MAPSCRIPT_DELREF(zv) \
if (!(Z_ISUNDEF(zv))) \
{ \
zend_refcounted *_gc = Z_COUNTED(zv); \
zend_gc_delref(&_gc->gc); \
if(GC_REFCOUNT(_gc) == 0) \
rc_dtor_func(_gc); \
ZVAL_UNDEF(&zv); \
}
#else
#if PHP_VERSION_ID >= 70000 #if PHP_VERSION_ID >= 70000
#ifndef _zval_dtor_func_for_ptr #if PHP_VERSION_ID >= 70100
//use _zval_dtor_func in PHP7.1 instead
#define _zval_dtor_func_for_ptr _zval_dtor_func #define _zval_dtor_func_for_ptr _zval_dtor_func
#endif #endif /* PHP_VERSION_ID >= 70100 */
#define MAPSCRIPT_DELREF(zv) \ #define MAPSCRIPT_DELREF(zv) \
if (!(Z_ISUNDEF(zv))) \ if (!(Z_ISUNDEF(zv))) \
{ \ { \
Expand All @@ -178,7 +193,8 @@ static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isre
} \ } \
zobj = NULL; \ zobj = NULL; \
} }
#endif #endif /* PHP_VERSION_ID >= 70000 */
#endif /* PHP_VERSION_ID >= 70300 */


#if PHP_VERSION_ID >= 70000 #if PHP_VERSION_ID >= 70000
#define MAPSCRIPT_FREE_PARENT(parent) \ #define MAPSCRIPT_FREE_PARENT(parent) \
Expand Down
16 changes: 4 additions & 12 deletions mapscript/php/php_proj.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -403,9 +403,7 @@ DLEXPORT void php_proj_pj_fwd(INTERNAL_FUNCTION_PARAMETERS)
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/* initilize return array. */ /* initilize return array. */
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
if (array_init(return_value) == FAILURE) { array_init(return_value);
RETURN_FALSE;
}


convert_to_double(p1); convert_to_double(p1);
convert_to_double(p2); convert_to_double(p2);
Expand Down Expand Up @@ -467,9 +465,7 @@ DLEXPORT void php_proj_pj_inv(INTERNAL_FUNCTION_PARAMETERS)
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/* initilize return array. */ /* initilize return array. */
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
if (array_init(return_value) == FAILURE) { array_init(return_value);
RETURN_FALSE;
}


convert_to_double(p1); convert_to_double(p1);
convert_to_double(p2); convert_to_double(p2);
Expand Down Expand Up @@ -524,9 +520,7 @@ DLEXPORT void php_proj_pj_transform(INTERNAL_FUNCTION_PARAMETERS)
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/* initilize return array. */ /* initilize return array. */
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
if (array_init(return_value) == FAILURE) { array_init(return_value);
RETURN_FALSE;
}


convert_to_double(p1); convert_to_double(p1);
convert_to_double(p2); convert_to_double(p2);
Expand Down Expand Up @@ -602,9 +596,7 @@ DLEXPORT void php_proj_pj_datum_transform(INTERNAL_FUNCTION_PARAMETERS)
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/* initilize return array. */ /* initilize return array. */
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
if (array_init(return_value) == FAILURE) { array_init(return_value);
RETURN_FALSE;
}


convert_to_double(p1); convert_to_double(p1);
convert_to_double(p2); convert_to_double(p2);
Expand Down

0 comments on commit f1a579a

Please sign in to comment.