Skip to content

Commit

Permalink
wolfssl/wolfcrypt/types.h: dial in the __static_assert() gating+defin…
Browse files Browse the repository at this point in the history
…itions, and add static_assert2().
  • Loading branch information
douzzer committed Sep 19, 2024
1 parent fbbb2b8 commit 510d6a0
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions wolfssl/wolfcrypt/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1696,20 +1696,32 @@ typedef struct w64wrapper {

#define WC_CPP_CAT_(a, b) a ## b
#define WC_CPP_CAT(a, b) WC_CPP_CAT_(a, b)
#ifndef static_assert
#if !defined(__cplusplus) && !defined(__STRICT_ANSI__) && \
!defined(WOLF_C89) && ((defined(__GNUC__) && \
__GNUC__ >= 5) || defined(__clang__))
#define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
#define static_assert(expr, ...) \
__static_assert(expr, ##__VA_ARGS__, #expr)
#elif defined(__STRICT_ANSI__) || defined(WOLF_C89)
#define static_assert(expr) \
struct WC_CPP_CAT(dummy_struct_, __LINE__)
#if defined(__cplusplus) && (__cplusplus >= 201103L)
#ifndef static_assert2
#define static_assert2 static_assert
#endif
#elif !defined(static_assert)
#if !defined(__cplusplus) && \
!defined(__STRICT_ANSI__) && \
!defined(WOLF_C89) && \
defined(__STDC_VERSION__) && \
(__STDC_VERSION__ >= 201112L) && \
((defined(__GNUC__) && \
(__GNUC__ >= 5)) || \
defined(__clang__))
#define static_assert(expr) _Static_assert(expr, #expr)
#ifndef static_assert2
#define static_assert2(expr, msg) _Static_assert(expr, msg)
#endif
#else
#define static_assert(...) \
#define static_assert(expr) \
struct WC_CPP_CAT(wc_dummy_struct_L, __LINE__)
#ifndef static_assert2
#define static_assert2(expr, msg) static_assert(expr)
#endif
#endif
#elif !defined(static_assert2)
#define static_assert2(expr, msg) static_assert(expr)
#endif

#ifndef SAVE_VECTOR_REGISTERS
Expand Down

0 comments on commit 510d6a0

Please sign in to comment.