From: Nathan Moin Vaziri Date: Fri, 17 Apr 2026 06:42:59 +0000 (-0700) Subject: Move LFS64 detection from build system to C preprocessor X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=18bfaf7fc8ca71ce993fed1cda986182fe0edea9;p=thirdparty%2Fzlib-ng.git Move LFS64 detection from build system to C preprocessor zbuild.h now defines _LARGEFILE64_SOURCE before any system header, so glibc exposes off64_t and lseek64 where available. The _LFS64_LARGEFILE check already in zconf.h handles per-platform gating. Drops the redundant -D__USE_LARGEFILE64 (internal glibc macro, set automatically) and the unused __off64_t probe that only wrote to HAVE___OFF64_T. The configure script's _off64_t probe was log-only and the off64_t=yes path assumed fseeko exists without testing; both are removed in favor of the standalone fseeko check. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 307159db9..e16475386 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -490,23 +490,6 @@ if(HAVE_ASM_HWPROBE_H) add_definitions(-DHAVE_ASM_HWPROBE_H) endif() -# -# Check to see if we have large file support -# -set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64) -check_type_size(off64_t OFF64_T) -if(HAVE_OFF64_T) - add_definitions(-D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64) -else() - check_type_size(_off64_t _OFF64_T) - if(HAVE__OFF64_T) - add_definitions(-D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64) - else() - check_type_size(__off64_t __OFF64_T) - endif() -endif() -set(CMAKE_REQUIRED_DEFINITIONS) # clear variable - # # Check for fseeko and other optional functions # diff --git a/configure b/configure index bb7156e54..5e22e7977 100755 --- a/configure +++ b/configure @@ -792,46 +792,20 @@ if test $shared -eq 1; then fi echo >> configure.log -# check for large file support, and if none, check for fseeko() +# check for fseeko() cat > $test.c < -off64_t dummy = 0; -EOF -if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then - CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1" - SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1" - echo "Checking for off64_t... Yes." | tee -a configure.log - echo "Checking for fseeko... Yes." | tee -a configure.log -else - echo "Checking for off64_t... No." | tee -a configure.log - echo >> configure.log - cat > $test.c < -int main() { - _off64_t dummy = 0; - return 0; -} -EOF - if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then - echo "Checking for _off64_t... Yes." | tee -a configure.log - else - echo "Checking for _off64_t... No." | tee -a configure.log - fi - echo >> configure.log - cat > $test.c < int main(void) { fseeko(NULL, 0, 0); return 0; } EOF - if try $CC $CFLAGS $ADDITIONAL_CHECK_FLAGS -o $test $test.c $LDSHAREDLIBC; then - echo "Checking for fseeko... Yes." | tee -a configure.log - else - CFLAGS="${CFLAGS} -DNO_FSEEKO" - SFLAGS="${SFLAGS} -DNO_FSEEKO" - echo "Checking for fseeko... No." | tee -a configure.log - fi +if try $CC $CFLAGS $ADDITIONAL_CHECK_FLAGS -o $test $test.c $LDSHAREDLIBC; then + echo "Checking for fseeko... Yes." | tee -a configure.log +else + CFLAGS="${CFLAGS} -DNO_FSEEKO" + SFLAGS="${SFLAGS} -DNO_FSEEKO" + echo "Checking for fseeko... No." | tee -a configure.log fi echo >> configure.log diff --git a/zbuild.h b/zbuild.h index 16a9d0d77..c25c9ffde 100644 --- a/zbuild.h +++ b/zbuild.h @@ -11,6 +11,9 @@ #ifdef __OpenBSD__ # define _BSD_SOURCE 1 #endif +#ifndef _LARGEFILE64_SOURCE +# define _LARGEFILE64_SOURCE 1 /* request off64_t, lseek64 on glibc; check _LFS64_LARGEFILE */ +#endif #include #include