curl/CMake
Viktor Szakats 32454b954a
localtime: detect thread-safe alternatives and use them
- add local API `toolx_localtime()` to wrap the banned function
  `localtime()`. Used from libcurl, libtests and test servers.
- auto-detect and use `localtime_r()` where available (e.g. Linux).
  Also to support multi-threading.
- use `localtime_s()` on Windows. It requires MSVC or mingw-w64 v4+.
  Also to support multi-threading.
  Use local workaround to also support mingw-w64 v3.
- add `src/toolx` to keep internal APIs used by the curl tool and tests,
  but not by libcurl. `toolx_localtime()` is the first API in it.
- replace `localtime()` calls with `toolx_localtime()`.
  Except in examples.
- note Windows XP's default `msvcrt.dll` doesn't offer secure CRT APIs.
  XP likely needs a newer version of this DLL, or may not run.
- note that `localtime()` mirrors `gmtime()`, with the difference that
  `gmtime()`'s internal wrapper lives in curlx.

Also:
- drop redundant `int` casts.

Refs:
https://learn.microsoft.com/cpp/c-runtime-library/reference/localtime-localtime32-localtime64
https://learn.microsoft.com/cpp/c-runtime-library/reference/localtime-s-localtime32-s-localtime64-s
https://pubs.opengroup.org/onlinepubs/9799919799/functions/localtime.html
https://linux.die.net/man/3/localtime_r

Ref: #19955 (for `gmtime_r()`)
Follow-up to 54d9f060b4
Closes #19957
2025-12-16 14:30:06 +01:00
..
cmake_uninstall.cmake.in cmake: replace exec_program() with execute_process() 2025-03-23 00:06:25 +01:00
CMakeConfigurableFile.in copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
curl-config.cmake.in cmake: verify minimum CMake version in curl-config.cmake 2025-12-01 14:46:44 +01:00
CurlSymbolHiding.cmake build: drop Windows CE / CeGCC support 2025-11-15 15:35:23 +01:00
CurlTests.c tidy-up: miscellaneous 2025-12-12 04:18:48 +01:00
FindBrotli.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindCares.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindGnuTLS.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindGSS.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindLDAP.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindLibbacktrace.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindLibgsasl.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindLibidn2.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindLibpsl.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindLibrtmp.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindLibssh.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindLibssh2.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindLibuv.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindMbedTLS.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindNettle.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindNGHTTP2.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindNGHTTP3.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindNGTCP2.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindQuiche.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindRustls.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindWolfSSL.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
FindZstd.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
Macros.cmake badwords: fix issues found in scripts and other files 2025-11-17 17:18:07 +01:00
OtherTests.cmake build: drop HAVE_SYS_SOCKET_H and HAVE_SYS_TIME_H macros 2025-06-15 18:44:39 +02:00
PickyWarnings.cmake build: set -Wno-format-signedness 2025-12-09 23:54:55 +01:00
unix-cache.cmake localtime: detect thread-safe alternatives and use them 2025-12-16 14:30:06 +01:00
Utilities.cmake cmake: define dependencies as IMPORTED interface targets 2025-11-29 01:41:40 +01:00
win32-cache.cmake localtime: detect thread-safe alternatives and use them 2025-12-16 14:30:06 +01:00