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
This commit is contained in:
Viktor Szakats 2025-01-11 03:22:10 +01:00
parent b9840814ad
commit 7eb4ddb850
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
6 changed files with 14 additions and 46 deletions

View File

@ -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])

View File

@ -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

View File

@ -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 */

View File

@ -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 */

View File

@ -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 <io.h>
# include <sys/types.h>
# include <sys/stat.h>

View File

@ -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