# zend.h breaks system headers on OSX in PHP 5.3

- Thread: https://externals.io/message/33044
- Original archive: https://news-web.php.net/php.internals/33044
- Started by Wez Furlong on 2007-11-07T04:43:01+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #33044 — Wez Furlong — 2007-11-07T04:43:01+00:00

URL: https://externals.io/message/33044#33044

The system headers on OSX use __attribute__((always_inline)) and  
zend.h defines always_inline to something else, breaking the build  
when the compiler tries to resolve that attribute name.

A solution is to prefix the defines used in the engine with zend or  
ZEND or other similar namespacing token, which I thought was our  
standard practice, considering everything else in there has a prefix.

If there have been other similar changes elsewhere, they should also  
be fixed

--Wez.

Index: zend.h
===================================================================
RCS file: /repository/ZendEngine2/zend.h,v
retrieving revision 1.293.2.11.2.9.2.9
diff -u -p -r1.293.2.11.2.9.2.9 zend.h
--- zend.h	2 Nov 2007 19:40:37 -0000	1.293.2.11.2.9.2.9
+++ zend.h	7 Nov 2007 04:36:01 -0000
@@ -324,42 +324,42 @@ struct _zval_struct {
  #define Z_SET_ISREF_TO(z, isref)	Z_SET_ISREF_TO_P(&(z), isref)

  #if defined(__GNUC__)
-#define always_inline inline __attribute__((always_inline))
+#define zend_always_inline inline __attribute__((always_inline))
  #elif defined(_MSC_VER)
-#define always_inline __forceinline
+#define zend_always_inline __forceinline
  #else
-#define always_inline inline
+#define zend_always_inline inline
  #endif

-static always_inline zend_uint zval_refcount_p(zval* pz) {
+static zend_always_inline zend_uint zval_refcount_p(zval* pz) {
  	return pz->refcount__gc;
  }

-static always_inline zend_uint zval_set_refcount_p(zval* pz,  
zend_uint rc) {
+static zend_always_inline zend_uint zval_set_refcount_p(zval* pz,  
zend_uint rc) {
  	return pz->refcount__gc = rc;
  }

-static always_inline zend_uint zval_addref_p(zval* pz) {
+static zend_always_inline zend_uint zval_addref_p(zval* pz) {
  	return ++pz->refcount__gc;
  }

-static always_inline zend_uint zval_delref_p(zval* pz) {
+static zend_always_inline zend_uint zval_delref_p(zval* pz) {
  	return --pz->refcount__gc;
  }

-static always_inline zend_bool zval_isref_p(zval* pz) {
+static zend_always_inline zend_bool zval_isref_p(zval* pz) {
  	return pz->is_ref__gc;
  }

-static always_inline zend_bool zval_set_isref_p(zval* pz) {
+static zend_always_inline zend_bool zval_set_isref_p(zval* pz) {
  	return pz->is_ref__gc = 1;
  }

-static always_inline zend_bool zval_unset_isref_p(zval* pz) {
+static zend_always_inline zend_bool zval_unset_isref_p(zval* pz) {
  	return pz->is_ref__gc = 0;
  }

-static always_inline zend_bool zval_set_isref_to_p(zval* pz,  
zend_bool isref) {
+static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz,  
zend_bool isref) {
  	return pz->is_ref__gc = isref;
  }

---

## #33045 — Dmitry Stogov — 2007-11-07T07:48:52+00:00

URL: https://externals.io/message/33044#33045 · In reply to: #33044

May be it is better to just define always_inline as inline on OSX.
Something like:

#if defined(__GNUC__) && !defined(OSX)
...

Thanks. Dmitry.

> -----Original Message-----
> From: Wez Furlong [mailto:wez.furlong@messagesystems.com] 
> Sent: Wednesday, November 07, 2007 7:43 AM
> To: internals@lists.php.net
> Subject: [PHP-DEV] zend.h breaks system headers on OSX in PHP 5.3
> 
> 
> The system headers on OSX use __attribute__((always_inline)) and  
> zend.h defines always_inline to something else, breaking the build  
> when the compiler tries to resolve that attribute name.
> 
> A solution is to prefix the defines used in the engine with zend or  
> ZEND or other similar namespacing token, which I thought was our  
> standard practice, considering everything else in there has a prefix.
> 
> If there have been other similar changes elsewhere, they should also  
> be fixed
> 
> --Wez.
> 
> Index: zend.h 
> ===================================================================
> RCS file: /repository/ZendEngine2/zend.h,v
> retrieving revision 1.293.2.11.2.9.2.9
> diff -u -p -r1.293.2.11.2.9.2.9 zend.h
> --- zend.h	2 Nov 2007 19:40:37 -0000	1.293.2.11.2.9.2.9
> +++ zend.h	7 Nov 2007 04:36:01 -0000
> @@ -324,42 +324,42 @@ struct _zval_struct {
>   #define Z_SET_ISREF_TO(z, isref)	Z_SET_ISREF_TO_P(&(z), isref)
> 
>   #if defined(__GNUC__)
> -#define always_inline inline __attribute__((always_inline))
> +#define zend_always_inline inline __attribute__((always_inline))
>   #elif defined(_MSC_VER)
> -#define always_inline __forceinline
> +#define zend_always_inline __forceinline
>   #else
> -#define always_inline inline
> +#define zend_always_inline inline
>   #endif
> 
> -static always_inline zend_uint zval_refcount_p(zval* pz) {
> +static zend_always_inline zend_uint zval_refcount_p(zval* pz) {
>   	return pz->refcount__gc;
>   }
> 
> -static always_inline zend_uint zval_set_refcount_p(zval* pz,  
> zend_uint rc) {
> +static zend_always_inline zend_uint zval_set_refcount_p(zval* pz,
> zend_uint rc) {
>   	return pz->refcount__gc = rc;
>   }
> 
> -static always_inline zend_uint zval_addref_p(zval* pz) {
> +static zend_always_inline zend_uint zval_addref_p(zval* pz) {
>   	return ++pz->refcount__gc;
>   }
> 
> -static always_inline zend_uint zval_delref_p(zval* pz) {
> +static zend_always_inline zend_uint zval_delref_p(zval* pz) {
>   	return --pz->refcount__gc;
>   }
> 
> -static always_inline zend_bool zval_isref_p(zval* pz) {
> +static zend_always_inline zend_bool zval_isref_p(zval* pz) {
>   	return pz->is_ref__gc;
>   }
> 
> -static always_inline zend_bool zval_set_isref_p(zval* pz) {
> +static zend_always_inline zend_bool zval_set_isref_p(zval* pz) {
>   	return pz->is_ref__gc = 1;
>   }
> 
> -static always_inline zend_bool zval_unset_isref_p(zval* pz) {
> +static zend_always_inline zend_bool zval_unset_isref_p(zval* pz) {
>   	return pz->is_ref__gc = 0;
>   }
> 
> -static always_inline zend_bool zval_set_isref_to_p(zval* pz,  
> zend_bool isref) {
> +static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz,
> zend_bool isref) {
>   	return pz->is_ref__gc = isref;
>   }
