From: FdaSilvaYY Date: Sat, 20 Feb 2021 22:46:34 +0000 (+0100) Subject: Move inclusion of out of "e_os.h" into a dedicated header file. X-Git-Tag: openssl-3.5.0-alpha1~1187 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2ac9c714e177950488e263a4a52b2b36abfdbd8;p=thirdparty%2Fopenssl.git Move inclusion of out of "e_os.h" into a dedicated header file. Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/14344) --- diff --git a/include/internal/e_os.h b/include/internal/e_os.h index 003d63e17f2..0c546c1d946 100644 --- a/include/internal/e_os.h +++ b/include/internal/e_os.h @@ -98,26 +98,6 @@ */ # define _WIN32_WINNT 0x0501 # endif -# if defined(_WIN32_WINNT) || defined(_WIN32_WCE) - /* - * Just like defining _WIN32_WINNT including winsock2.h implies - * certain "discipline" for maintaining [broad] binary compatibility. - * As long as structures are invariant among Winsock versions, - * it's sufficient to check for specific Winsock2 API availability - * at run-time [DSO_global_lookup is recommended]... - */ -# include -# include - /* - * Clang-based C++Builder 10.3.3 toolchains cannot find C inline - * definitions at link-time. This header defines WspiapiLoad() as an - * __inline function. https://quality.embarcadero.com/browse/RSP-33806 - */ -# if !defined(__BORLANDC__) || !defined(__clang__) -# include -# endif - /* yes, they have to be #included prior to */ -# endif # include # include # include @@ -136,7 +116,7 @@ static __inline unsigned int _strlen31(const char *str) str++, len++; return len & 0x7FFFFFFF; } -# endif +# endif /* def(_WIN64) */ # include # if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(_DLL) && defined(stdin) # if _MSC_VER>=1300 && _MSC_VER<1600 @@ -150,6 +130,7 @@ FILE *__iob_func(void); # endif # endif # endif + # include # include diff --git a/include/internal/e_winsock.h b/include/internal/e_winsock.h new file mode 100644 index 00000000000..72a38a529f5 --- /dev/null +++ b/include/internal/e_winsock.h @@ -0,0 +1,52 @@ +/* + * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_E_WINSOCK_H +# define OSSL_E_WINSOCK_H +# pragma once + +# ifdef WINDOWS +# if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT) + /* + * Defining _WIN32_WINNT here in e_winsock.h implies certain "discipline." + * Most notably we ought to check for availability of each specific + * routine that was introduced after denoted _WIN32_WINNT with + * GetProcAddress(). Normally newer functions are masked with higher + * _WIN32_WINNT in SDK headers. So that if you wish to use them in + * some module, you'd need to override _WIN32_WINNT definition in + * the target module in order to "reach for" prototypes, but replace + * calls to new functions with indirect calls. Alternatively it + * might be possible to achieve the goal by /DELAYLOAD-ing .DLLs + * and check for current OS version instead. + */ +# define _WIN32_WINNT 0x0501 +# endif +# if defined(_WIN32_WINNT) || defined(_WIN32_WCE) + /* + * Just like defining _WIN32_WINNT including winsock2.h implies + * certain "discipline" for maintaining [broad] binary compatibility. + * As long as structures are invariant among Winsock versions, + * it's sufficient to check for specific Winsock2 API availability + * at run-time [DSO_global_lookup is recommended]... + */ +# include +# include + /* + * Clang-based C++Builder 10.3.3 toolchains cannot find C inline + * definitions at link-time. This header defines WspiapiLoad() as an + * __inline function. https://quality.embarcadero.com/browse/RSP-33806 + */ +# if !defined(__BORLANDC__) || !defined(__clang__) +# include +# endif + /* yes, they have to be #included prior to */ +# endif +# include +# endif +#endif /* !(OSSL_E_WINSOCK_H) */ diff --git a/include/internal/sockets.h b/include/internal/sockets.h index f51c1b075a4..5feec0eab8c 100644 --- a/include/internal/sockets.h +++ b/include/internal/sockets.h @@ -41,7 +41,7 @@ # endif # if !defined(IPPROTO_IP) /* winsock[2].h was included already? */ -# include +# include "internal/e_winsock.h" # endif # ifdef getservbyname /* this is used to be wcecompat/include/winsock_extras.h */