If the target attribute is available, attach it explicitly

The ifunc attribute might be not available as it is binary format
dependent.
This commit is contained in:
Anatol Belski 2018-02-03 17:15:18 +01:00
parent 1624b0a91f
commit a06cde8236
3 changed files with 22 additions and 4 deletions

View file

@ -514,6 +514,8 @@ static zend_always_inline double _zend_get_nan(void) /* {{{ */
# endif
#endif
/* Intrinsics macros start. */
#if defined(HAVE_FUNC_ATTRIBUTE_IFUNC) && defined(HAVE_FUNC_ATTRIBUTE_TARGET)
# define ZEND_INTRIN_HAVE_IFUNC_TARGET 1
#endif
@ -532,6 +534,18 @@ static zend_always_inline double _zend_get_nan(void) /* {{{ */
# define ZEND_INTRIN_SSE4_2_FUNC_PTR 1
#endif
#if ZEND_INTRIN_SSE4_2_RESOLVER
# if defined(HAVE_FUNC_ATTRIBUTE_TARGET)
# define ZEND_INTRIN_SSE4_2_FUNC_DECL(func) ZEND_API func __attribute__((target("sse4.2")))
# else
# define ZEND_INTRIN_SSE4_2_FUNC_DECL(func) func
# endif
#else
# define ZEND_INTRIN_SSE4_2_FUNC_DECL(func)
#endif
/* Intrinsics macros end. */
#ifdef ZEND_WIN32
# define ZEND_SET_ALIGNED(alignment, decl) __declspec(align(alignment)) decl
#elif HAVE_ATTRIBUTE_ALIGNED

View file

@ -3866,10 +3866,11 @@ PHPAPI zend_string *php_addcslashes(zend_string *str, int should_free, char *wha
# include "Zend/zend_bitset.h"
# include "Zend/zend_cpuinfo.h"
ZEND_INTRIN_SSE4_2_FUNC_DECL(zend_string *php_addslashes_sse42(zend_string *str, int should_free));
zend_string *php_addslashes_default(zend_string *str, int should_free);
# if ZEND_INTRIN_SSE4_2_FUNC_PROTO
PHPAPI zend_string *php_addslashes(zend_string *str, int should_free) __attribute__((ifunc("resolve_addslashes")));
zend_string *php_addslashes_sse42(zend_string *str, int should_free) __attribute__((target("sse4.2")));
zend_string *php_addslashes_default(zend_string *str, int should_free);
static void *resolve_addslashes() {
if (zend_cpu_supports(ZEND_CPU_FEATURE_SSE42)) {
@ -3878,8 +3879,6 @@ static void *resolve_addslashes() {
return php_addslashes_default;
}
# else /* ZEND_INTRIN_SSE4_2_FUNC_PTR */
zend_string *php_addslashes_sse42(zend_string *str, int should_free);
zend_string *php_addslashes_default(zend_string *str, int should_free);
PHPAPI zend_string *(*php_addslashes)(zend_string *str, int should_free) = NULL;

View file

@ -178,3 +178,8 @@
#define HAVE_FTOK 1
#define HAVE_NICE
#ifdef __clang__
#define HAVE_FUNC_ATTRIBUTE_TARGET 1
#endif