Simplify delocate macros slightly We only need to vary DEFINE_BSS_GET. Change-Id: I3c577c682b0007186bf13d7f2a725d589d8c74c7 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/90149 Reviewed-by: Rudolf Polzer <rpolzer@google.com> Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/crypto/fipsmodule/delocate.h b/crypto/fipsmodule/delocate.h index 5c55791..648dbff 100644 --- a/crypto/fipsmodule/delocate.h +++ b/crypto/fipsmodule/delocate.h
@@ -40,30 +40,20 @@ * with short names. Define a static wrapper function so the caller can use \ * a short name, while the symbol itself is prefixed. */ \ static type *name##_bss_get() { return BCM_ADD_PREFIX(name##_bss_get)(); } -// For FIPS builds we require that CRYPTO_ONCE_INIT be zero. -#define DEFINE_STATIC_ONCE(name) \ - DEFINE_BSS_GET(bssl::CRYPTO_once_t, name, CRYPTO_ONCE_INIT) -// For FIPS builds we require that CRYPTO_MUTEX_INIT be zero. -#define DEFINE_STATIC_MUTEX(name) \ - DEFINE_BSS_GET(bssl::CRYPTO_MUTEX, name, CRYPTO_MUTEX_INIT) -// For FIPS builds we require that CRYPTO_EX_DATA_CLASS_INIT be zero. -#define DEFINE_STATIC_EX_DATA_CLASS(name) \ - DEFINE_BSS_GET(bssl::CRYPTO_EX_DATA_CLASS, name, CRYPTO_EX_DATA_CLASS_INIT) #else #define DEFINE_BSS_GET(type, name, init_value) \ static type name = init_value; \ static type *name##_bss_get() { return &name; } -#define DEFINE_STATIC_ONCE(name) \ - static bssl::CRYPTO_once_t name = CRYPTO_ONCE_INIT; \ - static bssl::CRYPTO_once_t *name##_bss_get() { return &name; } -#define DEFINE_STATIC_MUTEX(name) \ - static bssl::CRYPTO_MUTEX name = CRYPTO_MUTEX_INIT; \ - static bssl::CRYPTO_MUTEX *name##_bss_get() { return &name; } -#define DEFINE_STATIC_EX_DATA_CLASS(name) \ - static bssl::CRYPTO_EX_DATA_CLASS name = CRYPTO_EX_DATA_CLASS_INIT; \ - static bssl::CRYPTO_EX_DATA_CLASS *name##_bss_get() { return &name; } #endif +// For FIPS builds we require each of these objects be all zero. +#define DEFINE_STATIC_ONCE(name) \ + DEFINE_BSS_GET(bssl::CRYPTO_once_t, name, CRYPTO_ONCE_INIT) +#define DEFINE_STATIC_MUTEX(name) \ + DEFINE_BSS_GET(bssl::CRYPTO_MUTEX, name, CRYPTO_MUTEX_INIT) +#define DEFINE_STATIC_EX_DATA_CLASS(name) \ + DEFINE_BSS_GET(bssl::CRYPTO_EX_DATA_CLASS, name, CRYPTO_EX_DATA_CLASS_INIT) + #define DEFINE_DATA(type, name, accessor_decorations) \ DEFINE_BSS_GET(type, name##_storage, {}) \ DEFINE_STATIC_ONCE(name##_once) \