From: Čestmír Kalina Date: Fri, 2 Dec 2022 11:44:09 +0000 (-0500) Subject: e_os2: add ossl_static_assert_type_eq X-Git-Tag: openssl-3.2.0-alpha1~1147 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0e200d2a19185dab9d73eee90bd6cd0246416a9e;p=thirdparty%2Fopenssl.git e_os2: add ossl_static_assert_type_eq Add a gcc-only static assertion that a variable is of a specified type. Signed-off-by: Čestmír Kalina Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/12256) --- diff --git a/include/internal/e_os.h b/include/internal/e_os.h index 0455849559c..df5d0b05840 100644 --- a/include/internal/e_os.h +++ b/include/internal/e_os.h @@ -22,6 +22,15 @@ * outside; this file e_os.h is not part of the exported interface. */ +/* ossl_static_assert_type_eq: gcc-only variable type static assertion */ +# if defined(__GNUC__) && !defined(__clang__) +# define ossl_static_assert_type_eq(type, x) \ + _Static_assert((__builtin_types_compatible_p(type, __typeof__(x))), \ + #x " type check failed, expected: " #type) +# else +# define ossl_static_assert_type_eq(type, x) +# endif + # if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) # define NO_CHMOD # define NO_SYSLOG