diff options
author | Čestmír Kalina <ckalina@redhat.com> | 2022-12-02 06:44:09 -0500 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2023-03-17 11:12:47 +1100 |
commit | 0e200d2a19185dab9d73eee90bd6cd0246416a9e (patch) | |
tree | 97403b4a3842dc752e87c27036b80efcaade1aa3 /include/internal/e_os.h | |
parent | 232dd87c55f66ecae906299cbea1ea7782241b64 (diff) | |
download | openssl-new-0e200d2a19185dab9d73eee90bd6cd0246416a9e.tar.gz |
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)
Diffstat (limited to 'include/internal/e_os.h')
-rw-r--r-- | include/internal/e_os.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/internal/e_os.h b/include/internal/e_os.h index 0455849559..df5d0b0584 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 |