pax_global_header00006660000000000000000000000064132320271710014510gustar00rootroot0000000000000052 comment=0a1c5c43ca5b3cfb48ee90a678890f3f5b56aa3a hyperscan-4.7.0/000077500000000000000000000000001323202717100135145ustar00rootroot00000000000000hyperscan-4.7.0/.clang-format000066400000000000000000000002141323202717100160640ustar00rootroot00000000000000BasedOnStyle: LLVM IndentWidth: 4 UseTab: false AllowShortIfStatementsOnASingleLine: false IndentCaseLabels: false AccessModifierOffset: -4 hyperscan-4.7.0/.gitignore000066400000000000000000000030261323202717100155050ustar00rootroot00000000000000## ## There are some more .gitignore files in subdirs, but this is the main place ## to add new entries. These are mostly for the common case when ue2 is built ## in place ## # Autogenerated stuff that we don't want to know about .deps autom4te.cache autojunk .dirstamp # Temp and swap files *~ .*.swp .sw? # compiler output and binaries *.a *.o *.lo *.la *.so *.pyc .libs bin # Merge files created by git. *.orig # sigs dir is handled externally signatures # but not the regression tests !tools/hscollider/test_cases/signatures # ignore pcre symlink if it exists pcre # but not pcre subdirs! !pcre/ # ignore boost symlink if it exists include/boost # ignore sqlite3 symlink if it exists sqlite3 # Generated files src/config.h src/config.h.in src/hs_version.h src/parser/Parser.cpp # Generated PCRE files pcre/pcre_chartables.c pcre/pcregrep pcre/pcretest # Autoconf/automake/libtool noise Makefile Makefile.in aclocal.m4 config.cache config.log config.status configure libhs.pc libtool m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 src/stamp-h1 # Docs !doc/dev-reference/Makefile # not generated doc/dev-reference/doxygen_sqlite3.db doc/dev-reference/doxygen_xml/ doc/dev-reference/_build/ # Autotools noise in pcre pcre/INSTALL pcre/Makefile pcre/Makefile.in pcre/aclocal.m4 pcre/ar-lib pcre/compile pcre/config.* pcre/configure pcre/depcomp pcre/install-sh pcre/*.pc pcre/libtool pcre/ltmain.sh pcre/missing pcre/pcre-config pcre/pcre.h pcre/pcre_stringpiece.h pcre/pcrecpparg.h pcre/stamp-h1 pcre/test-driver hyperscan-4.7.0/CHANGELOG.md000066400000000000000000000277171323202717100153430ustar00rootroot00000000000000# Hyperscan Change Log This is a list of notable changes to Hyperscan, in reverse chronological order. ## [4.7.0] 2018-01-24 - Introduced hscollider pattern testing tool, for validating Hyperscan match behaviour against PCRE. - Introduced hscheck pattern compilation tool. - Introduced hsdump development tool for producing information about Hyperscan pattern compilation. - New API feature: extended approximate matching support for Hamming distance. - Bugfix for issue #69: Force C++ linkage in Xcode. - Bugfix for issue #73: More documentation for `hs_close_stream()`. - Bugfix for issue #78: Fix for fat runtime initialisation when used as a shared library. ## [4.6.0] 2017-09-22 - New API feature: stream state compression. This allows the user to compress and restore state for streams to reduce memory usage. - Many improvements to literal matching performance, including more support for Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX-512). - Compile time improvements, mainly reducing compiler memory allocation. Also results in reduced compile time for some pattern sets. - Bugfix for issue #62: fix error building Hyperscan using older versions of Boost. - Small updates to fix warnings identified by Coverity. ## [4.5.2] 2017-07-26 - Bugfix for issue #57: Treat characters between `\Q.\E` as codepoints in UTF8 mode. - Bugfix for issue #60: Use a portable flag for mktemp for fat runtime builds. - Bugfix for fat runtime builds on AVX-512 capable machines with Hyperscan's AVX-512 support disabled. ## [4.5.1] 2017-06-16 - Bugfix for issue #56: workaround for gcc-4.8 C++11 defect. - Bugfix for literal matching table generation, reversing a regression in performance for some literal matching cases. - Bugfixes for hsbench, related to multicore benchmarking, portability fixes for FreeBSD, and clarifying output results. - CMake: removed a duplicate else branch that causes very recent (v3.9) builds of CMake to fail. ## [4.5.0] 2017-06-09 - New API feature: approximate matching using the "edit distance" extended parameter. This allows the user to request all matches that are a given edit distance from an exact match for a pattern. - Initial support for Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX-512), disabled by default. To enable it, pass `-DBUILD_AVX512=1` to `cmake`. - Major compile time improvements in many subsystems, reducing compile time significantly for many large pattern sets. - Internal reworking of literal matchers to operate on literals of at most eight characters, with subsequent confirmation done in the Rose interpreter. This reduces complexity and bytecode size and improves performance for many pattern sets. - Improve performance of the FDR literal matcher front end. - Improve bucket assignment and other heuristics governing the FDR literal matcher. - Improve optimisation passes that take advantage of extended parameter constraints (`min_offset`, etc). - Introduce further lookaround specialisations to improve scanning performance. - Optimise Rose interpreter construction to reduce the length of programs generated in some situations. - Remove the old "Rose" pattern decomposition analysis pass in favour of the new "Violet" pass introduced in Hyperscan 4.3.0. - In streaming mode, allow exhaustion (where the stream can no longer produce matchers) to be detected in more situations, improving scanning performance. - Improve parsing of control verbs (such as `(*UTF8)`) that can only occur at the beginning of the pattern. Combinations of supported verbs in any order are now permitted. - Update version of PCRE used by testing tools as a syntax and semantic reference to PCRE 8.40. - Tuning support for Intel(R) microarchitecture code names Skylake, Skylake Server, Goldmont. - CMake: when building a native build with a version of GCC that doesn't recognise the host compiler, tune for the microarch selected by `-march=native`. - CMake: don't fail if SQLite (which is only required to build the `hsbench` tool) is not present. - CMake: detect libc++ directly and use that to inform the Boost version requirement. - Bugfix for issue #51: make the fat runtime build wrapper less fragile. - Bugfix for issues #46, #52: use `sqlite3_errmsg()` to allow SQLite 3.6.x to be used. Thanks to @EaseTheWorld for the PR. ## [4.4.1] 2017-02-28 - Bugfixes to fix issues where stale data was being referenced in scratch memory. In particular this may have resulted in `hs_close_stream()` referencing data from other previously scanned streams. This may result in incorrect matches being been reported. ## [4.4.0] 2017-01-20 - Introduce the "fat runtime" build. This will build several variants of the Hyperscan scanning engine specialised for different processor feature sets, and use the appropriate one for the host at runtime. This uses the "ifunc" indirect function attribute provided by GCC and is currently available on Linux only, where it is the default for release builds. - New API function: add the `hs_valid_platform()` function. This function tests whether the host provides the SSSE3 instruction set required by Hyperscan. - Introduce a new standard benchmarking tool, "hsbench". This provides an easy way to measure Hyperscan's performance for a particular set of patterns and corpus of data to be scanned. - Introduce a 64-bit GPR LimEx NFA model, which uses 64-bit GPRs on 64-bit hosts and SSE registers on 32-bit hosts. - Introduce a new DFA model ("McSheng") which is a hybrid of the existing McClellan and Sheng models. This improves scanning performance for some cases. - Introduce lookaround specialisations to improve scanning performance. - Improve the handling of long literals by moving confirmation to the Rose interpreter and simplifying the hash table used to track them in streaming mode. - Improve compile time optimisation for removing redundant paths from expression graphs. - Build: improve support for building with MSVC toolchain. - Reduce the size of small write DFAs used for small scans in block mode. - Introduce a custom graph type (`ue2_graph`) used in place of the Boost Graph Library's `adjacency_list` type. Improves compile time performance and type safety. - Improve scanning performance of the McClellan DFA. - Bugfix for a very unusual SOM case where the incorrect start offset was reported for a match. - Bugfix for issue #37, removing execute permissions from some source files. - Bugfix for issue #41, handle Windows line endings in pattern files. ## [4.3.2] 2016-11-15 - Bugfix for issue #39. This small change is a workaround for an issue in Boost 1.62. The fix has been submitted to Boost for inclusion in a future release. ## [4.3.1] 2016-08-29 - Bugfix for issue #30. In recent versions of Clang, a write to a variable was being elided, resulting in corrupted stream state after calling `hs_reset_stream()`. ## [4.3.0] 2016-08-24 - Introduce a new analysis pass ("Violet") used for decomposition of patterns into literals and smaller engines. - Introduce a new container engine ("Tamarama") for infix and suffix engines that can be proven to run exclusively of one another. This reduces stream state for pattern sets with many such engines. - Introduce a new shuffle-based DFA engine ("Sheng"). This improves scanning performance for pattern sets where small engines are generated. - Improve the analysis used to extract extra mask information from short literals. - Reduced compile time spent in equivalence class analysis. - Build: frame pointers are now only omitted for 32-bit release builds. - Build: Workaround for C++ issues reported on FreeBSD/libc++ platforms. (github issue #27) - Simplify the LimEx NFA with a unified "variable shift" model, which reduces the number of different NFA code paths to one per model size. - Allow some anchored prefixes that may squash the literal to which they are attached to run eagerly. This improves scanning performance for some patterns. - Simplify and improve EOD ("end of data") matching, using the interpreter for all operations. - Elide unnecessary instructions in the Rose interpreter at compile time. - Reduce the number of inlined instantiations of the Rose interpreter in order to reduce instruction cache pressure. - Small improvements to literal matcher acceleration. - Parser: ignore `\E` metacharacters that are not preceded by `\Q`. This conforms to PCRE's behaviour, rather than returning a compile error. - Check for misaligned memory when allocating an error structure in Hyperscan's compile path and return an appropriate error if detected. ## [4.2.0] 2016-05-31 - Introduce an interpreter for many complex actions to replace the use of internal reports within the core of Hyperscan (the "Rose" engine). This improves scanning performance and reduces database size for many pattern sets. - Many enhancements to the acceleration framework used by NFA and DFA engines, including more flexible multibyte implementations and more AVX2 support. This improves scanning performance for many pattern sets. - Improved prefiltering support for complex patterns containing very large bounded repeats (`R{M,N}` with large `N`). - Improve scanning performance of pattern sets with a very large number of EOD-anchored patterns. - Improve scanning performance of large pattern sets that use the `HS_FLAG_SINGLEMATCH` flag. - Improve scanning performance of pattern sets that contain a single literal by improving the "Noodle" literal matcher. - Small reductions in total stream state for many pattern sets. - Improve runtime detection of AVX2 support. - Disable -Werror for release builds, in order to behave better for packagers and users with different compiler combinations than those that we test. - Improve support for building on Windows with MSVC 2015 (github issue #14). Support for Hyperscan on Windows is still experimental. - Small updates to fix warnings identified by Coverity. - Remove Python codegen for the "FDR" and "Teddy" literal matchers. These are now implemented directly in C code. - Remove the specialist "Sidecar" engine in favour of using our more general repeat engines. - New API function: add the `hs_expression_ext_info()` function. This is a variant of `hs_expression_info()` that can accept patterns with extended parameters. - New API error value: add the `HS_SCRATCH_IN_USE` error, which is returned when Hyperscan detects that a scratch region is already in use on entry to an API function. ## [4.1.0] 2015-12-18 - Update version of PCRE used by testing tools as a syntax and semantic reference to PCRE 8.38. - Small updates to fix warnings identified by Coverity. - Clean up and unify exception handling behaviour across GPR and SIMD NFA models. - Fix bug in handling of bounded repeat triggers with large gaps between them for sparse repeat model. - Correctly reject POSIX collating elements (`[.ch.]`, `[=ch=]`) in the parser. These are not supported by Hyperscan. - Add support for quoted sequences (`\Q...\E`) inside character classes. - Simplify FDR literal matcher runtime by removing some static specialization. - Fix handling of the POSIX `[:graph:]`, `[:print:]` and `[:punct:]` character classes to match the behaviour of PCRE 8.38 in both standard operation and with the UCP flag set. (Note: some bugs were fixed in this area in PCRE 8.38.) Previously Hyperscan's behaviour was the same as versions of PCRE before 8.34. - Improve performance when compiling pattern sets that include a large number of similar bounded repeat constructs. (github issue #9) ## [4.0.1] 2015-10-30 - Minor cleanups to test code. - CMake and other build system improvements. - API update: allow `hs_reset_stream()` and `hs_reset_and_copy_stream()` to be supplied with a NULL scratch pointer if no matches are required. This is in line with the behaviour of `hs_close_stream()`. - Disallow bounded repeats with a very large minimum repeat but no maximum, i.e. {N,} for very large N. - Reduce compile memory usage in literal set explansion for some large cases. ## [4.0.0] 2015-10-20 - Original release of Hyperscan as open-source software. hyperscan-4.7.0/CMakeLists.txt000066400000000000000000001256761323202717100162750ustar00rootroot00000000000000cmake_minimum_required (VERSION 2.8.11) project (hyperscan C CXX) set (HS_MAJOR_VERSION 4) set (HS_MINOR_VERSION 7) set (HS_PATCH_VERSION 0) set (HS_VERSION ${HS_MAJOR_VERSION}.${HS_MINOR_VERSION}.${HS_PATCH_VERSION}) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) include(CheckCXXSymbolExists) INCLUDE (CheckFunctionExists) INCLUDE (CheckIncludeFiles) INCLUDE (CheckIncludeFileCXX) INCLUDE (CheckLibraryExists) INCLUDE (CheckSymbolExists) include (CMakeDependentOption) include (GNUInstallDirs) include (${CMAKE_MODULE_PATH}/platform.cmake) include (${CMAKE_MODULE_PATH}/ragel.cmake) find_package(PkgConfig QUIET) if (NOT CMAKE_BUILD_TYPE) message(STATUS "Default build type 'Release with debug info'") set(CMAKE_BUILD_TYPE RELWITHDEBINFO CACHE STRING "" FORCE ) else() string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE) message(STATUS "Build type ${CMAKE_BUILD_TYPE}") endif() if(CMAKE_BUILD_TYPE MATCHES RELEASE|RELWITHDEBINFO|MINSIZEREL) set(RELEASE_BUILD TRUE) else() set(RELEASE_BUILD FALSE) endif() set(BINDIR "${PROJECT_BINARY_DIR}/bin") set(LIBDIR "${PROJECT_BINARY_DIR}/lib") set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) # First for the generic no-config case set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BINDIR}") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${LIBDIR}") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${LIBDIR}") # Second, for multi-config builds (e.g. msvc) foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) string (TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${BINDIR}") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${LIBDIR}") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${LIBDIR}") endforeach (OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES) if(CMAKE_GENERATOR STREQUAL Xcode) set(XCODE TRUE) endif() # older versions of cmake don't know things support isystem if (XCODE OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem") endif () set(CMAKE_INCLUDE_CURRENT_DIR 1) include_directories(${PROJECT_SOURCE_DIR}/src) include_directories(${PROJECT_BINARY_DIR}) include_directories(SYSTEM include) include (${CMAKE_MODULE_PATH}/boost.cmake) # -- make this work? set(python_ADDITIONAL_VERSIONS 2.7 2.6) find_package(PythonInterp) find_program(RAGEL ragel) if(PYTHONINTERP_FOUND) set(PYTHON ${PYTHON_EXECUTABLE}) else() message(FATAL_ERROR "No python interpreter found") endif() # allow for reproducible builds - python for portability if (DEFINED ENV{SOURCE_DATE_EPOCH}) execute_process( COMMAND "${PYTHON}" "${CMAKE_MODULE_PATH}/formatdate.py" "$ENV{SOURCE_DATE_EPOCH}" OUTPUT_VARIABLE BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) else () string (TIMESTAMP BUILD_DATE "%Y-%m-%d") endif () message(STATUS "Build date: ${BUILD_DATE}") if(${RAGEL} STREQUAL "RAGEL-NOTFOUND") message(FATAL_ERROR "Ragel state machine compiler not found") endif() option(OPTIMISE "Turns off compiler optimizations (on by default unless debug output enabled or coverage testing)" TRUE) option(DEBUG_OUTPUT "Enable debug output (warning: very verbose)" FALSE) if(DEBUG_OUTPUT) add_definitions(-DDEBUG) set(OPTIMISE FALSE) endif(DEBUG_OUTPUT) option(BUILD_SHARED_LIBS "Build shared libs instead of static" OFF) option(BUILD_STATIC_AND_SHARED "Build shared libs as well as static" OFF) if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS) if (WIN32) message(FATAL_ERROR "Windows DLLs currently not supported") else() message(STATUS "Building shared libraries") endif() endif() if (NOT BUILD_SHARED_LIBS) # build static libs set(BUILD_STATIC_LIBS ON) mark_as_advanced(BUILD_STATIC_LIBS) endif () #for config if (OPTIMISE) set(HS_OPTIMIZE ON) endif() CMAKE_DEPENDENT_OPTION(DUMP_SUPPORT "Dump code support; normally on, except in release builds" ON "NOT RELEASE_BUILD" OFF) CMAKE_DEPENDENT_OPTION(DISABLE_ASSERTS "Disable assert(); Asserts are enabled in debug builds, disabled in release builds" OFF "NOT RELEASE_BUILD" ON) option(BUILD_AVX512 "Experimental: support avx512 in the fat runtime" OFF) option(WINDOWS_ICC "Use Intel C++ Compiler on Windows, default off, requires ICC to be set in project" OFF) # TODO: per platform config files? # TODO: windows generator on cmake always uses msvc, even if we plan to build with icc if(MSVC OR MSVC_IDE) message(STATUS "Building for Windows") if (MSVC_VERSION LESS 1700) message(FATAL_ERROR "The project requires C++11 features.") else() if (WINDOWS_ICC) set(ARCH_C_FLAGS "/QxHost") set(ARCH_CXX_FLAGS "/QxHost") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /O3 /Qstd=c99 /Qrestrict /wd4267 /Qdiag-disable:remark") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /Qstd=c++11 /Qrestrict /QxHost /wd4267 /wd4800 /Qdiag-disable:remark -DBOOST_DETAIL_NO_CONTAINER_FWD -D_SCL_SECURE_NO_WARNINGS") else() # todo: change these as required set(ARCH_C_FLAGS "/arch:AVX2") set(ARCH_CXX_FLAGS "/arch:AVX2") set(MSVC_WARNS "/wd4101 /wd4146 /wd4172 /wd4200 /wd4244 /wd4267 /wd4307 /wd4334 /wd4805 -D_CRT_SECURE_NO_WARNINGS") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /O2 ${MSVC_WARNS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 ${MSVC_WARNS} /wd4800 -DBOOST_DETAIL_NO_CONTAINER_FWD") endif() string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") string(REPLACE "/RTC1" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") if (DISABLE_ASSERTS) set(CMAKE_C_FLAGS_DEBUG "/DNDEBUG ${CMAKE_C_FLAGS_DEBUG}") set(CMAKE_CXX_FLAGS_DEBUG "/DNDEBUG ${CMAKE_CXX_FLAGS_DEBUG}") endif () # flags only used to build hs libs set(HS_C_FLAGS "/Gv") set(HS_CXX_FLAGS "/Gv") endif() else() # remove CMake's idea of optimisation foreach (CONFIG ${CMAKE_BUILD_TYPE} ${CMAKE_CONFIGURATION_TYPES}) string(REGEX REPLACE "-O[^ ]*" "" CMAKE_C_FLAGS_${CONFIG} "${CMAKE_C_FLAGS_${CONFIG}}") string(REGEX REPLACE "-O[^ ]*" "" CMAKE_CXX_FLAGS_${CONFIG} "${CMAKE_CXX_FLAGS_${CONFIG}}") endforeach () if (CMAKE_COMPILER_IS_GNUCC) message(STATUS "gcc version ${CMAKE_C_COMPILER_VERSION}") # If gcc doesn't recognise the host cpu, then mtune=native becomes # generic, which isn't very good in some cases. march=native looks at # cpuid info and then chooses the best microarch it can (and replaces # the flag), so use that for tune. # arg1 might exist if using ccache string (STRIP "${CMAKE_C_COMPILER_ARG1}" CC_ARG1) set (EXEC_ARGS ${CC_ARG1} -c -Q --help=target -march=native -mtune=native) execute_process(COMMAND ${CMAKE_C_COMPILER} ${EXEC_ARGS} OUTPUT_VARIABLE _GCC_OUTPUT) string(REGEX REPLACE ".*march=[ \t]*([^ \n]*)[ \n].*" "\\1" GNUCC_ARCH "${_GCC_OUTPUT}") # test the parsed flag set (EXEC_ARGS ${CC_ARG1} -E - -mtune=${GNUCC_ARCH}) execute_process(COMMAND ${CMAKE_C_COMPILER} ${EXEC_ARGS} OUTPUT_QUIET ERROR_QUIET INPUT_FILE /dev/null RESULT_VARIABLE GNUCC_TUNE_TEST) if (NOT GNUCC_TUNE_TEST EQUAL 0) message(SEND_ERROR "Something went wrong determining gcc tune: -mtune=${GNUCC_ARCH} not valid") endif() set(TUNE_FLAG ${GNUCC_ARCH}) else () set(TUNE_FLAG native) endif() # compiler version checks TODO: test more compilers if (CMAKE_COMPILER_IS_GNUCXX) set(GNUCXX_MINVER "4.8.1") message(STATUS "g++ version ${CMAKE_CXX_COMPILER_VERSION}") if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS GNUCXX_MINVER) message(FATAL_ERROR "A minimum of g++ ${GNUCXX_MINVER} is required for C++11 support") endif() endif() if(OPTIMISE) if (NOT CMAKE_BUILD_TYPE MATCHES MINSIZEREL) set(OPT_C_FLAG "-O3") set(OPT_CXX_FLAG "-O2") else () set(OPT_C_FLAG "-Os") set(OPT_CXX_FLAG "-Os") endif () else() set(OPT_C_FLAG "-O0") set(OPT_CXX_FLAG "-O0") endif(OPTIMISE) # set compiler flags - more are tested and added later set(EXTRA_C_FLAGS "${OPT_C_FLAG} -std=c99 -Wall -Wextra -Wshadow -Wcast-qual -fno-strict-aliasing") set(EXTRA_CXX_FLAGS "${OPT_CXX_FLAG} -std=c++11 -Wall -Wextra -Wshadow -Wswitch -Wreturn-type -Wcast-qual -Wno-deprecated -Wnon-virtual-dtor -fno-strict-aliasing") if (NOT RELEASE_BUILD) # -Werror is most useful during development, don't potentially break # release builds set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Werror") set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Werror") endif() if (DISABLE_ASSERTS) set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -DNDEBUG") set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -DNDEBUG") endif() if (NOT CMAKE_C_FLAGS MATCHES .*march.* AND NOT CMAKE_C_FLAGS MATCHES .*mtune.*) set(ARCH_C_FLAGS "-march=native -mtune=${TUNE_FLAG}") endif() if (NOT CMAKE_CXX_FLAGS MATCHES .*march.* AND NOT CMAKE_CXX_FLAGS MATCHES .*mtune.*) set(ARCH_CXX_FLAGS "-march=native -mtune=${TUNE_FLAG}") endif() if(CMAKE_COMPILER_IS_GNUCC) # spurious warnings? set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-array-bounds -Wno-maybe-uninitialized") endif() if(CMAKE_COMPILER_IS_GNUCXX) set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Wno-maybe-uninitialized") if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -fabi-version=0") endif () # don't complain about abi set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-abi") set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Wno-abi") endif() if (NOT(ARCH_IA32 AND RELEASE_BUILD)) set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -fno-omit-frame-pointer") set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -fno-omit-frame-pointer") endif() if (CMAKE_C_COMPILER_ID MATCHES "Intel") set(SKYLAKE_FLAG "-xCORE-AVX512") else () set(SKYLAKE_FLAG "-march=skylake-avx512") endif () endif() CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H) CHECK_INCLUDE_FILES(intrin.h HAVE_C_INTRIN_H) CHECK_INCLUDE_FILE_CXX(intrin.h HAVE_CXX_INTRIN_H) CHECK_INCLUDE_FILES(x86intrin.h HAVE_C_X86INTRIN_H) CHECK_INCLUDE_FILE_CXX(x86intrin.h HAVE_CXX_X86INTRIN_H) CHECK_FUNCTION_EXISTS(posix_memalign HAVE_POSIX_MEMALIGN) CHECK_FUNCTION_EXISTS(_aligned_malloc HAVE__ALIGNED_MALLOC) # these end up in the config file CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAS_C_HIDDEN) CHECK_CXX_COMPILER_FLAG(-fvisibility=hidden HAS_CXX_HIDDEN) # are we using libc++ CHECK_CXX_SYMBOL_EXISTS(_LIBCPP_VERSION ciso646 HAVE_LIBCPP) if (RELEASE_BUILD) if (HAS_C_HIDDEN) set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -fvisibility=hidden") endif() if (HAS_CXX_HIDDEN) set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -fvisibility=hidden") endif() endif() if (CMAKE_SYSTEM_NAME MATCHES "Linux") # This is a Linux-only feature for now - requires platform support # elsewhere message(STATUS "generator is ${CMAKE_GENERATOR}") if (CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "3.9") message (STATUS "Clang v3.9 or higher required for fat runtime, cannot build fat runtime") set (FAT_RUNTIME_REQUISITES FALSE) elseif (NOT (CMAKE_GENERATOR MATCHES "Unix Makefiles" OR (CMAKE_VERSION VERSION_GREATER "3.0" AND CMAKE_GENERATOR MATCHES "Ninja"))) message (STATUS "Building the fat runtime requires the Unix Makefiles generator, or Ninja with CMake v3.0 or higher") set (FAT_RUNTIME_REQUISITES FALSE) else() include (${CMAKE_MODULE_PATH}/attrib.cmake) if (NOT HAS_C_ATTR_IFUNC) message(STATUS "Compiler does not support ifunc attribute, cannot build fat runtime") set (FAT_RUNTIME_REQUISITES FALSE) else () set (FAT_RUNTIME_REQUISITES TRUE) endif() endif() CMAKE_DEPENDENT_OPTION(FAT_RUNTIME "Build a library that supports multiple microarchitecures" ${RELEASE_BUILD} "FAT_RUNTIME_REQUISITES" OFF) endif () include (${CMAKE_MODULE_PATH}/arch.cmake) # testing a builtin takes a little more work CHECK_C_SOURCE_COMPILES("void *aa_test(void *x) { return __builtin_assume_aligned(x, 16);}\nint main(void) { return 0; }" HAVE_CC_BUILTIN_ASSUME_ALIGNED) CHECK_CXX_SOURCE_COMPILES("void *aa_test(void *x) { return __builtin_assume_aligned(x, 16);}\nint main(void) { return 0; }" HAVE_CXX_BUILTIN_ASSUME_ALIGNED) CHECK_C_SOURCE_COMPILES("int main(void) { __builtin_constant_p(0); }" HAVE__BUILTIN_CONSTANT_P) if (NOT WIN32) set(C_FLAGS_TO_CHECK # Variable length arrays are way bad, most especially at run time "-Wvla" # Pointer arith on void pointers is doing it wong. "-Wpointer-arith" # Build our C code with -Wstrict-prototypes -Wmissing-prototypes "-Wstrict-prototypes" "-Wmissing-prototypes" ) foreach (FLAG ${C_FLAGS_TO_CHECK}) # munge the name so it doesn't break things string(REPLACE "-" "_" FNAME C_FLAG${FLAG}) CHECK_C_COMPILER_FLAG("${FLAG}" ${FNAME}) if (${FNAME}) set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} ${FLAG}") endif() endforeach() set(CXX_FLAGS_TO_CHECK "-Wvla" "-Wpointer-arith" ) foreach (FLAG ${CXX_FLAGS_TO_CHECK}) string(REPLACE "-" "_" FNAME CXX_FLAG${FLAG}) CHECK_CXX_COMPILER_FLAG("${FLAG}" ${FNAME}) if (${FNAME}) set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} ${FLAG}") endif() endforeach() # self-assign should be thrown away, but clang whinges CHECK_C_COMPILER_FLAG("-Wself-assign" CC_SELF_ASSIGN) if (CC_SELF_ASSIGN) set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-self-assign") endif() CHECK_CXX_COMPILER_FLAG("-Wself-assign" CXX_SELF_ASSIGN) if (CXX_SELF_ASSIGN) set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Wno-self-assign") endif() # clang gets up in our face for going paren crazy with macros CHECK_C_COMPILER_FLAG("-Wparentheses-equality" CC_PAREN_EQUALITY) if (CC_PAREN_EQUALITY) set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-parentheses-equality") endif() # clang compains about unused const vars in our Ragel-generated code. CHECK_CXX_COMPILER_FLAG("-Wunused-const-variable" CXX_UNUSED_CONST_VAR) if (CXX_UNUSED_CONST_VAR) set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Wno-unused-const-variable") endif() # gcc 6 complains about type attributes that get ignored, like alignment CHECK_CXX_COMPILER_FLAG("-Wignored-attributes" CXX_IGNORED_ATTR) if (CXX_IGNORED_ATTR) set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Wno-ignored-attributes") endif() # note this for later # g++ doesn't have this flag but clang does CHECK_CXX_COMPILER_FLAG("-Wweak-vtables" CXX_WEAK_VTABLES) if (CXX_WEAK_VTABLES) set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Wweak-vtables") endif() CHECK_CXX_COMPILER_FLAG("-Wmissing-declarations" CXX_MISSING_DECLARATIONS) if (CXX_MISSING_DECLARATIONS) set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Wmissing-declarations") endif() CHECK_CXX_COMPILER_FLAG("-Wunused-local-typedefs" CXX_UNUSED_LOCAL_TYPEDEFS) # gcc5 complains about this CHECK_CXX_COMPILER_FLAG("-Wunused-variable" CXX_WUNUSED_VARIABLE) endif() include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) if(CMAKE_SYSTEM_NAME MATCHES "Linux") set(LINUX TRUE) endif(CMAKE_SYSTEM_NAME MATCHES "Linux") if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") set(FREEBSD true) endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") if(NOT WIN32) if(CMAKE_C_COMPILER_ID MATCHES "Intel") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -diag-error 10006 -diag-disable 68 -diag-disable 177 -diag-disable 186 -diag-disable 2304 -diag-disable 2305 -diag-disable 2338 -diag-disable 1418 -diag-disable 279 -diag-disable=remark") endif() if(CMAKE_CXX_COMPILER_ID MATCHES "Intel") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -diag-error 10006 -diag-disable 68 -diag-disable 177 -diag-disable 186 -diag-disable 2304 -diag-disable 2305 -diag-disable 2338 -diag-disable 1418 -diag-disable 1170 -diag-disable 3373 -diag-disable 279 -diag-disable=remark") endif() endif() if (NOT FAT_RUNTIME) message(STATUS "Building for current host CPU: ${ARCH_C_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARCH_C_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_CXX_FLAGS}") else() message(STATUS "Building runtime for multiple microarchitectures") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") endif() add_subdirectory(util) add_subdirectory(unit) add_subdirectory(doc/dev-reference) if (EXISTS ${CMAKE_SOURCE_DIR}/tools/CMakeLists.txt) add_subdirectory(tools) endif() # do substitutions configure_file(${CMAKE_MODULE_PATH}/config.h.in ${PROJECT_BINARY_DIR}/config.h) configure_file(src/hs_version.h.in ${PROJECT_BINARY_DIR}/hs_version.h) if (NOT WIN32) # expand out library names for pkgconfig static link info foreach (LIB ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}) # this is fragile, but protects us from toolchain specific files if (NOT EXISTS ${LIB}) set(PRIVATE_LIBS "${PRIVATE_LIBS} -l${LIB}") endif() endforeach() configure_file(libhs.pc.in libhs.pc @ONLY) # only replace @ quoted vars install(FILES ${CMAKE_BINARY_DIR}/libhs.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") endif() # only set these after all tests are done if (NOT FAT_RUNTIME) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS} ${HS_C_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS} ${HS_CXX_FLAGS}") else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS}") endif() if(NOT WIN32) set(RAGEL_C_FLAGS "-Wno-unused") endif() set_source_files_properties( ${CMAKE_BINARY_DIR}/src/parser/Parser.cpp PROPERTIES COMPILE_FLAGS "${RAGEL_C_FLAGS}") ragelmaker(src/parser/Parser.rl) set_source_files_properties( ${CMAKE_BINARY_DIR}/src/parser/control_verbs.cpp PROPERTIES COMPILE_FLAGS "${RAGEL_C_FLAGS}") ragelmaker(src/parser/control_verbs.rl) SET(hs_HEADERS src/hs.h src/hs_common.h src/hs_compile.h src/hs_runtime.h ) install(FILES ${hs_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/hs") set (hs_exec_common_SRCS src/alloc.c src/scratch.c src/util/cpuid_flags.c src/util/cpuid_flags.h src/util/multibit.c ) set (hs_exec_SRCS ${hs_HEADERS} src/hs_version.h src/ue2common.h src/allocator.h src/crc32.c src/crc32.h src/report.h src/runtime.c src/stream_compress.c src/stream_compress.h src/stream_compress_impl.h src/fdr/fdr.c src/fdr/fdr.h src/fdr/fdr_internal.h src/fdr/fdr_confirm.h src/fdr/fdr_confirm_runtime.h src/fdr/flood_runtime.h src/fdr/fdr_loadval.h src/fdr/teddy.c src/fdr/teddy.h src/fdr/teddy_internal.h src/fdr/teddy_runtime_common.h src/hwlm/hwlm.c src/hwlm/hwlm.h src/hwlm/hwlm_internal.h src/hwlm/noodle_engine.c src/hwlm/noodle_engine.h src/hwlm/noodle_internal.h src/nfa/accel.c src/nfa/accel.h src/nfa/castle.c src/nfa/castle.h src/nfa/castle_internal.h src/nfa/gough.c src/nfa/gough_internal.h src/nfa/lbr.c src/nfa/lbr.h src/nfa/lbr_common_impl.h src/nfa/lbr_internal.h src/nfa/limex_accel.c src/nfa/limex_accel.h src/nfa/limex_exceptional.h src/nfa/limex_native.c src/nfa/limex_ring.h src/nfa/limex_64.c src/nfa/limex_simd128.c src/nfa/limex_simd256.c src/nfa/limex_simd384.c src/nfa/limex_simd512.c src/nfa/limex.h src/nfa/limex_common_impl.h src/nfa/limex_context.h src/nfa/limex_internal.h src/nfa/limex_runtime.h src/nfa/limex_runtime_impl.h src/nfa/limex_shuffle.h src/nfa/limex_state_impl.h src/nfa/mcclellan.c src/nfa/mcclellan.h src/nfa/mcclellan_common_impl.h src/nfa/mcclellan_internal.h src/nfa/mcsheng.c src/nfa/mcsheng_data.c src/nfa/mcsheng.h src/nfa/mcsheng_internal.h src/nfa/mpv.h src/nfa/mpv.c src/nfa/mpv_internal.h src/nfa/nfa_api.h src/nfa/nfa_api_dispatch.c src/nfa/nfa_internal.h src/nfa/nfa_rev_api.h src/nfa/repeat.c src/nfa/repeat.h src/nfa/repeat_internal.h src/nfa/sheng.c src/nfa/sheng.h src/nfa/sheng_defs.h src/nfa/sheng_impl.h src/nfa/sheng_impl4.h src/nfa/sheng_internal.h src/nfa/shufti.c src/nfa/shufti.h src/nfa/tamarama.c src/nfa/tamarama.h src/nfa/tamarama_internal.h src/nfa/truffle.c src/nfa/truffle.h src/nfa/vermicelli.h src/nfa/vermicelli_run.h src/nfa/vermicelli_sse.h src/som/som.h src/som/som_operation.h src/som/som_runtime.h src/som/som_runtime.c src/som/som_stream.c src/som/som_stream.h src/rose/block.c src/rose/catchup.h src/rose/catchup.c src/rose/infix.h src/rose/init.h src/rose/init.c src/rose/stream.c src/rose/stream_long_lit.h src/rose/stream_long_lit_hash.h src/rose/match.h src/rose/match.c src/rose/miracle.h src/rose/program_runtime.c src/rose/program_runtime.h src/rose/runtime.h src/rose/rose.h src/rose/rose_internal.h src/rose/rose_program.h src/rose/rose_types.h src/rose/rose_common.h src/rose/validate_mask.h src/rose/validate_shufti.h src/util/bitutils.h src/util/copybytes.h src/util/exhaust.h src/util/fatbit.h src/util/join.h src/util/masked_move.h src/util/multibit.h src/util/multibit.c src/util/multibit_compress.h src/util/multibit_internal.h src/util/pack_bits.h src/util/popcount.h src/util/pqueue.h src/util/scatter.h src/util/scatter_runtime.h src/util/simd_utils.h src/util/simd_utils.c src/util/state_compress.h src/util/state_compress.c src/util/unaligned.h src/util/uniform_ops.h src/database.c src/database.h ) set (hs_exec_avx2_SRCS src/fdr/teddy_avx2.c src/util/masked_move.c ) SET (hs_compile_SRCS ${hs_HEADERS} src/crc32.h src/database.h src/grey.cpp src/grey.h src/hs.cpp src/hs_internal.h src/hs_version.h src/scratch.h src/state.h src/ue2common.h src/compiler/asserts.cpp src/compiler/asserts.h src/compiler/compiler.cpp src/compiler/compiler.h src/compiler/error.cpp src/compiler/error.h src/compiler/expression_info.h src/fdr/engine_description.cpp src/fdr/engine_description.h src/fdr/fdr_compile.cpp src/fdr/fdr_compile.h src/fdr/fdr_compile_internal.h src/fdr/fdr_compile_util.cpp src/fdr/fdr_confirm_compile.cpp src/fdr/fdr_confirm.h src/fdr/fdr_engine_description.cpp src/fdr/fdr_engine_description.h src/fdr/fdr_internal.h src/fdr/flood_compile.cpp src/fdr/teddy_compile.cpp src/fdr/teddy_compile.h src/fdr/teddy_engine_description.cpp src/fdr/teddy_engine_description.h src/fdr/teddy_internal.h src/hwlm/hwlm_build.cpp src/hwlm/hwlm_build.h src/hwlm/hwlm_internal.h src/hwlm/hwlm_literal.cpp src/hwlm/hwlm_literal.h src/hwlm/noodle_build.cpp src/hwlm/noodle_build.h src/hwlm/noodle_internal.h src/nfa/accel.h src/nfa/accel_dfa_build_strat.cpp src/nfa/accel_dfa_build_strat.h src/nfa/accelcompile.cpp src/nfa/accelcompile.h src/nfa/callback.h src/nfa/castlecompile.cpp src/nfa/castlecompile.h src/nfa/dfa_build_strat.cpp src/nfa/dfa_build_strat.h src/nfa/dfa_min.cpp src/nfa/dfa_min.h src/nfa/goughcompile.cpp src/nfa/goughcompile.h src/nfa/goughcompile_accel.cpp src/nfa/goughcompile_internal.h src/nfa/goughcompile_reg.cpp src/nfa/mcclellan.h src/nfa/mcclellan_internal.h src/nfa/mcclellancompile.cpp src/nfa/mcclellancompile.h src/nfa/mcclellancompile_util.cpp src/nfa/mcclellancompile_util.h src/nfa/mcsheng_compile.cpp src/nfa/mcsheng_compile.h src/nfa/limex_compile.cpp src/nfa/limex_compile.h src/nfa/limex_accel.h src/nfa/limex_internal.h src/nfa/mpv_internal.h src/nfa/mpvcompile.cpp src/nfa/mpvcompile.h src/nfa/nfa_api.h src/nfa/nfa_api_queue.h src/nfa/nfa_api_util.h src/nfa/nfa_build_util.cpp src/nfa/nfa_build_util.h src/nfa/nfa_internal.h src/nfa/nfa_kind.h src/nfa/rdfa.cpp src/nfa/rdfa.h src/nfa/rdfa_graph.cpp src/nfa/rdfa_graph.h src/nfa/rdfa_merge.cpp src/nfa/rdfa_merge.h src/nfa/repeat_internal.h src/nfa/repeatcompile.cpp src/nfa/repeatcompile.h src/nfa/sheng_internal.h src/nfa/shengcompile.cpp src/nfa/shengcompile.h src/nfa/shufticompile.cpp src/nfa/shufticompile.h src/nfa/tamaramacompile.cpp src/nfa/tamaramacompile.h src/nfa/trufflecompile.cpp src/nfa/trufflecompile.h src/nfagraph/ng.cpp src/nfagraph/ng.h src/nfagraph/ng_anchored_acyclic.cpp src/nfagraph/ng_anchored_acyclic.h src/nfagraph/ng_anchored_dots.cpp src/nfagraph/ng_anchored_dots.h src/nfagraph/ng_asserts.cpp src/nfagraph/ng_asserts.h src/nfagraph/ng_builder.cpp src/nfagraph/ng_builder.h src/nfagraph/ng_calc_components.cpp src/nfagraph/ng_calc_components.h src/nfagraph/ng_cyclic_redundancy.cpp src/nfagraph/ng_cyclic_redundancy.h src/nfagraph/ng_depth.cpp src/nfagraph/ng_depth.h src/nfagraph/ng_dominators.cpp src/nfagraph/ng_dominators.h src/nfagraph/ng_edge_redundancy.cpp src/nfagraph/ng_edge_redundancy.h src/nfagraph/ng_equivalence.cpp src/nfagraph/ng_equivalence.h src/nfagraph/ng_execute.cpp src/nfagraph/ng_execute.h src/nfagraph/ng_expr_info.cpp src/nfagraph/ng_expr_info.h src/nfagraph/ng_extparam.cpp src/nfagraph/ng_extparam.h src/nfagraph/ng_fixed_width.cpp src/nfagraph/ng_fixed_width.h src/nfagraph/ng_fuzzy.cpp src/nfagraph/ng_fuzzy.h src/nfagraph/ng_haig.cpp src/nfagraph/ng_haig.h src/nfagraph/ng_holder.cpp src/nfagraph/ng_holder.h src/nfagraph/ng_is_equal.cpp src/nfagraph/ng_is_equal.h src/nfagraph/ng_lbr.cpp src/nfagraph/ng_lbr.h src/nfagraph/ng_literal_analysis.cpp src/nfagraph/ng_literal_analysis.h src/nfagraph/ng_literal_component.cpp src/nfagraph/ng_literal_component.h src/nfagraph/ng_literal_decorated.cpp src/nfagraph/ng_literal_decorated.h src/nfagraph/ng_mcclellan.cpp src/nfagraph/ng_mcclellan.h src/nfagraph/ng_mcclellan_internal.h src/nfagraph/ng_limex.cpp src/nfagraph/ng_limex.h src/nfagraph/ng_limex_accel.cpp src/nfagraph/ng_limex_accel.h src/nfagraph/ng_misc_opt.cpp src/nfagraph/ng_misc_opt.h src/nfagraph/ng_netflow.cpp src/nfagraph/ng_netflow.h src/nfagraph/ng_prefilter.cpp src/nfagraph/ng_prefilter.h src/nfagraph/ng_prune.cpp src/nfagraph/ng_prune.h src/nfagraph/ng_puff.cpp src/nfagraph/ng_puff.h src/nfagraph/ng_redundancy.cpp src/nfagraph/ng_redundancy.h src/nfagraph/ng_region.cpp src/nfagraph/ng_region.h src/nfagraph/ng_region_redundancy.cpp src/nfagraph/ng_region_redundancy.h src/nfagraph/ng_repeat.cpp src/nfagraph/ng_repeat.h src/nfagraph/ng_reports.cpp src/nfagraph/ng_reports.h src/nfagraph/ng_restructuring.cpp src/nfagraph/ng_restructuring.h src/nfagraph/ng_revacc.cpp src/nfagraph/ng_revacc.h src/nfagraph/ng_sep.cpp src/nfagraph/ng_sep.h src/nfagraph/ng_small_literal_set.cpp src/nfagraph/ng_small_literal_set.h src/nfagraph/ng_som.cpp src/nfagraph/ng_som.h src/nfagraph/ng_som_add_redundancy.cpp src/nfagraph/ng_som_add_redundancy.h src/nfagraph/ng_som_util.cpp src/nfagraph/ng_som_util.h src/nfagraph/ng_split.cpp src/nfagraph/ng_split.h src/nfagraph/ng_squash.cpp src/nfagraph/ng_squash.h src/nfagraph/ng_stop.cpp src/nfagraph/ng_stop.h src/nfagraph/ng_uncalc_components.cpp src/nfagraph/ng_uncalc_components.h src/nfagraph/ng_undirected.h src/nfagraph/ng_utf8.cpp src/nfagraph/ng_utf8.h src/nfagraph/ng_util.cpp src/nfagraph/ng_util.h src/nfagraph/ng_vacuous.cpp src/nfagraph/ng_vacuous.h src/nfagraph/ng_violet.cpp src/nfagraph/ng_violet.h src/nfagraph/ng_width.cpp src/nfagraph/ng_width.h src/parser/AsciiComponentClass.cpp src/parser/AsciiComponentClass.h src/parser/Component.cpp src/parser/Component.h src/parser/ComponentAlternation.cpp src/parser/ComponentAlternation.h src/parser/ComponentAssertion.cpp src/parser/ComponentAssertion.h src/parser/ComponentAtomicGroup.cpp src/parser/ComponentAtomicGroup.h src/parser/ComponentBackReference.cpp src/parser/ComponentBackReference.h src/parser/ComponentBoundary.cpp src/parser/ComponentBoundary.h src/parser/ComponentByte.cpp src/parser/ComponentByte.h src/parser/ComponentClass.cpp src/parser/ComponentClass.h src/parser/ComponentCondReference.cpp src/parser/ComponentCondReference.h src/parser/ComponentEUS.cpp src/parser/ComponentEUS.h src/parser/ComponentEmpty.cpp src/parser/ComponentEmpty.h src/parser/ComponentRepeat.cpp src/parser/ComponentRepeat.h src/parser/ComponentSequence.cpp src/parser/ComponentSequence.h src/parser/ComponentVisitor.cpp src/parser/ComponentVisitor.h src/parser/ComponentWordBoundary.cpp src/parser/ComponentWordBoundary.h src/parser/ConstComponentVisitor.cpp src/parser/ConstComponentVisitor.h src/parser/Parser.cpp src/parser/Parser.h src/parser/Utf8ComponentClass.cpp src/parser/Utf8ComponentClass.h src/parser/buildstate.cpp src/parser/buildstate.h src/parser/check_refs.cpp src/parser/check_refs.h src/parser/control_verbs.cpp src/parser/control_verbs.h src/parser/parse_error.cpp src/parser/parse_error.h src/parser/parser_util.cpp src/parser/position.h src/parser/position_info.h src/parser/prefilter.cpp src/parser/prefilter.h src/parser/shortcut_literal.cpp src/parser/shortcut_literal.h src/parser/ucp_table.cpp src/parser/ucp_table.h src/parser/unsupported.cpp src/parser/unsupported.h src/parser/utf8_validate.h src/parser/utf8_validate.cpp src/smallwrite/smallwrite_build.cpp src/smallwrite/smallwrite_build.h src/smallwrite/smallwrite_internal.h src/som/slot_manager.cpp src/som/slot_manager.h src/som/slot_manager_internal.h src/som/som.h src/som/som_operation.h src/rose/rose_build.h src/rose/rose_build_add.cpp src/rose/rose_build_add_internal.h src/rose/rose_build_add_mask.cpp src/rose/rose_build_anchored.cpp src/rose/rose_build_anchored.h src/rose/rose_build_bytecode.cpp src/rose/rose_build_castle.h src/rose/rose_build_castle.cpp src/rose/rose_build_compile.cpp src/rose/rose_build_convert.cpp src/rose/rose_build_convert.h src/rose/rose_build_dedupe.cpp src/rose/rose_build_engine_blob.cpp src/rose/rose_build_engine_blob.h src/rose/rose_build_exclusive.cpp src/rose/rose_build_exclusive.h src/rose/rose_build_groups.cpp src/rose/rose_build_groups.h src/rose/rose_build_impl.h src/rose/rose_build_infix.cpp src/rose/rose_build_infix.h src/rose/rose_build_instructions.cpp src/rose/rose_build_instructions.h src/rose/rose_build_lit_accel.cpp src/rose/rose_build_lit_accel.h src/rose/rose_build_long_lit.cpp src/rose/rose_build_long_lit.h src/rose/rose_build_lookaround.cpp src/rose/rose_build_lookaround.h src/rose/rose_build_matchers.cpp src/rose/rose_build_matchers.h src/rose/rose_build_merge.cpp src/rose/rose_build_merge.h src/rose/rose_build_misc.cpp src/rose/rose_build_misc.h src/rose/rose_build_program.cpp src/rose/rose_build_program.h src/rose/rose_build_resources.h src/rose/rose_build_role_aliasing.cpp src/rose/rose_build_scatter.cpp src/rose/rose_build_scatter.h src/rose/rose_build_util.h src/rose/rose_build_width.cpp src/rose/rose_build_width.h src/rose/rose_graph.h src/rose/rose_in_graph.h src/rose/rose_in_util.cpp src/rose/rose_in_util.h src/util/accel_scheme.h src/util/alloc.cpp src/util/alloc.h src/util/bitfield.h src/util/boundary_reports.h src/util/charreach.cpp src/util/charreach.h src/util/charreach_util.h src/util/clique.cpp src/util/clique.h src/util/compare.h src/util/compile_context.cpp src/util/compile_context.h src/util/compile_error.cpp src/util/compile_error.h src/util/container.h src/util/depth.cpp src/util/depth.h src/util/determinise.h src/util/dump_mask.cpp src/util/dump_mask.h src/util/fatbit_build.cpp src/util/fatbit_build.h src/util/flat_containers.h src/util/graph.h src/util/graph_range.h src/util/graph_small_color_map.h src/util/hash.h src/util/hash_dynamic_bitset.h src/util/insertion_ordered.h src/util/math.h src/util/multibit_build.cpp src/util/multibit_build.h src/util/noncopyable.h src/util/operators.h src/util/order_check.h src/util/partial_store.h src/util/partitioned_set.h src/util/popcount.h src/util/queue_index_factory.h src/util/report.h src/util/report_manager.cpp src/util/report_manager.h src/util/simd_utils.h src/util/small_vector.h src/util/target_info.cpp src/util/target_info.h src/util/ue2_graph.h src/util/ue2string.cpp src/util/ue2string.h src/util/unaligned.h src/util/unicode_def.h src/util/unicode_set.h src/util/uniform_ops.h src/util/unordered.h src/util/verify_types.h ) set(hs_dump_SRCS src/scratch_dump.cpp src/scratch_dump.h src/fdr/fdr_dump.cpp src/hwlm/hwlm_dump.cpp src/hwlm/hwlm_dump.h src/nfa/accel_dump.cpp src/nfa/accel_dump.h src/nfa/castle_dump.cpp src/nfa/castle_dump.h src/nfagraph/ng_dump.cpp src/nfagraph/ng_dump.h src/nfa/goughcompile_dump.cpp src/nfa/goughcompile_dump.h src/nfa/goughdump.cpp src/nfa/goughdump.h src/nfa/lbr_dump.cpp src/nfa/limex_dump.cpp src/nfa/mcclellandump.cpp src/nfa/mcclellandump.h src/nfa/mcsheng_dump.cpp src/nfa/mcsheng_dump.h src/nfa/mpv_dump.cpp src/nfa/nfa_dump_api.h src/nfa/nfa_dump_dispatch.cpp src/nfa/nfa_dump_internal.cpp src/nfa/nfa_dump_internal.h src/nfa/shengdump.cpp src/nfa/shengdump.h src/nfa/tamarama_dump.cpp src/nfa/tamarama_dump.h src/parser/dump.cpp src/parser/dump.h src/parser/position_dump.h src/smallwrite/smallwrite_dump.cpp src/smallwrite/smallwrite_dump.h src/som/slot_manager_dump.cpp src/som/slot_manager_dump.h src/rose/rose_build_dump.cpp src/rose/rose_build_dump.h src/rose/rose_in_dump.cpp src/rose/rose_in_dump.h src/util/dump_charclass.cpp src/util/dump_charclass.h src/util/dump_util.cpp src/util/dump_util.h ) if (DUMP_SUPPORT) set(hs_compile_SRCS ${hs_compile_SRCS} ${hs_dump_SRCS}) endif() # we group things by sublibraries, specifying shared and static and then # choose which ones to build set (LIB_VERSION ${HS_VERSION}) set (LIB_SOVERSION ${HS_MAJOR_VERSION}) if (NOT FAT_RUNTIME) set(hs_exec_SRCS ${hs_exec_SRCS} ${hs_exec_common_SRCS}) if (HAVE_AVX2) set(hs_exec_SRCS ${hs_exec_SRCS} ${hs_exec_avx2_SRCS}) endif() if (BUILD_STATIC_LIBS) add_library(hs_exec OBJECT ${hs_exec_SRCS}) add_library(hs_runtime STATIC src/hs_version.c src/hs_valid_platform.c $) set_target_properties(hs_runtime PROPERTIES LINKER_LANGUAGE C) add_library(hs_compile OBJECT ${hs_compile_SRCS}) add_library(hs STATIC src/hs_version.c src/hs_valid_platform.c $ $) endif (BUILD_STATIC_LIBS) if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS) add_library(hs_exec_shared OBJECT ${hs_exec_SRCS}) set_target_properties(hs_exec_shared PROPERTIES POSITION_INDEPENDENT_CODE TRUE) add_library(hs_compile_shared OBJECT ${hs_compile_SRCS}) set_target_properties(hs_compile_shared PROPERTIES POSITION_INDEPENDENT_CODE TRUE) endif() else (FAT_RUNTIME) set(BUILD_WRAPPER "${PROJECT_SOURCE_DIR}/cmake/build_wrapper.sh") if (NOT BUILD_AVX512) set (DISPATCHER_DEFINE "-DDISABLE_AVX512_DISPATCH") endif (NOT BUILD_AVX512) set_source_files_properties(src/dispatcher.c PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter -Wno-unused-function ${DISPATCHER_DEFINE}") if (BUILD_STATIC_LIBS) add_library(hs_exec_core2 OBJECT ${hs_exec_SRCS}) list(APPEND RUNTIME_LIBS $) set_target_properties(hs_exec_core2 PROPERTIES COMPILE_FLAGS "-march=core2" RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} core2 ${CMAKE_MODULE_PATH}/keep.syms.in" ) add_library(hs_exec_corei7 OBJECT ${hs_exec_SRCS}) list(APPEND RUNTIME_LIBS $) set_target_properties(hs_exec_corei7 PROPERTIES COMPILE_FLAGS "-march=corei7" RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} corei7 ${CMAKE_MODULE_PATH}/keep.syms.in" ) add_library(hs_exec_avx2 OBJECT ${hs_exec_SRCS} ${hs_exec_avx2_SRCS}) list(APPEND RUNTIME_LIBS $) set_target_properties(hs_exec_avx2 PROPERTIES COMPILE_FLAGS "-march=core-avx2" RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} avx2 ${CMAKE_MODULE_PATH}/keep.syms.in" ) if (BUILD_AVX512) add_library(hs_exec_avx512 OBJECT ${hs_exec_SRCS} ${hs_exec_avx2_SRCS}) list(APPEND RUNTIME_LIBS $) set_target_properties(hs_exec_avx512 PROPERTIES COMPILE_FLAGS "${SKYLAKE_FLAG}" RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} avx512 ${CMAKE_MODULE_PATH}/keep.syms.in" ) endif (BUILD_AVX512) add_library(hs_exec_common OBJECT ${hs_exec_common_SRCS} src/dispatcher.c ) # hs_version.c is added explicitly to avoid some build systems that refuse to # create a lib without any src (I'm looking at you Xcode) add_library(hs_runtime STATIC src/hs_version.c $ ${RUNTIME_LIBS}) set_target_properties(hs_runtime PROPERTIES LINKER_LANGUAGE C) add_library(hs_compile OBJECT ${hs_compile_SRCS}) # we want the static lib for testing add_library(hs STATIC src/hs_version.c src/hs_valid_platform.c $ $ ${RUNTIME_LIBS}) endif (BUILD_STATIC_LIBS) if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS) # build shared libs add_library(hs_compile_shared OBJECT ${hs_compile_SRCS}) set_target_properties(hs_compile_shared PROPERTIES POSITION_INDEPENDENT_CODE TRUE) add_library(hs_exec_shared_core2 OBJECT ${hs_exec_SRCS}) list(APPEND RUNTIME_SHLIBS $) set_target_properties(hs_exec_shared_core2 PROPERTIES COMPILE_FLAGS "-march=core2" POSITION_INDEPENDENT_CODE TRUE RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} core2 ${CMAKE_MODULE_PATH}/keep.syms.in" ) add_library(hs_exec_shared_corei7 OBJECT ${hs_exec_SRCS}) list(APPEND RUNTIME_SHLIBS $) set_target_properties(hs_exec_shared_corei7 PROPERTIES COMPILE_FLAGS "-march=corei7" POSITION_INDEPENDENT_CODE TRUE RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} corei7 ${CMAKE_MODULE_PATH}/keep.syms.in" ) add_library(hs_exec_shared_avx2 OBJECT ${hs_exec_SRCS} ${hs_exec_avx2_SRCS}) list(APPEND RUNTIME_SHLIBS $) set_target_properties(hs_exec_shared_avx2 PROPERTIES COMPILE_FLAGS "-march=core-avx2" POSITION_INDEPENDENT_CODE TRUE RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} avx2 ${CMAKE_MODULE_PATH}/keep.syms.in" ) if (BUILD_AVX512) add_library(hs_exec_shared_avx512 OBJECT ${hs_exec_SRCS} ${hs_exec_avx2_SRCS}) list(APPEND RUNTIME_SHLIBS $) set_target_properties(hs_exec_shared_avx512 PROPERTIES COMPILE_FLAGS "${SKYLAKE_FLAG}" POSITION_INDEPENDENT_CODE TRUE RULE_LAUNCH_COMPILE "${BUILD_WRAPPER} avx512 ${CMAKE_MODULE_PATH}/keep.syms.in" ) endif (BUILD_AVX512) add_library(hs_exec_common_shared OBJECT ${hs_exec_common_SRCS} src/dispatcher.c ) set_target_properties(hs_exec_common_shared PROPERTIES OUTPUT_NAME hs_exec_common POSITION_INDEPENDENT_CODE TRUE) endif() # SHARED endif (NOT FAT_RUNTIME) if (NOT BUILD_SHARED_LIBS) install(TARGETS hs_runtime DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS) if (NOT FAT_RUNTIME) add_library(hs_runtime_shared SHARED src/hs_version.c src/hs_valid_platform.c $) else() add_library(hs_runtime_shared SHARED src/hs_version.c src/hs_valid_platform.c $ ${RUNTIME_SHLIBS}) endif() set_target_properties(hs_runtime_shared PROPERTIES VERSION ${LIB_VERSION} SOVERSION ${LIB_SOVERSION} OUTPUT_NAME hs_runtime MACOSX_RPATH ON LINKER_LANGUAGE C) install(TARGETS hs_runtime_shared RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() if (BUILD_STATIC_LIBS) add_dependencies(hs ragel_Parser) endif () if (NOT BUILD_SHARED_LIBS) install(TARGETS hs DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS) set(hs_shared_SRCS src/hs_version.c src/hs_valid_platform.c $) if (XCODE) # force this lib to use C++ linkage add_custom_command(OUTPUT empty.cxx COMMAND ${CMAKE_COMMAND} -E touch empty.cxx) set (hs_shared_SRCS ${hs_shared_SRCS} empty.cxx) endif (XCODE) if (NOT FAT_RUNTIME) set(hs_shared_SRCS ${hs_shared_SRCS} $) else () set(hs_shared_SRCS ${hs_shared_SRCS} $ ${RUNTIME_SHLIBS}) endif () add_library(hs_shared SHARED ${hs_shared_SRCS}) add_dependencies(hs_shared ragel_Parser) set_target_properties(hs_shared PROPERTIES OUTPUT_NAME hs VERSION ${LIB_VERSION} SOVERSION ${LIB_SOVERSION} MACOSX_RPATH ON) install(TARGETS hs_shared RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() # used by tools and other targets if (NOT BUILD_STATIC_LIBS) # use shared lib without having to change all the targets add_library(hs ALIAS hs_shared) endif () if(NOT WIN32) add_subdirectory(examples) endif() hyperscan-4.7.0/COPYING000066400000000000000000000027061323202717100145540ustar00rootroot00000000000000Copyright (c) 2015, Intel Corporation Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. hyperscan-4.7.0/LICENSE000066400000000000000000000135751323202717100145340ustar00rootroot00000000000000Hyperscan is licensed under the BSD License. Copyright (c) 2015, Intel Corporation Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- This product also contains code from third parties, under the following licenses: Intel's Slicing-by-8 CRC32 implementation ----------------------------------------- Copyright (c) 2004-2006, Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Boost C++ Headers Library ------------------------- Boost Software License - Version 1.0 - August 17th, 2003 Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. The Google C++ Testing Framework (Google Test) ---------------------------------------------- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. hyperscan-4.7.0/README.md000066400000000000000000000030751323202717100150000ustar00rootroot00000000000000# Hyperscan Hyperscan is a high-performance multiple regex matching library. It follows the regular expression syntax of the commonly-used libpcre library, but is a standalone library with its own C API. Hyperscan uses hybrid automata techniques to allow simultaneous matching of large numbers (up to tens of thousands) of regular expressions and for the matching of regular expressions across streams of data. Hyperscan is typically used in a DPI library stack. # Documentation Information on building the Hyperscan library and using its API is available in the [Developer Reference Guide](http://intel.github.io/hyperscan/dev-reference/). # License Hyperscan is licensed under the BSD License. See the LICENSE file in the project repository. # Versioning The `master` branch on Github will always contain the most recent release of Hyperscan. Each version released to `master` goes through QA and testing before it is released; if you're a user, rather than a developer, this is the version you should be using. Further development towards the next release takes place on the `develop` branch. # Get Involved The official homepage for Hyperscan is at [01.org/hyperscan](https://01.org/hyperscan). If you have questions or comments, we encourage you to [join the mailing list](https://lists.01.org/mailman/listinfo/hyperscan). Bugs can be filed by sending email to the list, or by creating an issue on Github. If you wish to contact the Hyperscan team at Intel directly, without posting publicly to the mailing list, send email to [hyperscan@intel.com](mailto:hyperscan@intel.com). hyperscan-4.7.0/cmake/000077500000000000000000000000001323202717100145745ustar00rootroot00000000000000hyperscan-4.7.0/cmake/arch.cmake000066400000000000000000000045151323202717100165200ustar00rootroot00000000000000# detect architecture features # # must be called after determining where compiler intrinsics are defined if (HAVE_C_X86INTRIN_H) set (INTRIN_INC_H "x86intrin.h") elseif (HAVE_C_INTRIN_H) set (INTRIN_INC_H "intrin.h") else () message (FATAL_ERROR "No intrinsics header found") endif () if (BUILD_AVX512) CHECK_C_COMPILER_FLAG(${SKYLAKE_FLAG} HAS_ARCH_SKYLAKE) if (NOT HAS_ARCH_SKYLAKE) message (FATAL_ERROR "AVX512 not supported by compiler") endif () endif () if (FAT_RUNTIME) # test the highest level microarch to make sure everything works if (BUILD_AVX512) set (CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS} ${SKYLAKE_FLAG}") else () set (CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS} -march=core-avx2") endif () else (NOT FAT_RUNTIME) # if not fat runtime, then test given cflags set (CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS} ${ARCH_C_FLAGS}") endif () # ensure we have the minimum of SSSE3 - call a SSSE3 intrinsic CHECK_C_SOURCE_COMPILES("#include <${INTRIN_INC_H}> int main() { __m128i a = _mm_set1_epi8(1); (void)_mm_shuffle_epi8(a, a); }" HAVE_SSSE3) # now look for AVX2 CHECK_C_SOURCE_COMPILES("#include <${INTRIN_INC_H}> #if !defined(__AVX2__) #error no avx2 #endif int main(){ __m256i z = _mm256_setzero_si256(); (void)_mm256_xor_si256(z, z); }" HAVE_AVX2) # and now for AVX512 CHECK_C_SOURCE_COMPILES("#include <${INTRIN_INC_H}> #if !defined(__AVX512BW__) #error no avx512bw #endif int main(){ __m512i z = _mm512_setzero_si512(); (void)_mm512_abs_epi8(z); }" HAVE_AVX512) if (FAT_RUNTIME) if (NOT HAVE_SSSE3) message(FATAL_ERROR "SSSE3 support required to build fat runtime") endif () if (NOT HAVE_AVX2) message(FATAL_ERROR "AVX2 support required to build fat runtime") endif () if (BUILD_AVX512 AND NOT HAVE_AVX512) message(FATAL_ERROR "AVX512 support requested but not supported") endif () else (NOT FAT_RUNTIME) if (NOT HAVE_AVX2) message(STATUS "Building without AVX2 support") endif () if (NOT HAVE_AVX512) message(STATUS "Building without AVX512 support") endif () if (NOT HAVE_SSSE3) message(FATAL_ERROR "A minimum of SSSE3 compiler support is required") endif () endif () unset (CMAKE_REQUIRED_FLAGS) unset (INTRIN_INC_H) hyperscan-4.7.0/cmake/attrib.cmake000066400000000000000000000005521323202717100170650ustar00rootroot00000000000000# tests for compiler properties # set -Werror so we can't ignore unused attribute warnings set (CMAKE_REQUIRED_FLAGS "-Werror") CHECK_C_SOURCE_COMPILES(" int foo(int) __attribute__ ((ifunc(\"foo_i\"))); int f1(int i) { return i; } void (*foo_i()) { return f1; } int main(void) { return 0; } " HAS_C_ATTR_IFUNC) unset(CMAKE_REQUIRED_FLAGS) hyperscan-4.7.0/cmake/backtrace.cmake000066400000000000000000000040041323202717100175130ustar00rootroot00000000000000# The `backtrace' function is available on Linux via glibc, and on FreeBSD if # the 'libexecinfo' package is installed. CHECK_C_SOURCE_COMPILES( "#include \n#include \nint main () { backtrace(NULL, 0); }" BACKTRACE_LIBC) if(BACKTRACE_LIBC) set(HAVE_BACKTRACE TRUE) set(BACKTRACE_CFLAGS "") set(BACKTRACE_LDFLAGS "") endif() if(NOT BACKTRACE_LIBC) # FreeBSD 10 has backtrace but requires libexecinfo list(INSERT CMAKE_REQUIRED_LIBRARIES 0 "-lexecinfo") CHECK_C_SOURCE_COMPILES( "#include \n#include \nint main () { backtrace(NULL, 0); }" BACKTRACE_LIBEXECINFO) list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "-lexecinfo") if(BACKTRACE_LIBEXECINFO) set(HAVE_BACKTRACE TRUE) set(BACKTRACE_CFLAGS "") set(BACKTRACE_LDFLAGS "-lexecinfo") else() # older FreeBSD requires it from ports list(INSERT CMAKE_REQUIRED_INCLUDES 0 "/usr/local/include") list(INSERT CMAKE_REQUIRED_LIBRARIES 0 "-L/usr/local/lib -lexecinfo") CHECK_C_SOURCE_COMPILES( "#include \n#include \nint main () { backtrace(NULL, 0); }" BACKTRACE_LIBEXECINFO_LOCAL) list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES 0 "/usr/local/include") list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "-L/usr/local/lib -lexecinfo") if(BACKTRACE_LIBEXECINFO_LOCAL) set(HAVE_BACKTRACE TRUE) set(BACKTRACE_CFLAGS "-I/usr/local/include") set(BACKTRACE_LDFLAGS "-L/usr/local/lib -lexecinfo") endif() endif() endif() if(HAVE_BACKTRACE) CHECK_C_COMPILER_FLAG(-rdynamic HAS_RDYNAMIC) if(HAS_RDYNAMIC) list(INSERT BACKTRACE_LDFLAGS 0 -rdynamic) endif() else() set(BACKTRACE_CFLAGS "") set(BACKTRACE_LDFLAGS "") endif() # cmake scope fun set(HAVE_BACKTRACE ${HAVE_BACKTRACE} CACHE BOOL INTERNAL) set(BACKTRACE_CFLAGS ${BACKTRACE_CFLAGS} CACHE STRING INTERNAL) set(BACKTRACE_LDFLAGS ${BACKTRACE_LDFLAGS} CACHE STRING INTERNAL) hyperscan-4.7.0/cmake/boost.cmake000066400000000000000000000045171323202717100167330ustar00rootroot00000000000000# Various checks related to Boost set(BOOST_USE_STATIC_LIBS OFF) set(BOOST_USE_MULTITHREADED OFF) set(BOOST_USE_STATIC_RUNTIME OFF) if (HAVE_LIBCPP) # we need a more recent boost for libc++ set(BOOST_MINVERSION 1.61.0) else () set(BOOST_MINVERSION 1.57.0) endif () set(BOOST_NO_BOOST_CMAKE ON) unset(Boost_INCLUDE_DIR CACHE) # we might have boost in tree, so provide a hint and try again set(BOOST_INCLUDEDIR "${PROJECT_SOURCE_DIR}/include") find_package(Boost ${BOOST_MINVERSION} QUIET) if(NOT Boost_FOUND) # otherwise check for Boost installed on the system unset(BOOST_INCLUDEDIR) find_package(Boost ${BOOST_MINVERSION} QUIET) if(NOT Boost_FOUND) message(FATAL_ERROR "Boost ${BOOST_MINVERSION} or later not found. Either install system packages if available, extract Boost headers to ${CMAKE_SOURCE_DIR}/include, or set the CMake BOOST_ROOT variable.") endif() endif() message(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") # Boost 1.62 has a bug that we've patched around, check if it is required if (Boost_VERSION EQUAL 106200) set (CMAKE_REQUIRED_INCLUDES ${BOOST_INCLUDEDIR} "${PROJECT_SOURCE_DIR}/include") set (BOOST_REV_TEST " #include #include #include #include int main(int,char*[]) { using namespace boost; // Check const reverse_graph { typedef adjacency_list< vecS, vecS, bidirectionalS, property, property, property > AdjList; typedef reverse_graph Graph; BOOST_CONCEPT_ASSERT(( BidirectionalGraphConcept )); } return 0; } ") CHECK_CXX_SOURCE_COMPILES("${BOOST_REV_TEST}" BOOST_REVGRAPH_OK) if (NOT BOOST_REVGRAPH_OK) message(STATUS "trying patched") CHECK_CXX_SOURCE_COMPILES(" #include ${BOOST_REV_TEST}" BOOST_REVGRAPH_PATCH) endif() if (NOT BOOST_REVGRAPH_OK AND NOT BOOST_REVGRAPH_PATCH) message(FATAL_ERROR "Something is wrong with this copy of boost::reverse_graph") endif() unset (CMAKE_REQUIRED_INCLUDES) else () unset(BOOST_REVGRAPH_OK CACHE) unset(BOOST_REVGRAPH_PATCH CACHE) endif () # Boost 1.62.0 hyperscan-4.7.0/cmake/build_wrapper.sh000077500000000000000000000016061323202717100177750ustar00rootroot00000000000000#!/bin/sh -e # This is used for renaming symbols for the fat runtime, don't call directly # TODO: make this a lot less fragile! cleanup () { rm -f ${SYMSFILE} ${KEEPSYMS} } PREFIX=$1 KEEPSYMS_IN=$2 shift 2 # $@ contains the actual build command OUT=$(echo "$@" | sed 's/.* -o \(.*\.o\).*/\1/') trap cleanup INT QUIT EXIT SYMSFILE=$(mktemp -p /tmp ${PREFIX}_rename.syms.XXXXX) KEEPSYMS=$(mktemp -p /tmp keep.syms.XXXXX) # find the libc used by gcc LIBC_SO=$("$@" --print-file-name=libc.so.6) cp ${KEEPSYMS_IN} ${KEEPSYMS} # get all symbols from libc and turn them into patterns nm -f p -g -D ${LIBC_SO} | sed -s 's/\([^ ]*\).*/^\1$/' >> ${KEEPSYMS} # build the object "$@" # rename the symbols in the object nm -f p -g ${OUT} | cut -f1 -d' ' | grep -v -f ${KEEPSYMS} | sed -e "s/\(.*\)/\1\ ${PREFIX}_\1/" >> ${SYMSFILE} if test -s ${SYMSFILE} then objcopy --redefine-syms=${SYMSFILE} ${OUT} fi hyperscan-4.7.0/cmake/config.h.in000066400000000000000000000051311323202717100166170ustar00rootroot00000000000000/* used by cmake */ #ifndef CONFIG_H_ #define CONFIG_H_ /* "Define if the build is 32 bit" */ #cmakedefine ARCH_32_BIT /* "Define if the build is 64 bit" */ #cmakedefine ARCH_64_BIT /* "Define if building for IA32" */ #cmakedefine ARCH_IA32 /* "Define if building for EM64T" */ #cmakedefine ARCH_X86_64 /* internal build, switch on dump support. */ #cmakedefine DUMP_SUPPORT /* Define if building "fat" runtime. */ #cmakedefine FAT_RUNTIME /* Define if building AVX-512 in the fat runtime. */ #cmakedefine BUILD_AVX512 /* Define to 1 if `backtrace' works. */ #cmakedefine HAVE_BACKTRACE /* C compiler has __builtin_assume_aligned */ #cmakedefine HAVE_CC_BUILTIN_ASSUME_ALIGNED /* C++ compiler has __builtin_assume_aligned */ #cmakedefine HAVE_CXX_BUILTIN_ASSUME_ALIGNED /* C++ compiler has x86intrin.h */ #cmakedefine HAVE_CXX_X86INTRIN_H /* C compiler has x86intrin.h */ #cmakedefine HAVE_C_X86INTRIN_H /* C++ compiler has intrin.h */ #cmakedefine HAVE_CXX_INTRIN_H /* C compiler has intrin.h */ #cmakedefine HAVE_C_INTRIN_H /* Define to 1 if you have the declaration of `pthread_setaffinity_np', and to 0 if you don't. */ #cmakedefine HAVE_DECL_PTHREAD_SETAFFINITY_NP #cmakedefine HAVE_PTHREAD_NP_H /* Define to 1 if you have the `malloc_info' function. */ #cmakedefine HAVE_MALLOC_INFO /* Define to 1 if you have the `memmem' function. */ #cmakedefine HAVE_MEMMEM /* Define to 1 if you have a working `mmap' system call. */ #cmakedefine HAVE_MMAP /* Define to 1 if `posix_memalign' works. */ #cmakedefine HAVE_POSIX_MEMALIGN /* Define to 1 if you have the `setrlimit' function. */ #cmakedefine HAVE_SETRLIMIT /* Define to 1 if you have the `shmget' function. */ #cmakedefine HAVE_SHMGET /* Define to 1 if you have the `sigaction' function. */ #cmakedefine HAVE_SIGACTION /* Define to 1 if you have the `sigaltstack' function. */ #cmakedefine HAVE_SIGALTSTACK /* Define if the sqlite3_open_v2 call is available */ #cmakedefine HAVE_SQLITE3_OPEN_V2 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UNISTD_H /* Define to 1 if you have the `_aligned_malloc' function. */ #cmakedefine HAVE__ALIGNED_MALLOC /* Define if compiler has __builtin_constant_p */ #cmakedefine HAVE__BUILTIN_CONSTANT_P /* Optimize, inline critical functions */ #cmakedefine HS_OPTIMIZE #cmakedefine HS_VERSION #cmakedefine HS_MAJOR_VERSION #cmakedefine HS_MINOR_VERSION #cmakedefine HS_PATCH_VERSION #cmakedefine BUILD_DATE /* define if this is a release build. */ #cmakedefine RELEASE_BUILD /* define if reverse_graph requires patch for boost 1.62.0 */ #cmakedefine BOOST_REVGRAPH_PATCH #endif /* CONFIG_H_ */ hyperscan-4.7.0/cmake/formatdate.py000077500000000000000000000005421323202717100173000ustar00rootroot00000000000000#!/usr/bin/env python from __future__ import print_function import os import sys import datetime def usage(): print("Usage:", os.path.basename(sys.argv[0]), "") if len(sys.argv) != 2: usage() sys.exit(1) ts = sys.argv[1] build_date = datetime.datetime.utcfromtimestamp(int(ts)) print(build_date.strftime("%Y-%m-%d")) hyperscan-4.7.0/cmake/keep.syms.in000066400000000000000000000002441323202717100170420ustar00rootroot00000000000000# names to exclude hs_misc_alloc hs_misc_free hs_free_scratch hs_stream_alloc hs_stream_free hs_scratch_alloc hs_scratch_free hs_database_alloc hs_database_free ^_ hyperscan-4.7.0/cmake/pcre.cmake000066400000000000000000000045371323202717100165400ustar00rootroot00000000000000# first look in pcre-$version or pcre subdirs if (PCRE_SOURCE) # either provided on cmdline or we've seen it already set (PCRE_BUILD_SOURCE TRUE) elseif (EXISTS ${PROJECT_SOURCE_DIR}/pcre-${PCRE_REQUIRED_VERSION}) set (PCRE_SOURCE ${PROJECT_SOURCE_DIR}/pcre-${PCRE_REQUIRED_VERSION}) set (PCRE_BUILD_SOURCE TRUE) elseif (EXISTS ${PROJECT_SOURCE_DIR}/pcre) set (PCRE_SOURCE ${PROJECT_SOURCE_DIR}/pcre) set (PCRE_BUILD_SOURCE TRUE) endif() if (PCRE_BUILD_SOURCE) if (NOT IS_ABSOLUTE ${PCRE_SOURCE}) set(PCRE_SOURCE "${CMAKE_BINARY_DIR}/${PCRE_SOURCE}") endif () set (saved_INCLUDES "${CMAKE_REQUIRED_INCLUDES}") set (CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES} ${PCRE_SOURCE}") if (PCRE_CHECKED) set(PCRE_INCLUDE_DIRS ${PCRE_SOURCE} ${PROJECT_BINARY_DIR}/pcre) set(PCRE_LDFLAGS -L"${LIBDIR}" -lpcre) # already processed this file and set up pcre building return() endif () # first, check version number CHECK_C_SOURCE_COMPILES("#include #if PCRE_MAJOR != ${PCRE_REQUIRED_MAJOR_VERSION} || PCRE_MINOR != ${PCRE_REQUIRED_MINOR_VERSION} #error Incorrect pcre version #endif main() {}" CORRECT_PCRE_VERSION) set (CMAKE_REQUIRED_INCLUDES "${saved_INCLUDES}") if (NOT CORRECT_PCRE_VERSION) unset(CORRECT_PCRE_VERSION CACHE) message(STATUS "Incorrect version of pcre - version ${PCRE_REQUIRED_VERSION} is required") return () else() message(STATUS "PCRE version ${PCRE_REQUIRED_VERSION} - building from source.") endif() # PCRE compile options option(PCRE_BUILD_PCRECPP OFF) option(PCRE_BUILD_PCREGREP OFF) option(PCRE_SHOW_REPORT OFF) set(PCRE_SUPPORT_UNICODE_PROPERTIES ON CACHE BOOL "Build pcre with unicode") add_subdirectory(${PCRE_SOURCE} ${PROJECT_BINARY_DIR}/pcre EXCLUDE_FROM_ALL) set(PCRE_INCLUDE_DIRS ${PCRE_SOURCE} ${PROJECT_BINARY_DIR}/pcre) set(PCRE_LDFLAGS -L"${LIBDIR}" -lpcre) else () # pkgconf should save us find_package(PkgConfig) pkg_check_modules(PCRE libpcre=${PCRE_REQUIRED_VERSION}) if (PCRE_FOUND) message(STATUS "PCRE version ${PCRE_REQUIRED_VERSION}") else () message(STATUS "PCRE version ${PCRE_REQUIRED_VERSION} not found") return () endif () endif (PCRE_BUILD_SOURCE) set (PCRE_CHECKED TRUE PARENT_SCOPE) hyperscan-4.7.0/cmake/platform.cmake000066400000000000000000000006501323202717100174230ustar00rootroot00000000000000# determine the target arch # really only interested in the preprocessor here CHECK_C_SOURCE_COMPILES("#if !(defined(__x86_64__) || defined(_M_X64))\n#error not 64bit\n#endif\nint main(void) { return 0; }" ARCH_64_BIT) CHECK_C_SOURCE_COMPILES("#if !(defined(__i386__) || defined(_M_IX86))\n#error not 64bit\n#endif\nint main(void) { return 0; }" ARCH_32_BIT) set(ARCH_X86_64 ${ARCH_64_BIT}) set(ARCH_IA32 ${ARCH_32_BIT}) hyperscan-4.7.0/cmake/ragel.cmake000066400000000000000000000014041323202717100166670ustar00rootroot00000000000000# function for doing all the dirty work in turning a .rl into C++ function(ragelmaker src_rl) get_filename_component(src_dir ${src_rl} PATH) # old cmake needs PATH get_filename_component(src_file ${src_rl} NAME_WE) set(rl_out ${CMAKE_CURRENT_BINARY_DIR}/${src_dir}/${src_file}.cpp) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${src_dir}/${src_file}.cpp COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${src_dir} COMMAND ${RAGEL} ${CMAKE_CURRENT_SOURCE_DIR}/${src_rl} -o ${rl_out} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${src_rl} ) add_custom_target(ragel_${src_file} DEPENDS ${rl_out}) set_source_files_properties(${rl_out} PROPERTIES GENERATED TRUE) endfunction(ragelmaker) hyperscan-4.7.0/cmake/sqlite3.cmake000066400000000000000000000040411323202717100171610ustar00rootroot00000000000000# # a lot of noise to find sqlite # option(SQLITE_PREFER_STATIC "Build sqlite3 statically instead of using an installed lib" OFF) if(NOT WIN32 AND NOT SQLITE_PREFER_STATIC) find_package(PkgConfig QUIET) # first check for sqlite on the system pkg_check_modules(SQLITE3 sqlite3) endif() if (NOT SQLITE3_FOUND) message(STATUS "looking for sqlite3 in source tree") # look in the source tree if (EXISTS "${PROJECT_SOURCE_DIR}/sqlite3/sqlite3.h" AND EXISTS "${PROJECT_SOURCE_DIR}/sqlite3/sqlite3.c") message(STATUS " found sqlite3 in source tree") set(SQLITE3_FOUND TRUE) set(SQLITE3_BUILD_SOURCE TRUE) set(SQLITE3_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/sqlite3") set(SQLITE3_LDFLAGS sqlite3_static) else() message(STATUS " no sqlite3 in source tree") endif() endif() # now do version checks if (SQLITE3_FOUND) list(INSERT CMAKE_REQUIRED_INCLUDES 0 "${SQLITE3_INCLUDE_DIRS}") CHECK_C_SOURCE_COMPILES("#include \n#if SQLITE_VERSION_NUMBER >= 3008007 && SQLITE_VERSION_NUMBER < 3008010\n#error broken sqlite\n#endif\nint main() {return 0;}" SQLITE_VERSION_OK) if (NOT SQLITE_VERSION_OK) message(FATAL_ERROR "sqlite3 is broken from 3.8.7 to 3.8.10 - please find a working version") endif() if (NOT SQLITE3_BUILD_SOURCE) set(_SAVED_FLAGS ${CMAKE_REQUIRED_FLAGS}) list(INSERT CMAKE_REQUIRED_LIBRARIES 0 ${SQLITE3_LDFLAGS}) CHECK_SYMBOL_EXISTS(sqlite3_open_v2 sqlite3.h HAVE_SQLITE3_OPEN_V2) list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES "${SQLITE3_INCLUDE_DIRS}") list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${SQLITE3_LDFLAGS}) else() if (NOT TARGET sqlite3_static) # build sqlite as a static lib to compile into our test programs add_library(sqlite3_static STATIC "${PROJECT_SOURCE_DIR}/sqlite3/sqlite3.c") if (NOT WIN32) set_target_properties(sqlite3_static PROPERTIES COMPILE_FLAGS "-Wno-error -Wno-extra -Wno-unused -Wno-cast-qual -DSQLITE_OMIT_LOAD_EXTENSION") endif() endif() endif() endif() # that's enough about sqlite hyperscan-4.7.0/doc/000077500000000000000000000000001323202717100142615ustar00rootroot00000000000000hyperscan-4.7.0/doc/dev-reference/000077500000000000000000000000001323202717100167735ustar00rootroot00000000000000hyperscan-4.7.0/doc/dev-reference/CMakeLists.txt000066400000000000000000000022721323202717100215360ustar00rootroot00000000000000find_program(DOXYGEN doxygen) if (DOXYGEN STREQUAL DOXYGEN-NOTFOUND) message(STATUS "Doxygen not found, unable to generate API reference") else() configure_file("${CMAKE_CURRENT_SOURCE_DIR}/hyperscan.doxyfile.in" "${CMAKE_CURRENT_BINARY_DIR}/hyperscan.doxyfile" @ONLY) add_custom_target(dev-reference-doxygen ${DOXYGEN} ${CMAKE_CURRENT_BINARY_DIR}/hyperscan.doxyfile COMMENT "Building doxygen XML for API reference") endif() find_program(SPHINX_BUILD sphinx-build) if (SPHINX_BUILD STREQUAL SPHINX_BUILD-NOTFOUND) message(STATUS "Sphinx not found, unable to generate developer reference") else() set(SPHINX_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/_build") set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees") set(SPHINX_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/html") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in" "${CMAKE_CURRENT_BINARY_DIR}/conf.py" @ONLY) add_custom_target(dev-reference ${SPHINX_BUILD} -b html -c "${CMAKE_CURRENT_BINARY_DIR}" -d "${SPHINX_CACHE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" "${SPHINX_HTML_DIR}" DEPENDS dev-reference-doxygen COMMENT "Building HTML dev reference with Sphinx") endif() hyperscan-4.7.0/doc/dev-reference/_static/000077500000000000000000000000001323202717100204215ustar00rootroot00000000000000hyperscan-4.7.0/doc/dev-reference/_static/hyperscan.css000066400000000000000000000004571323202717100231350ustar00rootroot00000000000000/* Differentiate the way we display regex fragments. */ .regexp { color: darkred !important; } /* Avoid (the alabaster theme default) Goudy Old Style, which renders in * italics on some Mac/Safari systems. */ body { font-family: 'minion pro', 'bell mt', Georgia, 'Hiragino Mincho Pro', serif; } hyperscan-4.7.0/doc/dev-reference/api_constants.rst000066400000000000000000000014431323202717100223740ustar00rootroot00000000000000.. _api_constants: ######################## API Reference: Constants ######################## *********** Error Codes *********** .. doxygengroup:: HS_ERROR :content-only: :no-link: ***************** hs_expr_ext flags ***************** .. doxygengroup:: HS_EXT_FLAG :content-only: :no-link: ************* Pattern flags ************* .. doxygengroup:: HS_PATTERN_FLAG :content-only: :no-link: ************************* CPU feature support flags ************************* .. doxygengroup:: HS_CPU_FEATURES_FLAG :content-only: :no-link: **************** CPU tuning flags **************** .. doxygengroup:: HS_TUNE_FLAG :content-only: :no-link: ****************** Compile mode flags ****************** .. doxygengroup:: HS_MODE_FLAG :content-only: :no-link: hyperscan-4.7.0/doc/dev-reference/api_files.rst000066400000000000000000000006171323202717100214640ustar00rootroot00000000000000.. _api_files: #################### API Reference: Files #################### ********** File: hs.h ********** .. doxygenfile:: hs.h ***************** File: hs_common.h ***************** .. doxygenfile:: hs_common.h ****************** File: hs_compile.h ****************** .. doxygenfile:: hs_compile.h ****************** File: hs_runtime.h ****************** .. doxygenfile:: hs_runtime.h hyperscan-4.7.0/doc/dev-reference/compilation.rst000066400000000000000000000527221323202717100220530ustar00rootroot00000000000000.. include:: .. _compilation: ################## Compiling Patterns ################## ******************* Building a Database ******************* The Hyperscan compiler API accepts regular expressions and converts them into a compiled pattern database that can then be used to scan data. The API provides three functions that compile regular expressions into databases: #. :c:func:`hs_compile`: compiles a single expression into a pattern database. #. :c:func:`hs_compile_multi`: compiles an array of expressions into a pattern database. All of the supplied patterns will be scanned for concurrently at scan time, with user-supplied identifiers returned when they match. #. :c:func:`hs_compile_ext_multi`: compiles an array of expressions as above, but allows :ref:`extparam` to be specified for each expression. Compilation allows the Hyperscan library to analyze the given pattern(s) and pre-determine how to scan for these patterns in an optimized fashion that would be far too expensive to compute at run-time. When compiling expressions, a decision needs to be made whether the resulting compiled patterns are to be used in a streaming, block or vectored mode: - **Streaming mode**: the target data to be scanned is a continuous stream, not all of which is available at once; blocks of data are scanned in sequence and matches may span multiple blocks in a stream. In streaming mode, each stream requires a block of memory to store its state between scan calls. - **Block mode**: the target data is a discrete, contiguous block which can be scanned in one call and does not require state to be retained. - **Vectored mode**: the target data consists of a list of non-contiguous blocks that are available all at once. As for block mode, no retention of state is required. To compile patterns to be used in streaming mode, the ``mode`` parameter of :c:func:`hs_compile` must be set to :c:member:`HS_MODE_STREAM`; similarly, block mode requires the use of :c:member:`HS_MODE_BLOCK` and vectored mode requires the use of :c:member:`HS_MODE_VECTORED`. A pattern database compiled for one mode (streaming, block or vectored) can only be used in that mode. The version of Hyperscan used to produce a compiled pattern database must match the version of Hyperscan used to scan with it. Hyperscan provides support for targeting a database at a particular CPU platform; see :ref:`instr_specialization` for details. *************** Pattern Support *************** Hyperscan supports the pattern syntax used by the PCRE library ("libpcre"), described at . However, not all constructs available in libpcre are supported. The use of unsupported constructs will result in compilation errors. The version of PCRE used to validate Hyperscan's interpretation of this syntax is 8.41. ==================== Supported Constructs ==================== The following regex constructs are supported by Hyperscan: * Literal characters and strings, with all libpcre quoting and character escapes. * Character classes such as :regexp:`.` (dot), :regexp:`[abc]`, and :regexp:`[^abc]`, as well as the predefined character classes :regexp:`\\s`, :regexp:`\\d`, :regexp:`\\w`, :regexp:`\\v`, and :regexp:`\\h` and their negated counterparts (:regexp:`\\S`, :regexp:`\\D`, :regexp:`\\W`, :regexp:`\\V`, and :regexp:`\\H`). * The POSIX named character classes :regexp:`[[:xxx:]]` and negated named character classes :regexp:`[[:^xxx:]]`. * Unicode character properties, such as :regexp:`\\p{L}`, :regexp:`\\P{Sc}`, :regexp:`\\p{Greek}`. * Quantifiers: * Quantifiers such as :regexp:`?`, :regexp:`*` and :regexp:`+` are supported when applied to arbitrary supported sub-expressions. * Bounded repeat qualifiers such as :regexp:`{n}`, :regexp:`{m,n}`, :regexp:`{n,}` are supported with limitations. * For arbitrary repeated sub-patterns: *n* and *m* should be either small or infinite, e.g. :regexp:`(a|b}{4}`, :regexp:`(ab?c?d){4,10}` or :regexp:`(ab(cd)*){6,}`. * For single-character width sub-patterns such as :regexp:`[^\\a]` or :regexp:`.` or :regexp:`x`, nearly all repeat counts are supported, except where repeats are extremely large (maximum bound greater than 32767). Stream states may be very large for large bounded repeats, e.g. :regexp:`a.{2000}b`. Note: such sub-patterns may be considerably cheaper if at the beginning or end of patterns and especially if the :c:member:`HS_FLAG_SINGLEMATCH` flag is on for that pattern. * Lazy modifiers (:regexp:`?` appended to another quantifier, e.g. :regexp:`\\w+?`) are supported but ignored (as Hyperscan reports all matches). * Parenthesization, including the named and unnamed capturing and non-capturing forms. However, capturing is ignored. * Alternation with the :regexp:`|` symbol, as in :regexp:`foo|bar`. * The anchors :regexp:`^`, :regexp:`$`, :regexp:`\\A`, :regexp:`\\Z` and :regexp:`\\z`. * Option modifiers: These allow behaviour to be switched on (with :regexp:`(?