From: Tomas Mraz Date: Thu, 18 Jun 2026 13:51:58 +0000 (+0200) Subject: Remove direct includes of windows.h where possible X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;p=thirdparty%2Fopenssl.git Remove direct includes of windows.h where possible It should be included via e_os.h instead. Reviewed-by: Milan Broz Reviewed-by: Tim Hudson Reviewed-by: Simo Sorce Reviewed-by: Frederik Wedel-Heinen Reviewed-by: Neil Horman MergeDate: Sat Jun 20 11:00:42 2026 (Merged from https://github.com/openssl/openssl/pull/31587) --- diff --git a/crypto/LPdir_win.c b/crypto/LPdir_win.c index bc5cec35d98..e8141cab868 100644 --- a/crypto/LPdir_win.c +++ b/crypto/LPdir_win.c @@ -36,8 +36,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include "internal/e_os.h" #include "internal/numbers.h" #ifndef LPDIR_H #include "LPdir.h" diff --git a/crypto/armcap.c b/crypto/armcap.c index cdb8336b13a..bd978dc86db 100644 --- a/crypto/armcap.c +++ b/crypto/armcap.c @@ -19,7 +19,7 @@ #endif #include "internal/cryptlib.h" #ifdef _WIN32 -#include +#include "internal/e_os.h" #else #include #endif diff --git a/crypto/async/arch/async_win.c b/crypto/async/arch/async_win.c index 849da5c3c41..2ca4ed6a931 100644 --- a/crypto/async/arch/async_win.c +++ b/crypto/async/arch/async_win.c @@ -12,7 +12,7 @@ #ifdef ASYNC_WIN -#include +#include "internal/e_os.h" #include "internal/cryptlib.h" int ASYNC_is_capable(void) diff --git a/crypto/async/async_local.h b/crypto/async/async_local.h index e1d11134646..f10a6745f88 100644 --- a/crypto/async/async_local.h +++ b/crypto/async/async_local.h @@ -21,6 +21,7 @@ #include #include +#include typedef struct async_ctx_st async_ctx; typedef struct async_pool_st async_pool; @@ -29,7 +30,6 @@ typedef struct async_pool_st async_pool; #define ASYNC_WIN #define ASYNC_ARCH -#include #include "internal/cryptlib.h" typedef struct async_fibre_st { diff --git a/crypto/comp/c_brotli.c b/crypto/comp/c_brotli.c index d262ec6a4ef..9c99e066b78 100644 --- a/crypto/comp/c_brotli.c +++ b/crypto/comp/c_brotli.c @@ -13,6 +13,7 @@ #include #include #include +#include "internal/e_os.h" #include "internal/comp.h" #include #include "crypto/cryptlib.h" @@ -46,10 +47,6 @@ static void brotli_free(void *opaque, void *address) * work. Therefore, all BROTLI routines are loaded at run time * and we do not link to a .LIB file when BROTLI_SHARED is set. */ -#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) -#include -#endif - #ifdef BROTLI_SHARED #include "internal/dso.h" diff --git a/crypto/comp/c_zlib.c b/crypto/comp/c_zlib.c index c90c7b090db..4af4e30b64b 100644 --- a/crypto/comp/c_zlib.c +++ b/crypto/comp/c_zlib.c @@ -11,6 +11,7 @@ #include #include #include +#include "internal/e_os.h" #include "internal/comp.h" #include #include "crypto/cryptlib.h" @@ -64,10 +65,6 @@ static COMP_METHOD zlib_stateful_method = { * work. Therefore, all ZLIB routines are loaded at run time * and we do not link to a .LIB file when ZLIB_SHARED is set. */ -#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) -#include -#endif /* !(OPENSSL_SYS_WINDOWS || \ - * OPENSSL_SYS_WIN32) */ #ifdef ZLIB_SHARED #include "internal/dso.h" diff --git a/crypto/comp/c_zstd.c b/crypto/comp/c_zstd.c index a9c881f8f9c..c5c6cd6eef9 100644 --- a/crypto/comp/c_zstd.c +++ b/crypto/comp/c_zstd.c @@ -16,6 +16,7 @@ #include #include #include +#include "internal/e_os.h" #include "internal/comp.h" #include #include "crypto/cryptlib.h" @@ -62,16 +63,6 @@ static ZSTD_customMem zstd_mem_funcs = { }; #endif -/* - * When OpenSSL is built on Windows, we do not want to require that - * the LIBZSTD.DLL be available in order for the OpenSSL DLLs to - * work. Therefore, all ZSTD routines are loaded at run time - * and we do not link to a .LIB file when ZSTD_SHARED is set. - */ -#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) -#include -#endif - #ifdef ZSTD_SHARED #include "internal/dso.h" diff --git a/crypto/mem_sec.c b/crypto/mem_sec.c index 3c5de4de8f2..a727d2008dd 100644 --- a/crypto/mem_sec.c +++ b/crypto/mem_sec.c @@ -23,7 +23,6 @@ #ifndef OPENSSL_NO_SECURE_MEMORY #if defined(_WIN32) -#include #if defined(WINAPI_FAMILY_PARTITION) #if !defined(WINAPI_PARTITION_SYSTEM) #define WINAPI_PARTITION_SYSTEM 0 diff --git a/crypto/rand/rand_deprecated.c b/crypto/rand/rand_deprecated.c index d838f3cd708..07b6ff04e8d 100644 --- a/crypto/rand/rand_deprecated.c +++ b/crypto/rand/rand_deprecated.c @@ -12,7 +12,6 @@ #include #if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) -#include #ifndef OPENSSL_NO_DEPRECATED_1_1_0 #define DEPRECATED_RAND_FUNCTIONS_DEFINED diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c index ab059bb5e86..b1881dac977 100644 --- a/crypto/rand/randfile.c +++ b/crypto/rand/randfile.c @@ -36,7 +36,6 @@ #include #include #if defined(_WIN32) && !defined(_WIN32_WCE) -#include #include #define stat _stat #define chmod _chmod diff --git a/crypto/sleep.c b/crypto/sleep.c index 9273995be68..3d8be852c91 100644 --- a/crypto/sleep.c +++ b/crypto/sleep.c @@ -67,7 +67,6 @@ static void ossl_sleep_millis(uint64_t millis) #endif #elif defined(_WIN32) && !defined(OPENSSL_SYS_UEFI) -#include static void ossl_sleep_millis(uint64_t millis) { diff --git a/crypto/thread/arch/thread_win.c b/crypto/thread/arch/thread_win.c index b26a1d917a6..1026ed3de36 100644 --- a/crypto/thread/arch/thread_win.c +++ b/crypto/thread/arch/thread_win.c @@ -7,11 +7,11 @@ * https://www.openssl.org/source/license.html */ -#include +#include "internal/thread_arch.h" +#include "internal/e_os.h" #if defined(OPENSSL_THREADS_WINNT) #include -#include static unsigned __stdcall thread_start_thunk(LPVOID vthread) { diff --git a/crypto/threads_win.c b/crypto/threads_win.c index 4fedf24e90c..448c9096308 100644 --- a/crypto/threads_win.c +++ b/crypto/threads_win.c @@ -7,14 +7,13 @@ * https://www.openssl.org/source/license.html */ -#if defined(_WIN32) -#include +#include "internal/e_os.h" + #if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 #define USE_RWLOCK #endif -#endif -#include +#include #include #include #include "internal/common.h" diff --git a/crypto/ui/ui_openssl.c b/crypto/ui/ui_openssl.c index 1da5369287e..8715ff068ee 100644 --- a/crypto/ui/ui_openssl.c +++ b/crypto/ui/ui_openssl.c @@ -60,7 +60,6 @@ #endif #ifdef WIN_CONSOLE_BUG -#include #ifndef OPENSSL_SYS_WINCE #include #endif diff --git a/include/internal/thread_arch.h b/include/internal/thread_arch.h index d7fc08a8afa..73e6e0d1e7f 100644 --- a/include/internal/thread_arch.h +++ b/include/internal/thread_arch.h @@ -11,12 +11,9 @@ #define OSSL_INTERNAL_THREAD_ARCH_H #include #include +#include "internal/e_os.h" #include "internal/time.h" -#if defined(_WIN32) -#include -#endif - #if defined(OPENSSL_THREADS) && defined(OPENSSL_SYS_UNIX) #define OPENSSL_THREADS_POSIX #elif defined(OPENSSL_THREADS) && defined(OPENSSL_SYS_VMS) diff --git a/providers/implementations/rands/seeding/rand_win.c b/providers/implementations/rands/seeding/rand_win.c index 63b523b729f..9b889e38bce 100644 --- a/providers/implementations/rands/seeding/rand_win.c +++ b/providers/implementations/rands/seeding/rand_win.c @@ -7,6 +7,7 @@ * https://www.openssl.org/source/license.html */ +#include "internal/e_os.h" /* For windows.h */ #include "internal/cryptlib.h" #include #include "crypto/rand_pool.h" @@ -19,7 +20,6 @@ #error "Unsupported seeding method configured; must be os" #endif -#include /* On Windows Vista or higher use BCrypt instead of the legacy CryptoAPI */ #if defined(_MSC_VER) && _MSC_VER > 1500 /* 1500 = Visual Studio 2008 */ \ && defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600