From df865c349a37328a6bdc516aef04defcc75841bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?okhowang=28=E7=8E=8B=E6=B2=9B=E6=96=87=29?= Date: Thu, 3 Sep 2020 16:21:30 +0800 Subject: [PATCH 1/5] Pass c99 to compiler in CMakeLists.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #3631 Signed-off-by: okhowang(王沛文) --- 3rdparty/everest/library/Hacl_Curve25519_joined.c | 6 ++++++ CMakeLists.txt | 2 ++ 2 files changed, 8 insertions(+) diff --git a/3rdparty/everest/library/Hacl_Curve25519_joined.c b/3rdparty/everest/library/Hacl_Curve25519_joined.c index ee62be1ceb46..49d4b4882f7c 100644 --- a/3rdparty/everest/library/Hacl_Curve25519_joined.c +++ b/3rdparty/everest/library/Hacl_Curve25519_joined.c @@ -18,6 +18,12 @@ * * This file is part of mbed TLS (https://tls.mbed.org) */ +#ifndef _BSD_SOURCE +#define _BSD_SOURCE +#endif +#ifndef _DEFAULT_SOURCE +#define _DEFAULT_SOURCE +#endif #include "common.h" diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fccd3d1bde6..ec140245f006 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,6 +170,8 @@ string(REGEX MATCH "Clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}") include(CheckCCompilerFlag) +set(CMAKE_C_STANDARD 99) + if(CMAKE_COMPILER_IS_GNU) # some warnings we want are not available with old GCC versions # note: starting with CMake 2.8 we could use CMAKE_C_COMPILER_VERSION From f5f1cfc57285db2735b36bf5f950c1d709c92b73 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Tue, 10 May 2022 17:26:47 +0100 Subject: [PATCH 2/5] Additional CMake flag for controlling C standard Disable compiler-specific extensions (e.g. use --std=c11 instead of --std=gnu11). Signed-off-by: Dave Rodgman --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec140245f006..0c207d17d66d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,6 +170,7 @@ string(REGEX MATCH "Clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}") include(CheckCCompilerFlag) +set(CMAKE_C_EXTENSIONS OFF) set(CMAKE_C_STANDARD 99) if(CMAKE_COMPILER_IS_GNU) From faef649dec11e87c83ceaa01610e729eb3b5f4f6 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Wed, 11 May 2022 16:05:16 +0000 Subject: [PATCH 3/5] Fix Ubuntu compile error in udp_proxy.c Signed-off-by: Dave Rodgman --- programs/test/udp_proxy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/programs/test/udp_proxy.c b/programs/test/udp_proxy.c index 41a90a9ada28..6ffd3cda0097 100644 --- a/programs/test/udp_proxy.c +++ b/programs/test/udp_proxy.c @@ -73,9 +73,10 @@ int main( void ) #endif #endif /* _MSC_VER */ #else /* ( _WIN32 || _WIN32_WCE ) && !EFIX64 && !EFI32 */ -#if defined(MBEDTLS_HAVE_TIME) +#if defined(MBEDTLS_HAVE_TIME) || (defined(MBEDTLS_TIMING_C) && !defined(MBEDTLS_TIMING_ALT)) #include #endif +#include #include #include #endif /* ( _WIN32 || _WIN32_WCE ) && !EFIX64 && !EFI32 */ From 85fba901fffcfadd34c91134eaaa775a46dff4db Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Wed, 11 May 2022 16:13:52 +0000 Subject: [PATCH 4/5] Add comment Signed-off-by: Dave Rodgman --- 3rdparty/everest/library/Hacl_Curve25519_joined.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/everest/library/Hacl_Curve25519_joined.c b/3rdparty/everest/library/Hacl_Curve25519_joined.c index 49d4b4882f7c..149e4741a774 100644 --- a/3rdparty/everest/library/Hacl_Curve25519_joined.c +++ b/3rdparty/everest/library/Hacl_Curve25519_joined.c @@ -19,7 +19,7 @@ * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef _BSD_SOURCE -#define _BSD_SOURCE +#define _BSD_SOURCE /* Required to enable compilation under --std=c99 */ #endif #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE From c9c6e8d1890f637ddd12211d1b5873094416dba4 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Thu, 12 May 2022 09:22:50 +0100 Subject: [PATCH 5/5] Improve comments Signed-off-by: Dave Rodgman --- 3rdparty/everest/library/Hacl_Curve25519_joined.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/3rdparty/everest/library/Hacl_Curve25519_joined.c b/3rdparty/everest/library/Hacl_Curve25519_joined.c index 149e4741a774..957294f64863 100644 --- a/3rdparty/everest/library/Hacl_Curve25519_joined.c +++ b/3rdparty/everest/library/Hacl_Curve25519_joined.c @@ -19,9 +19,12 @@ * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef _BSD_SOURCE -#define _BSD_SOURCE /* Required to enable compilation under --std=c99 */ +/* Required to get htole64() from gcc/glibc's endian.h (older systems) + * when we compile with -std=c99 */ +#define _BSD_SOURCE #endif #ifndef _DEFAULT_SOURCE +/* (modern version of _BSD_SOURCE) */ #define _DEFAULT_SOURCE #endif