From: Viktor Szakats Date: Sat, 11 Jan 2025 02:22:10 +0000 (+0100) Subject: windows: drop redundant `USE_WIN32_SMALL_FILES` macro X-Git-Tag: curl-8_12_0~148 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7eb4ddb850d3757ac9e0b60b0198bbb11e83135e;p=thirdparty%2Fcurl.git windows: drop redundant `USE_WIN32_SMALL_FILES` macro In effect it meant `_WIN32 && !USE_WIN32_LARGE_FILES`. Replace it with these macros. Also: - configure: delete tautological check for small file support. - configure: delete stray `_MSC_VER` reference. autotools does not support MSVC. - drop tautological checks for WinCE in `config-win32*.h` when setting `USE_WIN32_LARGE_FILES`. - merge related PP logic. - prefer `#ifdef`, fix whitespace. Suggested-by: Marcel Raad Report: https://github.com/curl/curl/pull/15952#issuecomment-2580092328 Closes #15968 --- diff --git a/acinclude.m4 b/acinclude.m4 index 4081c009a9..60303be519 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1385,7 +1385,7 @@ AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ ]],[[ - #if !defined(_WIN32_WCE) && (defined(__MINGW32__) || defined(_MSC_VER)) + #if !defined(_WIN32_WCE) && defined(__MINGW32__) int dummy=1; #else #error Win32 large file API not supported. @@ -1396,18 +1396,7 @@ AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [ ]) fi if test "$curl_win32_file_api" = "no"; then - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ - ]],[[ - #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER) - int dummy=1; - #else - #error Win32 small file API not supported. - #endif - ]]) - ],[ - curl_win32_file_api="win32_small_files" - ]) + curl_win32_file_api="win32_small_files" fi fi case "$curl_win32_file_api" in @@ -1418,8 +1407,6 @@ AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [ ;; win32_small_files) AC_MSG_RESULT([yes (large file disabled)]) - AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1, - [Define to 1 if you are building a Windows target without large file support.]) ;; *) AC_MSG_RESULT([no]) diff --git a/lib/config-win32.h b/lib/config-win32.h index 028acf4482..81dd46cf15 100644 --- a/lib/config-win32.h +++ b/lib/config-win32.h @@ -387,22 +387,13 @@ Vista /* LARGE FILE SUPPORT */ /* ---------------------------------------------------------------- */ -#if defined(_MSC_VER) && !defined(_WIN32_WCE) +#if defined(_MSC_VER) || defined(__MINGW32__) # define USE_WIN32_LARGE_FILES -#endif - -#if defined(__MINGW32__) && !defined(USE_WIN32_LARGE_FILES) -# define USE_WIN32_LARGE_FILES -#endif - -#if !defined(USE_WIN32_LARGE_FILES) && !defined(USE_WIN32_SMALL_FILES) -# 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(__MINGW32__) -# ifndef _FILE_OFFSET_BITS -# define _FILE_OFFSET_BITS 64 +# ifdef __MINGW32__ +# ifndef _FILE_OFFSET_BITS +# define _FILE_OFFSET_BITS 64 +# endif # endif #endif diff --git a/lib/config-win32ce.h b/lib/config-win32ce.h index fece5e9264..b01c2187f2 100644 --- a/lib/config-win32ce.h +++ b/lib/config-win32ce.h @@ -232,13 +232,7 @@ /* LARGE FILE SUPPORT */ /* ---------------------------------------------------------------- */ -#if defined(_MSC_VER) && !defined(_WIN32_WCE) -# define USE_WIN32_LARGE_FILES -#endif - -#if !defined(USE_WIN32_LARGE_FILES) && !defined(USE_WIN32_SMALL_FILES) -# define USE_WIN32_SMALL_FILES -#endif +/* Windows CE does not support large files */ /* ---------------------------------------------------------------- */ /* LDAP SUPPORT */ diff --git a/lib/curl_multibyte.c b/lib/curl_multibyte.c index a5ec7c9bd2..9102c972bc 100644 --- a/lib/curl_multibyte.c +++ b/lib/curl_multibyte.c @@ -32,7 +32,7 @@ #include "curl_setup.h" -#if defined(_WIN32) +#ifdef _WIN32 #include "curl_multibyte.h" @@ -84,10 +84,6 @@ char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w) return str_utf8; } -#endif /* _WIN32 */ - -#if defined(USE_WIN32_LARGE_FILES) || defined(USE_WIN32_SMALL_FILES) - /* declare GetFullPathNameW for mingw-w64 UWP builds targeting old windows */ #if defined(CURL_WINDOWS_UWP) && defined(__MINGW32__) && \ (_WIN32_WINNT < _WIN32_WINNT_WIN10) @@ -329,7 +325,7 @@ int curlx_win32_stat(const char *path, struct_stat *buffer) target = fixed; else target = path_w; -#if defined(USE_WIN32_SMALL_FILES) +#ifndef USE_WIN32_LARGE_FILES result = _wstat(target, buffer); #else result = _wstati64(target, buffer); @@ -343,7 +339,7 @@ int curlx_win32_stat(const char *path, struct_stat *buffer) target = fixed; else target = path; -#if defined(USE_WIN32_SMALL_FILES) +#ifndef USE_WIN32_LARGE_FILES result = _stat(target, buffer); #else result = _stati64(target, buffer); @@ -354,4 +350,4 @@ int curlx_win32_stat(const char *path, struct_stat *buffer) return result; } -#endif /* USE_WIN32_LARGE_FILES || USE_WIN32_SMALL_FILES */ +#endif /* _WIN32 */ diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 9b0b14bda6..582a50f690 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -497,7 +497,7 @@ * Small file (<2Gb) support using Win32 functions. */ -#ifdef USE_WIN32_SMALL_FILES +#if defined(_WIN32) && !defined(USE_WIN32_LARGE_FILES) # include # include # include diff --git a/src/tool_cb_see.c b/src/tool_cb_see.c index 99d3197eae..c86ea7fb17 100644 --- a/src/tool_cb_see.c +++ b/src/tool_cb_see.c @@ -49,7 +49,7 @@ int tool_seek_cb(void *userdata, curl_off_t offset, int whence) { struct per_transfer *per = userdata; -#if(SIZEOF_CURL_OFF_T > SIZEOF_OFF_T) && !defined(USE_WIN32_LARGE_FILES) +#if (SIZEOF_CURL_OFF_T > SIZEOF_OFF_T) && !defined(USE_WIN32_LARGE_FILES) /* The offset check following here is only interesting if curl_off_t is larger than off_t and we are not using the Win32 large file support