mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Use memrchr() when available
On x86_64 glibc memrchr() uses SSE/AVX CPU extensions and works much faster then naive loop. On x86 32-bit we still use inlined version. memrchr() is a GNU extension. Its prototype becomes available when <string.h> is included with defined _GNU_SOURCE macro. Previously, we defined it in "php_config.h", but some sources may include <string.h> befire it. To avod mess we also pass -D_GNU_SOURCE to C compiler.
This commit is contained in:
@@ -211,6 +211,10 @@ zend_memnstr(const char *haystack, const char *needle, size_t needle_len, const
|
||||
|
||||
static zend_always_inline const void *zend_memrchr(const void *s, int c, size_t n)
|
||||
{
|
||||
#if defined(HAVE_MEMRCHR) && !defined(i386)
|
||||
/* On x86 memrchr() doesn't use SSE/AVX, so inlined version is faster */
|
||||
return (const void*)memrchr(s, c, n);
|
||||
#else
|
||||
const unsigned char *e;
|
||||
if (0 == n) {
|
||||
return NULL;
|
||||
@@ -222,6 +226,7 @@ static zend_always_inline const void *zend_memrchr(const void *s, int c, size_t
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
All other licensing and usage conditions are those of the PHP Group.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#include "zend.h"
|
||||
|
||||
@@ -265,6 +265,12 @@ else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
dnl The effect of _GNU_SOURCE defined in config.h depeds on includes order
|
||||
if test "$ac_cv_safe_to_define___extensions__" = yes ; then
|
||||
AC_MSG_CHECKING(whether to use -D_GNU_SOURCE cflag)
|
||||
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
|
||||
AC_MSG_RESULT(yes)
|
||||
fi
|
||||
|
||||
dnl Include Zend configurations.
|
||||
dnl ----------------------------------------------------------------------------
|
||||
@@ -609,6 +615,7 @@ vasprintf \
|
||||
asprintf \
|
||||
nanosleep \
|
||||
memmem \
|
||||
memrchr \
|
||||
)
|
||||
|
||||
AX_FUNC_WHICH_GETHOSTBYNAME_R
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#include "zend_exceptions.h"
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#include "php_zlib.h"
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
#include "php.h"
|
||||
|
||||
#include <zend_strtod.h>
|
||||
|
||||
@@ -72,7 +72,9 @@
|
||||
* SIO stdio-replacement strx_* functions by Panos Tsirigotis
|
||||
* <panos@alumni.cs.colorado.edu> for xinetd.
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
#include "php.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
#include "php.h"
|
||||
#include "php_globals.h"
|
||||
#include "php_network.h"
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
#include "php.h"
|
||||
#include "ext/standard/base64.h"
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
#include "php.h"
|
||||
#include "php_globals.h"
|
||||
#include "php_memory_streams.h"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/* (c) 2007,2008 Andrei Nigmatulin */
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
#include "fpm_config.h"
|
||||
|
||||
Reference in New Issue
Block a user