Initial commit of Hyperscan

This commit is contained in:
Matthew Barr
2015-10-20 09:13:35 +11:00
commit 904e436f11
610 changed files with 213627 additions and 0 deletions

54
cmake/backtrace.cmake Normal file
View File

@@ -0,0 +1,54 @@
# The `backtrace' function is available on Linux via glibc, and on FreeBSD if
# the 'libexecinfo' package is installed.
CHECK_C_SOURCE_COMPILES(
"#include <stdlib.h>\n#include <execinfo.h>\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 <stdlib.h>\n#include <execinfo.h>\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 <stdlib.h>\n#include <execinfo.h>\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()
# cmake scope fun
set(HAVE_BACKTRACE ${HAVE_BACKTRACE} PARENT_SCOPE)
else()
set(BACKTRACE_CFLAGS "")
set(BACKTRACE_LDFLAGS "")
endif()

101
cmake/config.h.in Normal file
View File

@@ -0,0 +1,101 @@
/* used by cmake */
/* "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
/* Build tools with threading support */
#cmakedefine ENABLE_TOOLS_THREADS
/* 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_barrier_init', and to 0
if you don't. */
#cmakedefine HAVE_DECL_PTHREAD_BARRIER_INIT
/* 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
/* 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 <pthread.h> header file. */
#cmakedefine HAVE_PTHREAD_H
/* 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 <tmmintrin.h> header file. */
#cmakedefine HAVE_TMMINTRIN_H
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H
/* Define to 1 if you have the `_aligned_malloc' function. */
#cmakedefine HAVE__ALIGNED_MALLOC
/* 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

9
cmake/platform.cmake Normal file
View File

@@ -0,0 +1,9 @@
# 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})

16
cmake/ragel.cmake Normal file
View File

@@ -0,0 +1,16 @@
# 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)