From 1e17d737c8f41ee5b05ea1585d48a49b4fd7fc94 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Thu, 6 Feb 2025 18:41:03 -0600 Subject: [PATCH] "#undef _WINSOCKAPI_" after defining it to "block inclusion of winsock.h header file", to fix #warning in /usr/x86_64-w64-mingw32/usr/include/winsock2.h. --- src/ssl_load.c | 1 + wolfcrypt/benchmark/benchmark.c | 1 + wolfcrypt/src/random.c | 1 + wolfssl/internal.h | 2 ++ wolfssl/test.h | 1 + wolfssl/wolfcrypt/wc_port.h | 5 ++++- 6 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ssl_load.c b/src/ssl_load.c index 066df7024..4ff31a4de 100644 --- a/src/ssl_load.c +++ b/src/ssl_load.c @@ -38,6 +38,7 @@ #define _WINSOCKAPI_ /* block inclusion of winsock.h header file */ #include #include + #undef _WINSOCKAPI_ /* mingw gcc does not support pragma comment, and the * linking with crypt32 is handled in configure.ac */ diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 87197104e..5a8306f90 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -14465,6 +14465,7 @@ void bench_sphincsKeySign(byte level, byte optim) #define WIN32_LEAN_AND_MEAN #define _WINSOCKAPI_ /* block inclusion of winsock.h header file */ #include + #undef _WINSOCKAPI_ double current_time(int reset) { diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index a0ffc7ef6..3d368e98e 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -90,6 +90,7 @@ This library contains implementation for the random number generator. #define _WINSOCKAPI_ /* block inclusion of winsock.h header file */ #include #include + #undef _WINSOCKAPI_ #elif defined(HAVE_WNR) #include #include diff --git a/wolfssl/internal.h b/wolfssl/internal.h index d7a8cd9a7..3389b6096 100644 --- a/wolfssl/internal.h +++ b/wolfssl/internal.h @@ -156,6 +156,7 @@ #elif defined(__NT__) #define _WINSOCKAPI_ /* block inclusion of winsock.h header file */ #include + #undef _WINSOCKAPI_ #elif defined(__LINUX__) #ifndef SINGLE_THREADED #define WOLFSSL_PTHREADS @@ -168,6 +169,7 @@ #else #define _WINSOCKAPI_ /* block inclusion of winsock.h header file */ #include + #undef _WINSOCKAPI_ #endif #elif defined(THREADX) #ifndef SINGLE_THREADED diff --git a/wolfssl/test.h b/wolfssl/test.h index cb64dfa1a..f7ef396b7 100644 --- a/wolfssl/test.h +++ b/wolfssl/test.h @@ -2134,6 +2134,7 @@ static WC_INLINE unsigned int my_psk_client_cs_cb(WOLFSSL* ssl, #define WIN32_LEAN_AND_MEAN #define _WINSOCKAPI_ /* block inclusion of winsock.h header file */ #include + #undef _WINSOCKAPI_ static WC_INLINE double current_time(int reset) { diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index 868d847ac..314e85645 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -160,9 +160,12 @@ #define WIN32_LEAN_AND_MEAN #endif #if !defined(WOLFSSL_SGX) && !defined(WOLFSSL_NOT_WINDOWS_API) - #define _WINSOCKAPI_ /* block inclusion of winsock.h header file */ + #define _WINSOCKAPI_ /* block inclusion of winsock.h header file. */ #include + /* winsock2.h expects _WINSOCKAPI_ to be undef, and defines it. */ + #undef _WINSOCKAPI_ #ifndef WOLFSSL_USER_IO + #include #include /* required for InetPton */ #endif #endif /* WOLFSSL_SGX */