Skip to content

Commit 3d8f25a

Browse files
authored
Merge pull request #5430 from dgarske/sniffer_multithread
Support for multi-threaded sniffer
2 parents 3fd2292 + 6be0512 commit 3d8f25a

10 files changed

Lines changed: 797 additions & 232 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ check_function_exists("inet_ntoa" HAVE_INET_NTOA)
103103
check_function_exists("memset" HAVE_MEMSET)
104104
check_function_exists("socket" HAVE_SOCKET)
105105
check_function_exists("strftime" HAVE_STRFTIME)
106+
check_function_exists("__atomic_fetch_add" HAVE_C___ATOMIC)
106107

107108
include(CheckTypeSize)
108109

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ EXTRA_DIST+= LPCExpresso.cproject
153153
EXTRA_DIST+= LPCExpresso.project
154154
EXTRA_DIST+= resource.h wolfssl.rc
155155
EXTRA_DIST+= CMakeLists.txt
156+
EXTRA_DIST+= m4/ax_atomic.m4
156157

157158
include cmake/include.am
158159
include wrapper/include.am

configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,13 @@ fi
100100
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stddef.h time.h sys/ioctl.h sys/socket.h sys/time.h errno.h sys/un.h])
101101
AC_CHECK_LIB([network],[socket])
102102
AC_C_BIGENDIAN
103+
AC_C___ATOMIC
103104

104105
# check if functions of interest are linkable, but also check if
105106
# they're declared by the expected headers, and if not, supersede the
106107
# unusable positive from AC_CHECK_FUNCS().
107108
AC_CHECK_FUNCS([gethostbyname getaddrinfo gettimeofday gmtime_r gmtime_s inet_ntoa memset socket strftime atexit])
108-
AC_CHECK_DECLS([gethostbyname, getaddrinfo, gettimeofday, gmtime_r, gmtime_s, inet_ntoa, memset, socket, strftime], [], [
109+
AC_CHECK_DECLS([gethostbyname, getaddrinfo, gettimeofday, gmtime_r, gmtime_s, inet_ntoa, memset, socket, strftime, atexit], [], [
109110
if test "$(eval echo \$"$(eval 'echo ac_cv_func_${as_decl_name}')")" = "yes"
110111
then
111112
AC_MSG_NOTICE([ note: earlier check for $(eval 'echo ${as_decl_name}') superseded.])

m4/ax_atomic.m4

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# AC_C___ATOMIC
2+
# -------------
3+
# Define HAVE_C___ATOMIC if __atomic works.
4+
AN_IDENTIFIER([__atomic], [AC_C___ATOMIC])
5+
AC_DEFUN([AC_C___ATOMIC],
6+
[AC_CACHE_CHECK([for __atomic], ac_cv_c___atomic,
7+
[AC_LINK_IFELSE(
8+
[AC_LANG_SOURCE(
9+
[[int
10+
main (int argc, char **argv)
11+
{
12+
volatile unsigned long ul1 = 1, ul2 = 0, ul3 = 2;
13+
__atomic_load_n(&ul1, __ATOMIC_SEQ_CST);
14+
__atomic_compare_exchange(&ul1, &ul2, &ul3, 1, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
15+
__atomic_fetch_add(&ul1, 1, __ATOMIC_SEQ_CST);
16+
__atomic_fetch_sub(&ul3, 1, __ATOMIC_SEQ_CST);
17+
__atomic_or_fetch(&ul1, ul2, __ATOMIC_SEQ_CST);
18+
__atomic_and_fetch(&ul1, ul2, __ATOMIC_SEQ_CST);
19+
volatile unsigned long long ull1 = 1, ull2 = 0, ull3 = 2;
20+
__atomic_load_n(&ull1, __ATOMIC_SEQ_CST);
21+
__atomic_compare_exchange(&ull1, &ull2, &ull3, 1, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
22+
__atomic_fetch_add(&ull1, 1, __ATOMIC_SEQ_CST);
23+
__atomic_fetch_sub(&ull3, 1, __ATOMIC_SEQ_CST);
24+
__atomic_or_fetch(&ull1, ull2, __ATOMIC_SEQ_CST);
25+
__atomic_and_fetch(&ull1, ull2, __ATOMIC_SEQ_CST);
26+
return 0;
27+
}
28+
]])],
29+
[ac_cv_c___atomic=yes],
30+
[ac_cv_c___atomic=no])])
31+
if test $ac_cv_c___atomic = yes; then
32+
AC_DEFINE([HAVE_C___ATOMIC], 1,
33+
[Define to 1 if __atomic operations work.])
34+
fi
35+
])# AC_C___ATOMIC

0 commit comments

Comments
 (0)