From: Anatol Belski Date: Wed, 24 Jan 2018 09:14:28 +0000 (+0100) Subject: Move useful macro into zend_portability.h X-Git-Tag: php-7.3.0alpha1~551 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e2a9936d380494724680db1a1595bf922bedcfb;p=php Move useful macro into zend_portability.h --- diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index 92b9bb307e..f89258e0d6 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -521,7 +521,7 @@ static zend_always_inline double _zend_get_nan(void) /* {{{ */ #if defined(__GNUC__) && defined(__SSE4_2__) /* Instructions compiled directly. */ # define ZEND_INTRIN_SSE4_2_NATIVE 1 -#elif (defined(__i386__) || defined(__x86_64__)) && defined(HAVE_NMMINTRIN_H) || defined(PHP_WIN32) +#elif (defined(__i386__) || defined(__x86_64__)) && defined(HAVE_NMMINTRIN_H) || defined(ZEND_WIN32) /* Function resolved by ifunc or MINIT. */ # define ZEND_INTRIN_SSE4_2_RESOLVER 1 #endif @@ -532,6 +532,14 @@ static zend_always_inline double _zend_get_nan(void) /* {{{ */ # define ZEND_INTRIN_SSE4_2_FUNC_PTR 1 #endif +#ifdef ZEND_WIN32 +# define ZEND_SET_ALIGNED(alignment, decl) __declspec(align(alignment)) decl +#elif HAVE_ATTRIBUTE_ALIGNED +# define ZEND_SET_ALIGNED(alignment, decl) decl __attribute__ ((__aligned__ (alignment))) +#else +# define ZEND_SET_ALIGNED(alignment, decl) decl +#endif + #endif /* ZEND_PORTABILITY_H */ /* diff --git a/ext/standard/string.c b/ext/standard/string.c index 8915c532a4..cd2b028741 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -118,16 +118,8 @@ void register_string_constants(INIT_FUNC_ARGS) int php_tag_find(char *tag, size_t len, const char *set); -#ifdef PHP_WIN32 -# define SET_ALIGNED(alignment, decl) __declspec(align(alignment)) decl -#elif HAVE_ATTRIBUTE_ALIGNED -# define SET_ALIGNED(alignment, decl) decl __attribute__ ((__aligned__ (alignment))) -#else -# define SET_ALIGNED(alignment, decl) decl -#endif - /* this is read-only, so it's ok */ -SET_ALIGNED(16, static char hexconvtab[]) = "0123456789abcdef"; +ZEND_SET_ALIGNED(16, static char hexconvtab[]) = "0123456789abcdef"; /* localeconv mutex */ #ifdef ZTS @@ -3913,7 +3905,7 @@ PHPAPI zend_string *php_addslashes(zend_string *str, int should_free) /* {{{ */ zend_string *php_addslashes_sse42(zend_string *str, int should_free) # endif { - SET_ALIGNED(16, static const char slashchars[16]) = "\'\"\\\0"; + ZEND_SET_ALIGNED(16, static const char slashchars[16]) = "\'\"\\\0"; __m128i w128, s128; uint32_t res = 0; /* maximum string length, worst case situation */