]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Move inclusion of <winsock.h> out of "e_os.h" into a dedicated header file.
authorFdaSilvaYY <fdasilvayy@gmail.com>
Sat, 20 Feb 2021 22:46:34 +0000 (23:46 +0100)
committerTomas Mraz <tomas@openssl.org>
Thu, 5 Sep 2024 15:02:51 +0000 (17:02 +0200)
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14344)

include/internal/e_os.h
include/internal/e_winsock.h [new file with mode: 0644]
include/internal/sockets.h

index 003d63e17f2a8cc5efa5b561340ba63d7cb0a066..0c546c1d9460f82aa724b96760fb355ee0281651 100644 (file)
         */
 #    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 <winsock2.h>
-#    include <ws2tcpip.h>
-       /*
-        * 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 <wspiapi.h>
-#    endif
-       /* yes, they have to be #included prior to <windows.h> */
-#   endif
 #   include <windows.h>
 #   include <stdio.h>
 #   include <stddef.h>
@@ -136,7 +116,7 @@ static __inline unsigned int _strlen31(const char *str)
         str++, len++;
     return len & 0x7FFFFFFF;
 }
-#   endif
+#   endif   /* def(_WIN64) */
 #   include <malloc.h>
 #   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 <io.h>
 #  include <fcntl.h>
 
diff --git a/include/internal/e_winsock.h b/include/internal/e_winsock.h
new file mode 100644 (file)
index 0000000..72a38a5
--- /dev/null
@@ -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 <winsock2.h>
+#   include <ws2tcpip.h>
+      /*
+       * 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 <wspiapi.h>
+#   endif
+      /* yes, they have to be #included prior to <windows.h> */
+#  endif
+#  include <windows.h>
+# endif
+#endif /* !(OSSL_E_WINSOCK_H) */
index f51c1b075a441a55d02b7d505716c774e5bb7366..5feec0eab8cfc316159cfa50b3c4427dc99f1d57 100644 (file)
@@ -41,7 +41,7 @@
 #  endif
 #  if !defined(IPPROTO_IP)
     /* winsock[2].h was included already? */
-#   include <winsock.h>
+#   include "internal/e_winsock.h"
 #  endif
 #  ifdef getservbyname
      /* this is used to be wcecompat/include/winsock_extras.h */