]> source.dussan.org Git - rspamd.git/commitdiff
Some pcre distributions are brain damaged.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 6 May 2015 11:27:35 +0000 (12:27 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 6 May 2015 11:27:35 +0000 (12:27 +0100)
CMakeLists.txt
config.h.in
src/libutil/regexp.c

index d5a7677e0cc306ab42f67e218466e2175265ed75..5136213d971282984b20e90f6f90ed3964833bf5 100644 (file)
@@ -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>
index 5e262235a234e38419d7b1d908e1dfcb4c29753e..211b4bba983646712fa10ca89f6eaa6c99aff89f 100644 (file)
 #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
 
index c3b542fd9b148634d8c0007dffdd81ed033777ec..6f7d07f6fc4f90d22a605ebcb227a6728f7e1707 100644 (file)
@@ -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);