blob: e713665ab30e4281d6b4b8d633f9238fb92f42b5 [file] [log] [blame]
Brad Bishop8410d612019-11-25 09:40:59 -05001From 7b5dd67fee58f9f54c8a676abe2131776c0a3c52 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 20 Nov 2019 13:41:39 -0800
4Subject: [PATCH] Use __builtin_bswap32 on Clang if supported
5
6clang pretends to be gcc 4.2.1 so GCC_VERSION macro will decide that
7__builtin_bswap32 is not supported on clang, whereas in reality it might
8so its better to add a check for enquiring clang if it supports
9__builtin_bswap32 or not
10
11Upstream-Status: Submitted [https://github.com/smuellerDD/libkcapi/pull/83]
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13---
14 lib/kcapi-kdf.c | 6 +++++-
15 1 file changed, 5 insertions(+), 1 deletion(-)
16
17diff --git a/lib/kcapi-kdf.c b/lib/kcapi-kdf.c
18index 9e53a0b..f32fbe9 100644
19--- a/lib/kcapi-kdf.c
20+++ b/lib/kcapi-kdf.c
21@@ -54,10 +54,14 @@
22 #include "kcapi.h"
23 #include "internal.h"
24
25+#ifndef __has_builtin
26+# define __has_builtin(x) 0
27+#endif
28+
29 #define GCC_VERSION (__GNUC__ * 10000 \
30 + __GNUC_MINOR__ * 100 \
31 + __GNUC_PATCHLEVEL__)
32-#if GCC_VERSION >= 40400
33+#if GCC_VERSION >= 40400 || (defined(__clang__) && __has_builtin(__builtin_bswap32))
34 # define __HAVE_BUILTIN_BSWAP32__
35 #endif
36
37--
382.24.0
39