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 <ckalina@redhat.com>

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12256)
This commit is contained in:
Čestmír Kalina 2022-12-02 06:44:09 -05:00 committed by Pauli
parent 232dd87c55
commit 0e200d2a19

View File

@ -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