Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows: simplify detecting and using system headers #12495

Closed
wants to merge 27 commits into from

Conversation

vszakats
Copy link
Member

@vszakats vszakats commented Dec 9, 2023

  • autotools, cmake: assume that if we detect Windows, windows.h,
    winsock2.h and ws2tcpip.h do exist.
  • lib: fix 3 outlier #if conditions to use USE_WINSOCK instead of
    looking for winsock2.h.
  • autotools: merge 3 Windows check methods into one.
  • move Watt-32 and lwIP socket support to setup-win32.h from
    config-win32.h. It opens up using these with all build tools. Also
    merge logic with Windows Sockets.
  • fix to assume Windows sockets with the mingw32ce toolchain.
    Follow-up to: 2748c64
  • cmake: delete unused variable signature_call_conv since
    eb33ccd.
  • autotools: simplify CURL_CHECK_WIN32_LARGEFILE detection.
  • examples/externalsocket: fix header order.
  • cmake/OtherTests.cmake: delete Windows-specific _source_epilogue
    that wasn't used anymore.
  • cmake/OtherTests.cmake: set WIN32_LEAN_AND_MEAN for test
    SIZEOF_STRUCT_SOCKADDR_STORAGE.

After this patch curl universally uses _WIN32 to guard
Windows-specific logic. It guards Windows Sockets-specific logic with
USE_WINSOCK (this might need further work).

Closes #12495


TODO:

https://github.com/curl/curl/pull/12495/files?w=1

@vszakats vszakats added build Windows Windows-specific tidy-up labels Dec 9, 2023
@vszakats vszakats marked this pull request as draft December 9, 2023 23:29
@vszakats vszakats marked this pull request as ready for review December 10, 2023 02:30
@vszakats vszakats changed the title windows: cleanup/dedupe detecting/using system/socket headers windows: simplify detecting and using system headers Dec 10, 2023
It seems like this was a mistake, as it contradicts the original
commit message in 2748c64. These
headers exist in a mingw32ce release from 2009. Though the commit
predates that by 1 year, it seems unlikely these weren't present
in earlier releases.
These are always available for _WIN32, no need keeping a tab of them.
Use existing USE_WINSOCK to decide if we actually want to use the
default Windows TCP/IP stack.
@vszakats vszakats closed this in c1bc090 Dec 16, 2023
@vszakats vszakats deleted the winguards branch December 16, 2023 13:18
vszakats added a commit to vszakats/curl that referenced this pull request Feb 8, 2025
vszakats added a commit to vszakats/curl that referenced this pull request Feb 8, 2025
vszakats added a commit to vszakats/curl that referenced this pull request Feb 8, 2025
vszakats added a commit to vszakats/curl that referenced this pull request Feb 9, 2025
vszakats added a commit to vszakats/curl that referenced this pull request Feb 9, 2025
vszakats added a commit to vszakats/curl that referenced this pull request Feb 10, 2025
Almost all feature detection results are pre-filled on Windows
for performance, so none of the issues fixed here affected builds.

But, for good measure, this patch add missing detections and fixes
others to make sure they work even when omitting the pre-fill.

- fix `HAVE_STRUCT_TIMEVAL` detection for MSVC.
  Follow-up to c1bc090 curl#12495
- add `HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID` detection for Windows.
- fix `HAVE_STRDUP` detection for MSVC.
- fix `HAVE_SNPRINTF` detection for Windows.
  Regression from 8e34505 curl#15164
- fix `HAVE_IOCTLSOCKET` detection for non-UWP MSVC.
- exclude `if_nametoindex` detection for Windows.
  Although it exists on Windows, detection, usage and availability is
  complicated, and curl doesn't use it on this platform.
  Regression from 8e34505 curl#15164

Also:
- move IPv6-related detections so that pre-filling applies to them.
- add debug option to test without pre-filling.
- fix compiler warnings happening in feature detections to reduce log
  noise. (uninitialized/unused variables, missing static, missing const,
  constant conditional, macro redef, OpenSSL 3 deprecation warning.)

Closes curl#16278
vszakats added a commit to vszakats/curl that referenced this pull request Feb 10, 2025
vszakats added a commit to vszakats/curl that referenced this pull request Feb 11, 2025
Almost all feature detection results are pre-filled on Windows
for performance, so none of the issues fixed here affected builds.

But, for good measure, this patch add missing detections and fixes
others to make sure they work even when omitting the pre-fill.

- fix `HAVE_STRUCT_TIMEVAL` detection for MSVC.
  Follow-up to c1bc090 curl#12495
- add `HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID` detection for Windows.
- fix `HAVE_STRDUP` detection for MSVC.
- fix `HAVE_SNPRINTF` detection for Windows.
  Regression from 8e34505 curl#15164
- fix `HAVE_IOCTLSOCKET` detection for non-UWP MSVC.
- exclude `if_nametoindex` detection for Windows.
  Although it exists on Windows, detection, usage and availability is
  complicated, and curl doesn't use it on this platform.
  Regression from 8e34505 curl#15164

Also:
- move IPv6 detections so that pre-filling applies to them.
- add debug option to test without pre-filling.
- replace `NOT LESS` with `GREATER_EQUAL`

Closes curl#16278
vszakats added a commit that referenced this pull request Feb 11, 2025
Almost all feature detection results are pre-filled on Windows
for performance, so none of the issues fixed here affected builds.

For good measure, this patch add missing detections and fixes others
to make sure they work even when omitting the pre-fill.

It also fixes detecting IPv6 for MS-DOS.

- fix `HAVE_STRUCT_TIMEVAL` detection for MSVC.
  Follow-up to c1bc090 #12495
- add `HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID` detection for Windows.
- fix `HAVE_STRDUP` detection for MSVC.
- fix `HAVE_SNPRINTF` detection for Windows.
  Regression from 8e34505 #15164
- fix `HAVE_IOCTLSOCKET` detection for non-UWP MSVC.
- exclude `if_nametoindex` detection for Windows.
  Although it exists on Windows, detection, usage and availability is
  complicated, and curl doesn't use it on this platform.
  Regression from 8e34505 #15164
- move IPv6 detections so that pre-filling and MS-DOS Watt-32
  configuration applies to them. This fixes
  `HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID` detection with MS-DOS.
  Ref: https://github.com/curl/curl/actions/runs/13260511764/job/37015877585#step:7:306
  Follow-up to a3585c9 #15543

Also:
- add debug option to test without pre-filling.
- replace `NOT LESS` with `GREATER_EQUAL`

Closes #16278
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants