]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Move LFS64 detection from build system to C preprocessor
authorNathan Moin Vaziri <nathan@nathanm.com>
Fri, 17 Apr 2026 06:42:59 +0000 (23:42 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Tue, 26 May 2026 15:11:31 +0000 (17:11 +0200)
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.

CMakeLists.txt
configure
zbuild.h

index 307159db9783d233496cb31b815d6e3a3f717caf..e16475386ee278f7006a6aeb6e61aa5caf0b36f1 100644 (file)
@@ -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
 #
index bb7156e545ee95544841f5f1e0b89e804fb20974..5e22e797751fde4dfd6ff9c57e59b6fbc45f20b2 100755 (executable)
--- 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 <<EOF
-#include <sys/types.h>
-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 <<EOF
-#include <sys/types.h>
-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 <<EOF
 #include <stdio.h>
 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
 
index 16a9d0d7741c07a1dce2227a4bad53e8c8305606..c25c9ffde3125713a645890127ad13075366e422 100644 (file)
--- 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 <stddef.h>
 #include <string.h>