e_winsock.h 2.1 KB

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