summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorTom Cosgrove <tom.cosgrove@arm.com>2023-09-01 08:41:11 +0100
committerPauli <pauli@openssl.org>2023-09-04 08:44:21 +1000
commit12d08fe3a50f28fe80ff591e05d7f8253148afb4 (patch)
tree67a4ba063a353d5ea8bc4d903d36566c631bbaff /include
parent5318c012885a5382eadbf95aa9c1d35664bca819 (diff)
Move ALIGN32 and ALIGN64 into common.h, and fix for clang-cl.exe
clang-cl.exe defines __clang__ and _MSC_VER but not __GNUC__, so a clang- specific guard is needed to get the correct ALIGNxx versions. Fixes #21914 Change-Id: Icdc047b182ad1ba61c7b1b06a1e951eda1a0c33d Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21921)
Diffstat (limited to 'include')
-rw-r--r--include/internal/common.h35
1 files changed, 23 insertions, 12 deletions
diff --git a/include/internal/common.h b/include/internal/common.h
index 204e7c3eec..ce4a4e3086 100644
--- a/include/internal/common.h
+++ b/include/internal/common.h
@@ -18,17 +18,28 @@
# include "internal/e_os.h" /* ossl_inline in many files */
# include "internal/nelem.h"
-#if defined(__GNUC__) || defined(__clang__)
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else
- #define likely(x) x
- #define unlikely(x) x
-#endif
+# if defined(__GNUC__) || defined(__clang__)
+# define likely(x) __builtin_expect(!!(x), 1)
+# define unlikely(x) __builtin_expect(!!(x), 0)
+# else
+# define likely(x) x
+# define unlikely(x) x
+# endif
-#ifdef NDEBUG
-# define ossl_assert(x) ((x) != 0)
-#else
+# if defined(__GNUC__) || defined(__clang__)
+# define ALIGN32 __attribute((aligned(32)))
+# define ALIGN64 __attribute((aligned(64)))
+# elif defined(_MSC_VER)
+# define ALIGN32 __declspec(align(32))
+# define ALIGN64 __declspec(align(64))
+# else
+# define ALIGN32
+# define ALIGN64
+# endif
+
+# ifdef NDEBUG
+# define ossl_assert(x) ((x) != 0)
+# else
__owur static ossl_inline int ossl_assert_int(int expr, const char *exprstr,
const char *file, int line)
{
@@ -38,10 +49,10 @@ __owur static ossl_inline int ossl_assert_int(int expr, const char *exprstr,
return expr;
}
-# define ossl_assert(x) ossl_assert_int((x) != 0, "Assertion failed: "#x, \
+# define ossl_assert(x) ossl_assert_int((x) != 0, "Assertion failed: "#x, \
__FILE__, __LINE__)
-#endif
+# endif
/* Check if |pre|, which must be a string literal, is a prefix of |str| */
#define HAS_PREFIX(str, pre) (strncmp(str, pre "", sizeof(pre) - 1) == 0)