From 68fa9bf3f5d7b4fcbb57619f70cb4aabb79a51f6 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 13 Oct 2022 15:43:31 +0000 Subject: [PATCH] lib: set more flags in config-win32.h The goal is to add any flag that affect the created binary, to get in sync with the ones built with CMake and autotools. I took these flags from curl-for-win [0], where they've been tested with mingw-w64 and proven to work well. This patch brings them to curl as follows: - Enable unconditionally those force-enabled via `CMake/WindowsCache.cmake`: - `HAVE_SETJMP_H` - `HAVE_STRING_H` - `HAVE_SIGNAL` (CMake equivalent is `HAVE_SIGNAL_FUNC`) - Expand existing guards with mingw-w64: - `HAVE_STDBOOL_H` - `HAVE_BOOL_T` - Enable Win32 API functions for Windows Vista and later: - `HAVE_INET_NTOP` - `HAVE_INET_PTON` - Set sizes, if not already set: - `SIZEOF_OFF_T = 8` - `_FILE_OFFSET_BITS = 64` when `USE_WIN32_LARGE_FILES` is set, and using mingw-w64. - Add the remaining for mingw-w64 only. Feel free to expand as desired: - `HAVE_LIBGEN_H` - `HAVE_FTRUNCATE` - `HAVE_BASENAME` - `HAVE_STRTOK_R` Future TODO: - `HAVE_SIGNAL` has a different meaning in CMake. It's enabled when both the `signal()` function and the `SIGALRM` macro are found. In autotools and this header, it means the function only. For the function alone, CMake uses `HAVE_SIGNAL_FUNC`. [0] https://github.com/curl/curl-for-win/blob/c9b9a5f273c94c73d2b565ee892c4dff0ca97a8c/curl-m32.sh#L53-L58 Reviewed-by: Daniel Stenberg Closes #9712 --- lib/config-win32.h | 53 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/lib/config-win32.h b/lib/config-win32.h index 2f7c41644b..00e8663d2f 100644 --- a/lib/config-win32.h +++ b/lib/config-win32.h @@ -78,7 +78,8 @@ /* #define HAVE_SSL_H 1 */ /* Define to 1 if you have the header file. */ -#if defined(_MSC_VER) && (_MSC_VER >= 1800) +#if (defined(_MSC_VER) && (_MSC_VER >= 1800)) || \ + defined(__MINGW64_VERSION_MAJOR) #define HAVE_STDBOOL_H 1 #endif @@ -138,6 +139,17 @@ #define HAVE_WS2TCPIP_H 1 #endif +/* Define to 1 if you have the header file. */ +#define HAVE_SETJMP_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#if defined(__MINGW64_VERSION_MAJOR) +#define HAVE_LIBGEN_H 1 +#endif + /* ---------------------------------------------------------------- */ /* OTHER HEADER INFO */ /* ---------------------------------------------------------------- */ @@ -149,7 +161,8 @@ /* #define TIME_WITH_SYS_TIME 1 */ /* Define to 1 if bool is an available type. */ -#if defined(_MSC_VER) && (_MSC_VER >= 1800) +#if (defined(_MSC_VER) && (_MSC_VER >= 1800)) || \ + defined(__MINGW64_VERSION_MAJOR) #define HAVE_BOOL_T 1 #endif @@ -161,7 +174,9 @@ #define HAVE_CLOSESOCKET 1 /* Define if you have the ftruncate function. */ -/* #define HAVE_FTRUNCATE 1 */ +#if defined(__MINGW64_VERSION_MAJOR) +#define HAVE_FTRUNCATE 1 +#endif /* Define to 1 if you have the `getpeername' function. */ #define HAVE_GETPEERNAME 1 @@ -259,6 +274,26 @@ #define HAVE_SNPRINTF 1 #endif +#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 /* Vista */ +/* Define to 1 if you have a IPv6 capable working inet_ntop function. */ +#define HAVE_INET_NTOP 1 +/* Define to 1 if you have a IPv6 capable working inet_pton function. */ +#define HAVE_INET_PTON 1 +#endif + +/* Define to 1 if you have the `basename' function. */ +#if defined(__MINGW64_VERSION_MAJOR) +#define HAVE_BASENAME 1 +#endif + +/* Define to 1 if you have the strtok_r function. */ +#if defined(__MINGW64_VERSION_MAJOR) +#define HAVE_STRTOK_R 1 +#endif + +/* Define to 1 if you have the signal function. */ +#define HAVE_SIGNAL 1 + /* ---------------------------------------------------------------- */ /* TYPEDEF REPLACEMENTS */ /* ---------------------------------------------------------------- */ @@ -301,6 +336,11 @@ /* Define to the size of `curl_off_t', as computed by sizeof. */ #define SIZEOF_CURL_OFF_T 8 +/* Define to the size of `off_t', as computed by sizeof. */ +#ifndef SIZEOF_OFF_T +#define SIZEOF_OFF_T 8 +#endif + /* ---------------------------------------------------------------- */ /* BSD-style lwIP TCP/IP stack SPECIFIC */ /* ---------------------------------------------------------------- */ @@ -535,6 +575,13 @@ Vista # define USE_WIN32_SMALL_FILES #endif +/* Number of bits in a file offset, on hosts where this is settable. */ +#if defined(USE_WIN32_LARGE_FILES) && defined(__MINGW64_VERSION_MAJOR) +# ifndef _FILE_OFFSET_BITS +# define _FILE_OFFSET_BITS 64 +# endif +#endif + /* ---------------------------------------------------------------- */ /* DNS RESOLVER SPECIALTY */ /* ---------------------------------------------------------------- */ -- 2.47.3