diff options
-rw-r--r-- | CMakeLists.txt | 30 | ||||
-rw-r--r-- | config.h.in | 1 | ||||
-rw-r--r-- | src/libutil/regexp.c | 8 |
3 files changed, 35 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d5a7677e0..5136213d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -792,6 +792,36 @@ CHECK_SYMBOL_EXISTS(sched_yield "sched.h" HAVE_SCHED_YIELD) CHECK_SYMBOL_EXISTS(__get_cpuid "cpuid.h" HAVE_GET_CPUID) CHECK_SYMBOL_EXISTS(PCRE_CONFIG_JIT "pcre.h" HAVE_PCRE_JIT) +# Some PCRE implementations are lacking of pcre_jit_exec fast path +SET(_PCRE_FAST_TEST " +#include \"pcre.h\" +int main (void) +{ + int rc; + int ovector[30]; + pcre *re; + pcre_extra *extra; + pcre_jit_stack *jit_stack; + + re = pcre_compile(\"abc\", 0, NULL, NULL, NULL); + extra = pcre_study(re, PCRE_STUDY_JIT_COMPILE, NULL); + jit_stack = pcre_jit_stack_alloc(32*1024, 512*1024); + pcre_assign_jit_stack(extra, NULL, jit_stack); + rc = pcre_jit_exec(re, extra, \"abc\", 3, 0, 0, ovector, 30, jit_stack); + + return rc; +} +") + +SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES} -lpcre") +CHECK_C_SOURCE_COMPILES("${_PCRE_FAST_TEST}" _PCRE_JIT_FAST) +IF(_PCRE_JIT_FAST) + SET(HAVE_PCRE_JIT_FAST 1) + MESSAGE(STATUS "pcre_jit_exec is supported") +ELSE(_PCRE_JIT_FAST) + MESSAGE(STATUS "pcre_jit_exec is -NOT- supported") +ENDIF(_PCRE_JIT_FAST) + FILE(WRITE ${CMAKE_BINARY_DIR}/pthread_setpshared.c " #include <pthread.h> #include <stdlib.h> diff --git a/config.h.in b/config.h.in index 5e262235a..211b4bba9 100644 --- a/config.h.in +++ b/config.h.in @@ -225,6 +225,7 @@ #cmakedefine HAVE_EXPLICIT_BZERO 1 #cmakedefine HAVE_WEAK_SYMBOLS 1 #cmakedefine HAVE_PCRE_JIT 1 +#cmakedefine HAVE_PCRE_JIT_FAST 1 #cmakedefine HAVE_GET_CPUID 1 #cmakedefine HAVE_CPUID_H 1 diff --git a/src/libutil/regexp.c b/src/libutil/regexp.c index c3b542fd9..6f7d07f6f 100644 --- a/src/libutil/regexp.c +++ b/src/libutil/regexp.c @@ -327,7 +327,7 @@ rspamd_regexp_search (rspamd_regexp_t *re, const gchar *text, gsize len, { pcre *r; pcre_extra *ext; -#if defined(HAVE_PCRE_JIT) && (PCRE_MAJOR == 8 && PCRE_MINOR >= 32) +#if defined(HAVE_PCRE_JIT) && defined(HAVE_PCRE_JIT_FAST) pcre_jit_stack *st = NULL; #endif const gchar *mt; @@ -362,7 +362,7 @@ rspamd_regexp_search (rspamd_regexp_t *re, const gchar *text, gsize len, if ((re->flags & RSPAMD_REGEXP_FLAG_RAW) || raw) { r = re->raw_re; ext = re->raw_extra; -#if defined(HAVE_PCRE_JIT) && (PCRE_MAJOR == 8 && PCRE_MINOR >= 32) +#if defined(HAVE_PCRE_JIT) && defined(HAVE_PCRE_JIT_FAST) st = re->raw_jstack; #endif } @@ -370,7 +370,7 @@ rspamd_regexp_search (rspamd_regexp_t *re, const gchar *text, gsize len, match_flags |= PCRE_NO_UTF8_CHECK; r = re->re; ext = re->extra; -#if defined(HAVE_PCRE_JIT) && (PCRE_MAJOR == 8 && PCRE_MINOR >= 32) +#if defined(HAVE_PCRE_JIT) && defined(HAVE_PCRE_JIT_FAST) st = re->jstack; #endif } @@ -379,7 +379,7 @@ rspamd_regexp_search (rspamd_regexp_t *re, const gchar *text, gsize len, if (!(re->flags & RSPAMD_REGEXP_FLAG_NOOPT)) { #ifdef HAVE_PCRE_JIT -# if (PCRE_MAJOR == 8 && PCRE_MINOR >= 32) +# ifdef HAVE_PCRE_JIT_FAST /* XXX: flags seems to be broken with jit fast path */ g_assert (remain > 0); g_assert (mt != NULL); |