From b9a3b070d3bb7731e2aad8a448e6e7f3938dcdf3 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Sat, 29 Apr 2017 18:54:29 +0200 Subject: [PATCH] Don't check unaligned access in ubsan for GCC. --- libarchive/xxhash.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libarchive/xxhash.c b/libarchive/xxhash.c index 6f5ba52fa..70750bae0 100644 --- a/libarchive/xxhash.c +++ b/libarchive/xxhash.c @@ -141,13 +141,19 @@ typedef struct _U32_S { U32 v; } _PACKED U32_S; # pragma pack(pop) #endif -#define A32(x) (((const U32_S *)(x))->v) - /**************************************** ** Compiler-specific Functions and Macros *****************************************/ -#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) +#define GCC_VERSION ((__GNUC__-0) * 100 + (__GNUC_MINOR__ - 0)) + +#if GCC_VERSION >= 409 +__attribute__((__no_sanitize_undefined__)) +#endif +static inline U32 A32(const void * x) +{ + return (((const U32_S *)(x))->v); +} /* Note : although _rotl exists for minGW (GCC under windows), performance seems poor */ #if defined(_MSC_VER) -- 2.47.3