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>
#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
{
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;
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
}
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
}
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);