summaryrefslogtreecommitdiff
path: root/wsutil/ws_mempbrk.h
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2015-02-12 09:07:02 +0100
committerPascal Quantin <pascal.quantin@gmail.com>2015-02-12 16:37:55 +0000
commitbdcac172eaa2ec4998c9f2775e691460b9b7a2d0 (patch)
treefce8f3fc4cee653f0edfe8ed93f1133474e66ea8 /wsutil/ws_mempbrk.h
parent678a9b6463b3661660da2e8a99781332c23cf78c (diff)
downloadwireshark-bdcac172eaa2ec4998c9f2775e691460b9b7a2d0.tar.gz
Fix crash at startup in SSE4.2 code when running a 32 bits Windows build
There is no guarantee that a g_malloc'ed memory block will be aligned on a 128 bits boundary Instead use a static variable definition (at the cost of exposing the HAVE_SSE4_2 compilation flag in ws_mempbrk.h) Change-Id: I661bf479a9d458d64c96bafc940c519d29a4780b Reviewed-on: https://code.wireshark.org/review/7070 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Diffstat (limited to 'wsutil/ws_mempbrk.h')
-rw-r--r--wsutil/ws_mempbrk.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/wsutil/ws_mempbrk.h b/wsutil/ws_mempbrk.h
index 708d53cfff..40c7e5595c 100644
--- a/wsutil/ws_mempbrk.h
+++ b/wsutil/ws_mempbrk.h
@@ -24,28 +24,30 @@
#include "ws_symbol_export.h"
+#ifdef HAVE_SSE4_2
+#include <emmintrin.h>
+#endif
+
/** The pattern object used for tvb_pbrk_pattern_guint8().
*/
typedef struct {
gchar patt[256];
+#ifdef HAVE_SSE4_2
gboolean use_sse42;
- void *mask;
+ __m128i mask;
+#endif
} tvb_pbrk_pattern;
-/** The value to use when initializing a tvb_pbrk_pattern variable.
- * For example:
- * static tvb_pbrk_pattern pbrk_mypattern = INIT_PBRK_PATTERN;
- */
-#define INIT_PBRK_PATTERN { { 0 }, FALSE, NULL }
-
/** Compile the pattern for the needles to find using tvb_pbrk_pattern_guint8().
*/
WS_DLL_PUBLIC void tvb_pbrk_compile(tvb_pbrk_pattern* pattern, const gchar *needles);
WS_DLL_PUBLIC const guint8 *tvb_pbrk_exec(const guint8* haystack, size_t haystacklen, const tvb_pbrk_pattern* pattern, guchar *found_needle);
+#ifdef HAVE_SSE4_2
void ws_mempbrk_sse42_compile(tvb_pbrk_pattern* pattern, const gchar *needles);
const char *ws_mempbrk_sse42_exec(const char* haystack, size_t haystacklen, const tvb_pbrk_pattern* pattern, guchar *found_needle);
+#endif
const guint8 *ws_mempbrk_exec(const guint8* haystack, size_t haystacklen, const tvb_pbrk_pattern* pattern, guchar *found_needle);