Skip to content

Commit

Permalink
Merge pull request #8491 from jmalak/winsock-guard
Browse files Browse the repository at this point in the history
correct comment for _WINSOCKAPI_ macro manipulation
  • Loading branch information
dgarske authored Feb 25, 2025
2 parents 0589a34 + d066e6b commit 4eda5e1
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/ssl_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#define _WINSOCKAPI_ /* block inclusion of winsock.h header file */
#include <windows.h>
#include <wincrypt.h>
#undef _WINSOCKAPI_
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header file */

/* mingw gcc does not support pragma comment, and the
* linking with crypt32 is handled in configure.ac */
Expand Down
2 changes: 1 addition & 1 deletion wolfcrypt/benchmark/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -14584,7 +14584,7 @@ void bench_sphincsKeySign(byte level, byte optim)
#define WIN32_LEAN_AND_MEAN
#define _WINSOCKAPI_ /* block inclusion of winsock.h header file */
#include <windows.h>
#undef _WINSOCKAPI_
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header file */

double current_time(int reset)
{
Expand Down
2 changes: 1 addition & 1 deletion wolfcrypt/src/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ This library contains implementation for the random number generator.
#define _WINSOCKAPI_ /* block inclusion of winsock.h header file */
#include <windows.h>
#include <wincrypt.h>
#undef _WINSOCKAPI_
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header file */
#elif defined(HAVE_WNR)
#include <wnr.h>
#include <wolfssl/wolfcrypt/logging.h>
Expand Down
4 changes: 2 additions & 2 deletions wolfssl/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
#elif defined(__NT__)
#define _WINSOCKAPI_ /* block inclusion of winsock.h header file */
#include <windows.h>
#undef _WINSOCKAPI_
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header file */
#elif defined(__LINUX__)
#ifndef SINGLE_THREADED
#define WOLFSSL_PTHREADS
Expand All @@ -169,7 +169,7 @@
#else
#define _WINSOCKAPI_ /* block inclusion of winsock.h header file */
#include <windows.h>
#undef _WINSOCKAPI_
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header file */
#endif
#elif defined(THREADX)
#ifndef SINGLE_THREADED
Expand Down
2 changes: 1 addition & 1 deletion wolfssl/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,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 <windows.h>
#undef _WINSOCKAPI_
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header file */

static WC_INLINE double current_time(int reset)
{
Expand Down
6 changes: 4 additions & 2 deletions wolfssl/wolfcrypt/wc_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
#if defined(USE_WINDOWS_API)
#define _WINSOCKAPI_ /* block inclusion of winsock.h header file */
#include <windows.h>
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header file */
#include <process.h>
#elif defined(__OS2__)
#define INCL_DOSSEMAPHORES
Expand All @@ -143,6 +144,7 @@
#if defined(USE_WINDOWS_API)
#define _WINSOCKAPI_ /* block inclusion of winsock.h header file */
#include <windows.h>
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header file */
#elif defined(__OS2__)
#include <os2.h>
#endif
Expand All @@ -162,8 +164,7 @@
#if !defined(WOLFSSL_SGX) && !defined(WOLFSSL_NOT_WINDOWS_API)
#define _WINSOCKAPI_ /* block inclusion of winsock.h header file. */
#include <windows.h>
/* winsock2.h expects _WINSOCKAPI_ to be undef, and defines it. */
#undef _WINSOCKAPI_
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header file */
#ifndef WOLFSSL_USER_IO
#include <winsock2.h>
#include <ws2tcpip.h> /* required for InetPton */
Expand Down Expand Up @@ -1218,6 +1219,7 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
#elif defined(_WIN32_WCE)
#define _WINSOCKAPI_ /* block inclusion of winsock.h header file */
#include <windows.h>
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header file */
#include <stdlib.h> /* For file system */

time_t windows_time(time_t* timer);
Expand Down

0 comments on commit 4eda5e1

Please sign in to comment.