From 20607bb0fa279d2c0118caffd61988930219bb62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 5 Oct 2015 11:40:01 +0100 Subject: [PATCH] Fix macroization of inline in C++ When compiling as C++, MSVC complains about our macroization of a keyword. Stop doing that as we know inline is always available in C++ --- ChangeLog | 1 + include/polarssl/cipher.h | 6 ++---- include/polarssl/compat-1.2.h | 9 +++------ include/polarssl/md.h | 9 +++------ include/polarssl/pkcs11.h | 6 ++---- include/polarssl/ssl.h | 9 +++------ library/ecp.c | 9 +++------ library/ecp_curves.c | 6 ++---- 8 files changed, 19 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a8f63c7d..8dac7a494 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ mbed TLS ChangeLog (Sorted per branch, date) Bugfix * Fix compile error in net.c with musl libc. Found and patch provided by zhasha (#278). + * Fix macroization of 'inline' keywork when building as C++. (#279) = mbed TLS 1.3.13 released 2015-09-17 diff --git a/include/polarssl/cipher.h b/include/polarssl/cipher.h index 00c42c1d4..f4be4ab3d 100644 --- a/include/polarssl/cipher.h +++ b/include/polarssl/cipher.h @@ -47,10 +47,8 @@ #define POLARSSL_CIPHER_MODE_STREAM #endif -#if defined(_MSC_VER) && !defined(inline) -#define inline _inline -#else -#if defined(__ARMCC_VERSION) && !defined(inline) +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) #define inline __inline #endif /* __ARMCC_VERSION */ #endif /*_MSC_VER */ diff --git a/include/polarssl/compat-1.2.h b/include/polarssl/compat-1.2.h index d694015e4..37df5412f 100644 --- a/include/polarssl/compat-1.2.h +++ b/include/polarssl/compat-1.2.h @@ -41,13 +41,10 @@ // Comment out to disable prototype change warnings #define SHOW_PROTOTYPE_CHANGE_WARNINGS -#if defined(_MSC_VER) && !defined(inline) -#define inline _inline -#else -#if defined(__ARMCC_VERSION) && !defined(inline) +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) #define inline __inline -#endif /* __ARMCC_VERSION */ -#endif /* _MSC_VER */ +#endif #if defined(_MSC_VER) // MSVC does not support #warning diff --git a/include/polarssl/md.h b/include/polarssl/md.h index 303aee820..fc7482a4b 100644 --- a/include/polarssl/md.h +++ b/include/polarssl/md.h @@ -28,13 +28,10 @@ #include -#if defined(_MSC_VER) && !defined(inline) -#define inline _inline -#else -#if defined(__ARMCC_VERSION) && !defined(inline) +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) #define inline __inline -#endif /* __ARMCC_VERSION */ -#endif /*_MSC_VER */ +#endif #define POLARSSL_ERR_MD_FEATURE_UNAVAILABLE -0x5080 /**< The selected feature is not available. */ #define POLARSSL_ERR_MD_BAD_INPUT_DATA -0x5100 /**< Bad input parameters to function. */ diff --git a/include/polarssl/pkcs11.h b/include/polarssl/pkcs11.h index 18c3370fc..80be23faf 100644 --- a/include/polarssl/pkcs11.h +++ b/include/polarssl/pkcs11.h @@ -38,10 +38,8 @@ #include -#if defined(_MSC_VER) && !defined(inline) -#define inline _inline -#else -#if defined(__ARMCC_VERSION) && !defined(inline) +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) #define inline __inline #endif /* __ARMCC_VERSION */ #endif /*_MSC_VER */ diff --git a/include/polarssl/ssl.h b/include/polarssl/ssl.h index 1f9f8be63..3b67d3860 100644 --- a/include/polarssl/ssl.h +++ b/include/polarssl/ssl.h @@ -97,13 +97,10 @@ #define POLARSSL_KEY_EXCHANGE__SOME__ECDHE_ENABLED #endif -#if defined(_MSC_VER) && !defined(inline) -#define inline _inline -#else -#if defined(__ARMCC_VERSION) && !defined(inline) +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) #define inline __inline -#endif /* __ARMCC_VERSION */ -#endif /*_MSC_VER */ +#endif /* * SSL Error codes diff --git a/library/ecp.c b/library/ecp.c index adef09ea8..796452baf 100644 --- a/library/ecp.c +++ b/library/ecp.c @@ -68,13 +68,10 @@ #define strcasecmp _stricmp #endif -#if defined(_MSC_VER) && !defined(inline) -#define inline _inline -#else -#if defined(__ARMCC_VERSION) && !defined(inline) +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) #define inline __inline -#endif /* __ARMCC_VERSION */ -#endif /*_MSC_VER */ +#endif /* Implementation that should never be optimized out by the compiler */ static void polarssl_zeroize( void *v, size_t n ) { diff --git a/library/ecp_curves.c b/library/ecp_curves.c index 3786356c3..7d26cb5b2 100644 --- a/library/ecp_curves.c +++ b/library/ecp_curves.c @@ -32,10 +32,8 @@ #include -#if defined(_MSC_VER) && !defined(inline) -#define inline _inline -#else -#if defined(__ARMCC_VERSION) && !defined(inline) +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) #define inline __inline #endif /* __ARMCC_VERSION */ #endif /*_MSC_VER */