Skip to content

Commit 2060dd3

Browse files
committed
Merge branch develop to master
2 parents 6f81516 + da4a2bd commit 2060dd3

File tree

138 files changed

+11644
-719
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+11644
-719
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
This is a list of notable changes to Hyperscan, in reverse chronological order.
44

5+
## [5.0.0] 2018-07-09
6+
- Introduce chimera hybrid engine of Hyperscan and PCRE, to fully support
7+
PCRE syntax as well as to take advantage of the high performance nature of
8+
Hyperscan.
9+
- New API feature: logical combinations (AND, OR and NOT) of patterns in a
10+
given pattern set.
11+
- Windows porting: hsbench, hscheck, hscollider and hsdump tools now available
12+
on Windows 8 or newer.
13+
- Improve undirected graph implementation to avoid graph copy and reduce
14+
compile time.
15+
- Bugfix for issue #86: enable hscollider for installed PCRE package.
16+
517
## [4.7.0] 2018-01-24
618
- Introduced hscollider pattern testing tool, for validating Hyperscan match
719
behaviour against PCRE.

CMakeLists.txt

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
cmake_minimum_required (VERSION 2.8.11)
22
project (hyperscan C CXX)
33

4-
set (HS_MAJOR_VERSION 4)
5-
set (HS_MINOR_VERSION 7)
4+
set (HS_MAJOR_VERSION 5)
5+
set (HS_MINOR_VERSION 0)
66
set (HS_PATCH_VERSION 0)
77
set (HS_VERSION ${HS_MAJOR_VERSION}.${HS_MINOR_VERSION}.${HS_PATCH_VERSION})
88

@@ -154,7 +154,7 @@ if(MSVC OR MSVC_IDE)
154154
# todo: change these as required
155155
set(ARCH_C_FLAGS "/arch:AVX2")
156156
set(ARCH_CXX_FLAGS "/arch:AVX2")
157-
set(MSVC_WARNS "/wd4101 /wd4146 /wd4172 /wd4200 /wd4244 /wd4267 /wd4307 /wd4334 /wd4805 -D_CRT_SECURE_NO_WARNINGS")
157+
set(MSVC_WARNS "/wd4101 /wd4146 /wd4172 /wd4200 /wd4244 /wd4267 /wd4307 /wd4334 /wd4805 /wd4996 -D_CRT_SECURE_NO_WARNINGS")
158158
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /O2 ${MSVC_WARNS}")
159159
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 ${MSVC_WARNS} /wd4800 -DBOOST_DETAIL_NO_CONTAINER_FWD")
160160
endif()
@@ -446,11 +446,32 @@ else()
446446
endif()
447447

448448
add_subdirectory(util)
449-
add_subdirectory(unit)
450449
add_subdirectory(doc/dev-reference)
450+
451+
if (NOT WIN32)
452+
# PCRE check, we have a fixed requirement for PCRE to use Chimera
453+
# and hscollider
454+
set(PCRE_REQUIRED_MAJOR_VERSION 8)
455+
set(PCRE_REQUIRED_MINOR_VERSION 41)
456+
set(PCRE_REQUIRED_VERSION ${PCRE_REQUIRED_MAJOR_VERSION}.${PCRE_REQUIRED_MINOR_VERSION})
457+
include (${CMAKE_MODULE_PATH}/pcre.cmake)
458+
if (NOT CORRECT_PCRE_VERSION)
459+
message(STATUS "PCRE ${PCRE_REQUIRED_VERSION} not found")
460+
endif()
461+
462+
# we need static libs for Chimera - too much deep magic for shared libs
463+
if (CORRECT_PCRE_VERSION AND PCRE_BUILD_SOURCE AND BUILD_STATIC_LIBS)
464+
set(BUILD_CHIMERA TRUE)
465+
endif()
466+
467+
add_subdirectory(unit)
451468
if (EXISTS ${CMAKE_SOURCE_DIR}/tools/CMakeLists.txt)
452469
add_subdirectory(tools)
453470
endif()
471+
if (EXISTS ${CMAKE_SOURCE_DIR}/chimera/CMakeLists.txt AND BUILD_CHIMERA)
472+
add_subdirectory(chimera)
473+
endif()
474+
endif()
454475

455476
# do substitutions
456477
configure_file(${CMAKE_MODULE_PATH}/config.h.in ${PROJECT_BINARY_DIR}/config.h)
@@ -479,6 +500,31 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS}")
479500
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS}")
480501
endif()
481502

