From fcb019acb8932855d51b0facc45aa3e855fe8524 Mon Sep 17 00:00:00 2001 From: AndersBroman Date: Tue, 10 Jun 2014 14:47:09 +0200 Subject: [PATCH] Change HAVE_SSE42 to HAVE_SSE4_2 add $(SIMD_FLAGS) Add autotools macros to distribution Call AX_EXT to define HAVE_SSE4_2 Change-Id: I9ff085d923dfafb32510cdd14290e74a2aaea302 Reviewed-on: https://code.wireshark.org/review/2110 Tested-by: Anders Broman Reviewed-by: Jeff Morriss Reviewed-by: Anders Broman --- Makefile.am | 4 ++++ config.h.win32 | 2 +- configure.ac | 6 ++++++ wsutil/Makefile.am | 2 +- wsutil/ws_mempbrk.c | 6 +++--- wsutil/ws_mempbrk.h | 2 +- wsutil/ws_mempbrk_sse42.c | 4 ++-- 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Makefile.am b/Makefile.am index c6da3d1d32..5da8d50fd4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -709,6 +709,10 @@ EXTRA_DIST = \ aclocal-fallback/glib-2.0.m4 \ aclocal-fallback/gtk-2.0.m4 \ aclocal-fallback/gtk-3.0.m4 \ + aclocal-fallback/ax_check_compile_flag.m4 \ + aclocal-fallback/ax_gcc_x86_cpuid.m4 \ + aclocal-fallback/ax_ext.m4 \ + aclocal-fallback/ax_gcc_x86_avx_xgetbv.m4 \ aclocal-flags \ adns_dll.dep \ adns_dll.rc \ diff --git a/config.h.win32 b/config.h.win32 index 2b7249be09..d0b370f225 100644 --- a/config.h.win32 +++ b/config.h.win32 @@ -283,4 +283,4 @@ typedef int ssize_t; #endif /* to use define _ws_mempbrk_sse42 if available (checked with cpuinfo) */ -#define HAVE_SSE42 1 \ No newline at end of file +#define HAVE_SSE4_2 1 \ No newline at end of file diff --git a/configure.ac b/configure.ac index d17b28f210..e5a806fe0b 100644 --- a/configure.ac +++ b/configure.ac @@ -60,6 +60,12 @@ AC_PROG_CPP AC_PROG_MKDIR_P AC_WIRESHARK_CLANG_CHECK +# Find supported SIMD extensions by requesting cpuid. When an SIMD +# extension is found, the -m"simdextensionname" is added to SIMD_FLAGS +# (only if compilator support it) (ie : if "sse2" is available "-msse2" is +# added to SIMD_FLAGS) +AX_EXT + dnl Work around libtool bug (fixed in the version 1.5a?) AC_DEFUN([AC_PROVIDE_AC_LIBTOOL_DLOPEN], ) AC_LIBTOOL_DLOPEN diff --git a/wsutil/Makefile.am b/wsutil/Makefile.am index 98273637f0..868f9d79a8 100644 --- a/wsutil/Makefile.am +++ b/wsutil/Makefile.am @@ -83,7 +83,7 @@ libwsutil_la_SOURCES = \ libwsutil_sse42_la_SOURCES = \ ws_mempbrk_sse42.c -libwsutil_sse42_la_CFLAGS = $(AM_CFLAGS) -msse4.2 +libwsutil_sse42_la_CFLAGS = $(AM_CFLAGS) $(SIMD_FLAGS) EXTRA_libwsutil_la_SOURCES= \ inet_aton.c \ diff --git a/wsutil/ws_mempbrk.c b/wsutil/ws_mempbrk.c index c167166689..c24cedb404 100644 --- a/wsutil/ws_mempbrk.c +++ b/wsutil/ws_mempbrk.c @@ -23,7 +23,7 @@ #include #include "ws_symbol_export.h" -#ifdef HAVE_SSE42 +#ifdef HAVE_SSE4_2 #include "ws_cpuid.h" #endif #include "ws_mempbrk.h" @@ -50,13 +50,13 @@ _ws_mempbrk(const guint8* haystack, size_t haystacklen, const guint8 *needles) WS_DLL_PUBLIC const guint8 * ws_mempbrk(const guint8* haystack, size_t haystacklen, const guint8 *needles) { -#ifdef HAVE_SSE42 +#ifdef HAVE_SSE4_2 static int have_sse42 = -1; #endif if (*needles == 0) return NULL; -#ifdef HAVE_SSE42 +#ifdef HAVE_SSE4_2 if G_UNLIKELY(have_sse42 < 0) have_sse42 = ws_cpuid_sse42(); diff --git a/wsutil/ws_mempbrk.h b/wsutil/ws_mempbrk.h index 5f515321fd..72f37d574a 100644 --- a/wsutil/ws_mempbrk.h +++ b/wsutil/ws_mempbrk.h @@ -26,7 +26,7 @@ WS_DLL_PUBLIC const guint8 *ws_mempbrk(const guint8* haystack, size_t haystacklen, const guint8 *needles); -#ifdef HAVE_SSE42 +#ifdef HAVE_SSE4_2 const char *_ws_mempbrk_sse42(const char* haystack, size_t haystacklen, const char *needles); #endif diff --git a/wsutil/ws_mempbrk_sse42.c b/wsutil/ws_mempbrk_sse42.c index ac9ecd281c..07c6504f55 100644 --- a/wsutil/ws_mempbrk_sse42.c +++ b/wsutil/ws_mempbrk_sse42.c @@ -20,7 +20,7 @@ #include "config.h" -#ifdef HAVE_SSE42 +#ifdef HAVE_SSE4_2 #include @@ -191,7 +191,7 @@ _ws_mempbrk_sse42(const char *s, size_t slen, const char *a) return _ws_mempbrk(aligned, slen, a); } -#endif /* HAVE_SSE42 */ +#endif /* HAVE_SSE4_2 */ /* * Editor modelines *