forked from wolfSSL/wolfssl
peer review: refactor HAVE_ANONYMOUS_INLINE_AGGREGATES and HAVE_EMPTY_AGGREGATES to conform to wolfssl convention -- defined() for true, !defined() for false -- while retaining ability for user override-off by passing in explicit 0 definition.
This commit is contained in:
@@ -104,12 +104,12 @@ enum wc_CryptoCbCmdType {
|
||||
/* Crypto Information Structure for callbacks */
|
||||
typedef struct wc_CryptoInfo {
|
||||
int algo_type; /* enum wc_AlgoType */
|
||||
#if HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
#ifdef HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
union {
|
||||
#endif
|
||||
struct {
|
||||
int type; /* enum wc_PkType */
|
||||
#if HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
#ifdef HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
union {
|
||||
#endif
|
||||
#ifndef NO_RSA
|
||||
@@ -279,7 +279,7 @@ typedef struct wc_CryptoInfo {
|
||||
int type; /* enum wc_PqcSignatureType */
|
||||
} pqc_sig_check;
|
||||
#endif
|
||||
#if HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
#ifdef HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
};
|
||||
#endif
|
||||
} pk;
|
||||
@@ -287,7 +287,7 @@ typedef struct wc_CryptoInfo {
|
||||
struct {
|
||||
int type; /* enum wc_CipherType */
|
||||
int enc;
|
||||
#if HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
#ifdef HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
union {
|
||||
#endif
|
||||
#ifdef HAVE_AESGCM
|
||||
@@ -375,7 +375,7 @@ typedef struct wc_CryptoInfo {
|
||||
} des3;
|
||||
#endif
|
||||
void* ctx;
|
||||
#if HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
#ifdef HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
};
|
||||
#endif
|
||||
} cipher;
|
||||
@@ -387,7 +387,7 @@ typedef struct wc_CryptoInfo {
|
||||
const byte* in;
|
||||
word32 inSz;
|
||||
byte* digest;
|
||||
#if HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
#ifdef HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
union {
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
@@ -409,7 +409,7 @@ typedef struct wc_CryptoInfo {
|
||||
wc_Sha3* sha3;
|
||||
#endif
|
||||
void* ctx;
|
||||
#if HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
#ifdef HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
};
|
||||
#endif
|
||||
} hash;
|
||||
@@ -454,7 +454,7 @@ typedef struct wc_CryptoInfo {
|
||||
void *ctx;
|
||||
} cmd;
|
||||
#endif
|
||||
#if HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
#ifdef HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
};
|
||||
#endif
|
||||
} wc_CryptoInfo;
|
||||
|
@@ -123,36 +123,49 @@ decouple library dependencies with standard string, memory and so on.
|
||||
|
||||
#ifndef HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
/* if a version is available, pivot on the version, otherwise guess it's
|
||||
* allowed, subject to override.
|
||||
* disallowed, subject to override.
|
||||
*/
|
||||
#if !defined(WOLF_C89) && (!defined(__STDC__) \
|
||||
|| (!defined(__STDC_VERSION__) && !defined(__cplusplus)) \
|
||||
|| (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201101L)) \
|
||||
|| (defined(__cplusplus) && (__cplusplus >= 201103L)))
|
||||
#define HAVE_ANONYMOUS_INLINE_AGGREGATES 1
|
||||
#else
|
||||
#define HAVE_ANONYMOUS_INLINE_AGGREGATES 0
|
||||
#endif
|
||||
#elif ~(~HAVE_ANONYMOUS_INLINE_AGGREGATES + 1) == 1
|
||||
/* forced on with empty value -- remap to 1 */
|
||||
#undef HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
#define HAVE_ANONYMOUS_INLINE_AGGREGATES 1
|
||||
#elif HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
/* forced on with explicit nonzero value -- leave as-is. */
|
||||
#else
|
||||
/* forced off with explicit zero value -- remap to undef. */
|
||||
#undef HAVE_ANONYMOUS_INLINE_AGGREGATES
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_EMPTY_AGGREGATES
|
||||
/* The C standards don't define empty aggregates, but gcc and clang do.
|
||||
* We need to accommodate them for one of the same reasons C++ does --
|
||||
* templates that conditionally result in empty aggregates, e.g. in
|
||||
* hash.h.
|
||||
* conditionally empty aggregates, e.g. in hash.h.
|
||||
*/
|
||||
#if !defined(WOLF_C89) && defined(__GNUC__) && \
|
||||
!defined(__STRICT_ANSI__) && \
|
||||
HAVE_ANONYMOUS_INLINE_AGGREGATES + 0 == 1
|
||||
defined(HAVE_ANONYMOUS_INLINE_AGGREGATES)
|
||||
#define HAVE_EMPTY_AGGREGATES 1
|
||||
#else
|
||||
#define HAVE_EMPTY_AGGREGATES 0
|
||||
#endif
|
||||
#elif ~(~HAVE_EMPTY_AGGREGATES + 1) == 1
|
||||
/* forced on with empty value -- remap to 1 */
|
||||
#undef HAVE_EMPTY_AGGREGATES
|
||||
#define HAVE_EMPTY_AGGREGATES 1
|
||||
#elif HAVE_EMPTY_AGGREGATES
|
||||
/* forced on with explicit nonzero value -- leave as-is. */
|
||||
#else
|
||||
/* forced off with explicit zero value -- remap to undef. */
|
||||
#undef HAVE_EMPTY_AGGREGATES
|
||||
#endif
|
||||
|
||||
#define _WOLF_AGG_DUMMY_MEMBER_HELPER2(a, b, c) a ## b ## c
|
||||
#define _WOLF_AGG_DUMMY_MEMBER_HELPER(a, b, c) _WOLF_AGG_DUMMY_MEMBER_HELPER2(a, b, c)
|
||||
#if HAVE_EMPTY_AGGREGATES + 0 == 1
|
||||
#ifdef HAVE_EMPTY_AGGREGATES
|
||||
/* swallow the semicolon with a zero-sized array (language extension
|
||||
* specific to gcc/clang).
|
||||
*/
|
||||
@@ -185,7 +198,6 @@ decouple library dependencies with standard string, memory and so on.
|
||||
* without disrupting clean flow/syntax when some enum values are
|
||||
* preprocessor-gated.
|
||||
*/
|
||||
#define WC_VALUE_OF(x) x
|
||||
#if defined(WOLF_C89) || defined(WOLF_NO_TRAILING_ENUM_COMMAS)
|
||||
#define _WOLF_ENUM_DUMMY_LAST_ELEMENT_HELPER2(a, b, c, d, e) a ## b ## c ## d ## e
|
||||
#define _WOLF_ENUM_DUMMY_LAST_ELEMENT_HELPER(a, b, c, d, e) _WOLF_ENUM_DUMMY_LAST_ELEMENT_HELPER2(a, b, c, d, e)
|
||||
|
Reference in New Issue
Block a user