diff options
author | Richard Levitte <levitte@openssl.org> | 2019-09-16 16:23:25 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2019-09-20 12:16:48 +0200 |
commit | ec87a649dd2128bde780f6e34a4833d9469f6b4d (patch) | |
tree | e96148daed6896f6128ae6cdfdc867fb80ab9847 /include/openssl/macros.h | |
parent | Remove name string from PROV_CIPHER and PROV_DIGEST (diff) | |
download | openssl-ec87a649dd2128bde780f6e34a4833d9469f6b4d.tar.xz openssl-ec87a649dd2128bde780f6e34a4833d9469f6b4d.zip |
include/openssl/macros.h: Rework OPENSSL_FUNC for div C standards
OPENSSL_FUNC was defined as an alias for __FUNCTION__ with new enough
GNU C, regardless of the language standard used. We change this
slightly, so this won't happen unless __STDC_VERSION is defined.
Fixes #9911
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9913)
Diffstat (limited to '')
-rw-r--r-- | include/openssl/macros.h | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/include/openssl/macros.h b/include/openssl/macros.h index da5d155680..a06b869522 100644 --- a/include/openssl/macros.h +++ b/include/openssl/macros.h @@ -131,15 +131,31 @@ # endif # endif +/* + * __func__ was standardized in C99, so for any compiler that claims + * to implement that language level or newer, we assume we can safely + * use that symbol. + * + * GNU C also provides __FUNCTION__ since version 2, which predates + * C99. We can, however, only use this if __STDC_VERSION__ exists, + * as it's otherwise not allowed according to ISO C standards (C90). + * (compiling with GNU C's -pedantic tells us so) + * + * If none of the above applies, we check if the compiler is MSVC, + * and use __FUNCTION__ if that's the case. + * + * If all these possibilities are exhausted, we give up and use a + * static string. + */ # ifndef OPENSSL_FUNC -# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -# define OPENSSL_FUNC __func__ -# elif defined(__STRICT_ANSI__) -# define OPENSSL_FUNC "(unknown function)" -# elif defined(_MSC_VER) || (defined(__GNUC__) && __GNUC__ >= 2) -# define OPENSSL_FUNC __FUNCTION__ -# elif defined(__FUNCSIG__) -# define OPENSSL_FUNC __FUNCSIG__ +# if defined(__STDC_VERSION__) +# if __STDC_VERSION__ >= 199901L +# define OPENSSL_FUNC __func__ +# elif defined(__GNUC__) && __GNUC__ >= 2 +# define OPENSSL_FUNC __FUNCTION__ +# endif +# elif defined(_MSC_VER) +# define OPENSSL_FUNC __FUNCTION__ # else # define OPENSSL_FUNC "(unknown function)" # endif |