Update PCRE JIT code to support official JIT implementation in pcre-8.20-RC1.

remotes/origin/master-1.1.x
Victor Julien 14 years ago
parent 751a77a9be
commit 3d396e8b1e

@ -296,40 +296,64 @@ AC_INIT(configure.in)
echo echo
fi fi
#enable suppot for PCRE-sljit http://sljit.sourceforge.net/pcre.html #enable support for PCRE-jit available since pcre-8.20
AC_ARG_ENABLE(pcre-sljit, AC_ARG_ENABLE(pcre-jit,
AS_HELP_STRING([--enable-pcre-sljit], [Enable experimental support for PCRE-sljit]),,[enable_pcre_sljit=no]) AS_HELP_STRING([--enable-pcre-jit], [Enable experimental support for PCRE-jit]),,[enable_pcre_jit=no])
AS_IF([test "x$enable_pcre_sljit" = "xyes"], [ AS_IF([test "x$enable_pcre_jit" = "xyes"], [
AC_MSG_CHECKING(for PCRE sljit support) AC_MSG_CHECKING(for PCRE JIT support)
AC_TRY_COMPILE([ #include <pcre.h> ], AC_TRY_COMPILE([ #include <pcre.h> ],
[ const char* regexstr = "(a|b|c|d)"; [
pcre *re; int jit = 0;
const char *error; pcre_config(PCRE_CONFIG_JIT, &jit);
pcre_extra *extra; ],
int err_offset; [ pcre_jit_available=yes ], [:]
re = pcre_compile(regexstr,0, &error, &err_offset,NULL);
extra = pcre_study(re, PCRE_STUDY_JIT_COMPILE, &error);
if (!(extra->flags & PCRE_EXTRA_EXECUTABLE_FUNC)) {
printf("\nJIT compiler does not support: %s\n", regexstr);
}
return 0;],
[ pcre_sljit_available=yes ], [:]
) )
if test "x$pcre_sljit_available" = "xyes"; then if test "x$pcre_jit_available" = "xyes"; then
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
AC_DEFINE([PCRE_HAVE_SLJIT], [1], [Pcre with JIT compiler support enabled]) AC_DEFINE([PCRE_HAVE_JIT], [1], [Pcre with JIT compiler support enabled])
else
AC_MSG_RESULT(no)
echo
echo " Error! --enable-pcre-sljit set but PCRE_STUDY_JIT_COMPILE not found"
echo " Make sure you use pcre found here "
echo " http://sljit.sourceforge.net/pcre.html"
echo
exit 1
fi
AC_MSG_CHECKING(for PCRE JIT support usability)
AC_TRY_COMPILE([ #include <pcre.h> ],
[
const char* regexstr = "(a|b|c|d)";
pcre *re;
const char *error;
pcre_extra *extra;
int err_offset;
re = pcre_compile(regexstr,0, &error, &err_offset,NULL);
extra = pcre_study(re, PCRE_STUDY_JIT_COMPILE, &error);
if (extra == NULL)
exit(EXIT_FAILURE);
int jit = 0;
int ret = pcre_fullinfo(re, extra, PCRE_INFO_JIT, &jit);
if (ret != 0 || jit != 1)
exit(EXIT_FAILURE);
exit(EXIT_SUCCESS);
],
[ pcre_jit_works=yes ], [:]
)
if test "x$pcre_jit_works" != "xyes"; then
AC_MSG_RESULT(no)
echo
echo " PCRE JIT support detection worked but testing it failed"
echo " something odd is going on, please file a bug report."
echo
exit 1
else
AC_MSG_RESULT(yes)
fi
else
AC_MSG_RESULT(no)
echo
echo " Error! --enable-pcre-jit set but PCRE_CONFIG_JIT not found"
echo " Make sure your PCRE supports JIT. Version 8.20+ with"
echo " --enable-jit passed to it's configure script."
echo
exit 1
fi
]) ])
#libyaml #libyaml
AC_ARG_WITH(libyaml_includes, AC_ARG_WITH(libyaml_includes,
[ --with-libyaml-includes=DIR libyaml include directory], [ --with-libyaml-includes=DIR libyaml include directory],
@ -1031,5 +1055,5 @@ Suricata Configuration:
GCC Profile enabled: ${enable_gccprofile} GCC Profile enabled: ${enable_gccprofile}
Unified native time: ${enable_unified_native_timeval} Unified native time: ${enable_unified_native_timeval}
Non-bundled htp: ${enable_non_bundled_htp} Non-bundled htp: ${enable_non_bundled_htp}
PCRE sljit: ${enable_pcre_sljit} PCRE jit: ${enable_pcre_jit}
" "

@ -879,14 +879,17 @@ DetectPcreData *DetectPcreParse (char *regexstr)
SCLogError(SC_ERR_PCRE_COMPILE, "pcre compile of \"%s\" failed at offset %" PRId32 ": %s", regexstr, eo, eb); SCLogError(SC_ERR_PCRE_COMPILE, "pcre compile of \"%s\" failed at offset %" PRId32 ": %s", regexstr, eo, eb);
goto error; goto error;
} }
#ifdef PCRE_HAVE_SLJIT #ifdef PCRE_HAVE_JIT
pd->sd = pcre_study(pd->re, PCRE_STUDY_JIT_COMPILE, &eb); pd->sd = pcre_study(pd->re, PCRE_STUDY_JIT_COMPILE, &eb);
if(eb != NULL) { if(eb != NULL) {
SCLogError(SC_ERR_PCRE_STUDY, "pcre study failed : %s", eb); SCLogError(SC_ERR_PCRE_STUDY, "pcre study failed : %s", eb);
goto error; goto error;
} }
if (!(pd->sd->flags & PCRE_EXTRA_EXECUTABLE_FUNC)) {
SCLogWarning(SC_ERR_PCRE_STUDY, "JIT compiler does not support: %s", regexstr); int jit = 0;
ret = pcre_fullinfo(pd->re, pd->sd, PCRE_INFO_JIT, &jit);
if (ret != 0 || jit != 1) {
SCLogWarning(SC_ERR_PCRE_STUDY, "PCRE JIT compiler does not support: %s", regexstr);
} }
#else #else
pd->sd = pcre_study(pd->re, 0, &eb); pd->sd = pcre_study(pd->re, 0, &eb);

@ -506,8 +506,8 @@ void SCPrintBuildInfo(void) {
#ifdef HAVE_HTP_URI_NORMALIZE_HOOK #ifdef HAVE_HTP_URI_NORMALIZE_HOOK
strlcat(features, "HAVE_HTP_URI_NORMALIZE_HOOK ", sizeof(features)); strlcat(features, "HAVE_HTP_URI_NORMALIZE_HOOK ", sizeof(features));
#endif #endif
#ifdef PCRE_HAVE_SLJIT #ifdef PCRE_HAVE_JIT
strlcat(features, "PCRE_SLJIT ", sizeof(features)); strlcat(features, "PCRE_JIT ", sizeof(features));
#endif #endif
if (strlen(features) == 0) { if (strlen(features) == 0) {
strlcat(features, "none", sizeof(features)); strlcat(features, "none", sizeof(features));

Loading…
Cancel
Save