xref: /freebsd/crypto/openssl/include/internal/e_winsock.h (revision e7be843b4a162e68651d3911f0357ed464915629)
1*e7be843bSPierre Pronchery /*
2*e7be843bSPierre Pronchery  * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
3*e7be843bSPierre Pronchery  *
4*e7be843bSPierre Pronchery  * Licensed under the Apache License 2.0 (the "License").  You may not use
5*e7be843bSPierre Pronchery  * this file except in compliance with the License.  You can obtain a copy
6*e7be843bSPierre Pronchery  * in the file LICENSE in the source distribution or at
7*e7be843bSPierre Pronchery  * https://www.openssl.org/source/license.html
8*e7be843bSPierre Pronchery  */
9*e7be843bSPierre Pronchery 
10*e7be843bSPierre Pronchery #ifndef OSSL_E_WINSOCK_H
11*e7be843bSPierre Pronchery # define OSSL_E_WINSOCK_H
12*e7be843bSPierre Pronchery # pragma once
13*e7be843bSPierre Pronchery 
14*e7be843bSPierre Pronchery # ifdef WINDOWS
15*e7be843bSPierre Pronchery #  if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)
16*e7be843bSPierre Pronchery       /*
17*e7be843bSPierre Pronchery        * Defining _WIN32_WINNT here in e_winsock.h implies certain "discipline."
18*e7be843bSPierre Pronchery        * Most notably we ought to check for availability of each specific
19*e7be843bSPierre Pronchery        * routine that was introduced after denoted _WIN32_WINNT with
20*e7be843bSPierre Pronchery        * GetProcAddress(). Normally newer functions are masked with higher
21*e7be843bSPierre Pronchery        * _WIN32_WINNT in SDK headers. So that if you wish to use them in
22*e7be843bSPierre Pronchery        * some module, you'd need to override _WIN32_WINNT definition in
23*e7be843bSPierre Pronchery        * the target module in order to "reach for" prototypes, but replace
24*e7be843bSPierre Pronchery        * calls to new functions with indirect calls. Alternatively it
25*e7be843bSPierre Pronchery        * might be possible to achieve the goal by /DELAYLOAD-ing .DLLs
26*e7be843bSPierre Pronchery        * and check for current OS version instead.
27*e7be843bSPierre Pronchery        */
28*e7be843bSPierre Pronchery #   define _WIN32_WINNT 0x0501
29*e7be843bSPierre Pronchery #  endif
30*e7be843bSPierre Pronchery #  if defined(_WIN32_WINNT) || defined(_WIN32_WCE)
31*e7be843bSPierre Pronchery       /*
32*e7be843bSPierre Pronchery        * Just like defining _WIN32_WINNT including winsock2.h implies
33*e7be843bSPierre Pronchery        * certain "discipline" for maintaining [broad] binary compatibility.
34*e7be843bSPierre Pronchery        * As long as structures are invariant among Winsock versions,
35*e7be843bSPierre Pronchery        * it's sufficient to check for specific Winsock2 API availability
36*e7be843bSPierre Pronchery        * at run-time [DSO_global_lookup is recommended]...
37*e7be843bSPierre Pronchery        */
38*e7be843bSPierre Pronchery #   include <winsock2.h>
39*e7be843bSPierre Pronchery #   include <ws2tcpip.h>
40*e7be843bSPierre Pronchery       /*
41*e7be843bSPierre Pronchery        * Clang-based C++Builder 10.3.3 toolchains cannot find C inline
42*e7be843bSPierre Pronchery        * definitions at link-time.  This header defines WspiapiLoad() as an
43*e7be843bSPierre Pronchery        * __inline function.  https://quality.embarcadero.com/browse/RSP-33806
44*e7be843bSPierre Pronchery        */
45*e7be843bSPierre Pronchery #   if !defined(__BORLANDC__) || !defined(__clang__)
46*e7be843bSPierre Pronchery #    include <wspiapi.h>
47*e7be843bSPierre Pronchery #   endif
48*e7be843bSPierre Pronchery       /* yes, they have to be #included prior to <windows.h> */
49*e7be843bSPierre Pronchery #  endif
50*e7be843bSPierre Pronchery #  include <windows.h>
51*e7be843bSPierre Pronchery # endif
52*e7be843bSPierre Pronchery #endif /* !(OSSL_E_WINSOCK_H) */
53