503+
if (WIN32)
504+
# PCRE check, we have a fixed requirement for PCRE to use Chimera
505+
# and hscollider
506+
set(PCRE_REQUIRED_MAJOR_VERSION 8)
507+
set(PCRE_REQUIRED_MINOR_VERSION 41)
508+
set(PCRE_REQUIRED_VERSION ${PCRE_REQUIRED_MAJOR_VERSION}.${PCRE_REQUIRED_MINOR_VERSION})
509+
include (${CMAKE_MODULE_PATH}/pcre.cmake)
510+
if (NOT CORRECT_PCRE_VERSION)
511+
message(STATUS "PCRE ${PCRE_REQUIRED_VERSION} not found")
512+
endif()
513+
514+
# we need static libs for Chimera - too much deep magic for shared libs
515+
if (CORRECT_PCRE_VERSION AND PCRE_BUILD_SOURCE AND BUILD_STATIC_LIBS)
516+
set(BUILD_CHIMERA TRUE)
517+
endif()
518+
519+
add_subdirectory(unit)
520+
if (EXISTS ${CMAKE_SOURCE_DIR}/tools/CMakeLists.txt)
521+
add_subdirectory(tools)
522+
endif()
523+
if (EXISTS ${CMAKE_SOURCE_DIR}/chimera/CMakeLists.txt AND BUILD_CHIMERA)
524+
add_subdirectory(chimera)
525+
endif()
526+
endif()
527+
482528
if(NOT WIN32)
483529
set(RAGEL_C_FLAGS "-Wno-unused")
484530
endif()
@@ -860,7 +906,6 @@ SET (hs_compile_SRCS
860906
src/nfagraph/ng_stop.h
861907
src/nfagraph/ng_uncalc_components.cpp
862908
src/nfagraph/ng_uncalc_components.h
863-
src/nfagraph/ng_undirected.h
864909
src/nfagraph/ng_utf8.cpp
865910
src/nfagraph/ng_utf8.h
866911
src/nfagraph/ng_util.cpp
@@ -915,6 +960,8 @@ SET (hs_compile_SRCS
915960
src/parser/check_refs.h
916961
src/parser/control_verbs.cpp
917962
src/parser/control_verbs.h
963+
src/parser/logical_combination.cpp
964+
src/parser/logical_combination.h
918965
src/parser/parse_error.cpp
919966
src/parser/parse_error.h
920967
src/parser/parser_util.cpp
@@ -1014,6 +1061,7 @@ SET (hs_compile_SRCS
10141061
src/util/graph.h
10151062
src/util/graph_range.h
10161063
src/util/graph_small_color_map.h
1064+
src/util/graph_undirected.h
10171065
src/util/hash.h
10181066
src/util/hash_dynamic_bitset.h
10191067
src/util/insertion_ordered.h

chimera/CMakeLists.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Chimera lib
2+
3+
include_directories(${PCRE_INCLUDE_DIRS})
4+
5+
# only set these after all tests are done
6+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS}")
7+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS}")
8+
9+
SET(chimera_HEADERS
10+
ch.h
11+
ch_common.h
12+
ch_compile.h
13+
ch_runtime.h
14+
)
15+
install(FILES ${chimera_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/hs")
16+
17+
SET(chimera_SRCS
18+
${chimera_HEADERS}
19+
ch_alloc.c
20+
ch_alloc.h
21+
ch_compile.cpp
22+
ch_database.c
23+
ch_database.h
24+
ch_internal.h
25+
ch_runtime.c
26+
ch_scratch.h
27+
ch_scratch.c
28+
)
29+
30+
add_library(chimera STATIC ${chimera_SRCS})
31+
add_dependencies(chimera hs pcre)
32+
target_link_libraries(chimera hs pcre)
33+
34+
install(TARGETS chimera DESTINATION ${CMAKE_INSTALL_LIBDIR})
35+
36+
if (NOT WIN32)
37+
# expand out library names for pkgconfig static link info
38+
foreach (LIB ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES})
39+
# this is fragile, but protects us from toolchain specific files
40+
if (NOT EXISTS ${LIB})
41+
set(PRIVATE_LIBS "${PRIVATE_LIBS} -l${LIB}")
42+
endif()
43+
endforeach()
44+
set(PRIVATE_LIBS "${PRIVATE_LIBS} -L${LIBDIR} -lpcre")
45+
46+
configure_file(libch.pc.in libch.pc @ONLY) # only replace @ quoted vars
47+
install(FILES ${CMAKE_BINARY_DIR}/chimera/libch.pc
48+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
49+
endif()

chimera/ch.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2018, Intel Corporation
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions are met:
6+
*
7+
* * Redistributions of source code must retain the above copyright notice,
8+
* this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of Intel Corporation nor the names of its contributors
13+
* may be used to endorse or promote products derived from this software
14+
* without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
29+
#ifndef CH_H_
30+
#define CH_H_
31+
32+
/**
33+
* @file
34+
* @brief The complete Chimera API definition.
35+
*
36+
* Chimera is a hybrid solution of Hyperscan and PCRE.
37+
*
38+
* This header includes both the Chimera compiler and runtime components. See
39+
* the individual component headers for documentation.
40+
*/
41+
42+
#include "ch_compile.h"
43+
#include "ch_runtime.h"
44+
45+
#endif /* CH_H_ */

chimera/ch_alloc.c

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* Copyright (c) 2018, Intel Corporation
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions are met:
6+
*
7+
* * Redistributions of source code must retain the above copyright notice,
8+
* this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of Intel Corporation nor the names of its contributors
13+
* may be used to endorse or promote products derived from this software
14+
* without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
29+
/** \file
30+
* \brief Runtime functions for setting custom allocators.
31+
*/
32+
33+
#include "ch.h"
34+
#include "ch_common.h"
35+
#include "ch_internal.h"
36+
#include "hs.h"
37+
#include "ue2common.h"
38+
39+
#define default_malloc malloc
40+
#define default_free free
41+
42+
ch_alloc_t ch_database_alloc = default_malloc;
43+
ch_alloc_t ch_misc_alloc = default_malloc;
44+
ch_alloc_t ch_scratch_alloc = default_malloc;
45+
46+
ch_free_t ch_database_free = default_free;
47+
ch_free_t ch_misc_free = default_free;
48+
ch_free_t ch_scratch_free = default_free;
49+
50+
static
51+
ch_alloc_t normalise_alloc(ch_alloc_t a) {
52+
if (!a) {
53+
return default_malloc;
54+
} else {
55+
return a;
56+
}
57+
}
58+
59+
static
60+
ch_free_t normalise_free(ch_free_t f) {
61+
if (!f) {
62+
return default_free;
63+
} else {
64+
return f;
65+
}
66+
}
67+
68+
HS_PUBLIC_API
69+
ch_error_t HS_CDECL ch_set_allocator(ch_alloc_t allocfunc,
70+
ch_free_t freefunc) {
71+
ch_set_database_allocator(allocfunc, freefunc);
72+
ch_set_misc_allocator(allocfunc, freefunc);
73+
ch_set_scratch_allocator(allocfunc, freefunc);
74+
75+
// Set core Hyperscan alloc/free.
76+
hs_error_t ret = hs_set_allocator(allocfunc, freefunc);
77+
78+
return ret;
79+
}
80+
81+
HS_PUBLIC_API
82+
ch_error_t HS_CDECL ch_set_database_allocator(ch_alloc_t allocfunc,
83+
ch_free_t freefunc) {
84+
ch_database_alloc = normalise_alloc(allocfunc);
85+
ch_database_free = normalise_free(freefunc);
86+
87+
// Set Hyperscan database alloc/free.
88+
return hs_set_database_allocator(allocfunc, freefunc);
89+
}
90+
91+
HS_PUBLIC_API
92+
ch_error_t HS_CDECL ch_set_misc_allocator(ch_alloc_t allocfunc,
93+
ch_free_t freefunc) {
94+
ch_misc_alloc = normalise_alloc(allocfunc);
95+
ch_misc_free = normalise_free(freefunc);
96+
97+
// Set Hyperscan misc alloc/free.
98+
return hs_set_misc_allocator(allocfunc, freefunc);
99+
}
100+
101+
HS_PUBLIC_API
102+
ch_error_t HS_CDECL ch_set_scratch_allocator(ch_alloc_t allocfunc,
103+
ch_free_t freefunc) {
104+
ch_scratch_alloc = normalise_alloc(allocfunc);
105+
ch_scratch_free = normalise_free(freefunc);
106+
107+
// Set Hyperscan scratch alloc/free.
108+
return hs_set_scratch_allocator(allocfunc, freefunc);
109+
}

0 commit comments

Comments
 (0)