b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | From fc392c939b9a18959482f588aff0afc29dd6d30a Mon Sep 17 00:00:00 2001 |
| 2 | From: Romain Naour <romain.naour at openwide.fr> |
| 3 | Date: Fri, 23 Jan 2015 22:20:18 +0100 |
| 4 | Subject: [PATCH 6/6] unix/configure: borrow the LFS test from autotools. |
| 5 | |
| 6 | Infozip's LFS check can't work for cross-compilation |
| 7 | since it try to run a target's binary on the host system. |
| 8 | |
| 9 | Instead, use to LFS test used by autotools which is a |
| 10 | compilation test. |
| 11 | (see autotools/lib/autoconf/specific.m4) |
| 12 | |
| 13 | Reported-by: Richard Genoud <richard.genoud at gmail.com> |
| 14 | Signed-off-by: Romain Naour <romain.naour at openwide.fr> |
| 15 | --- |
| 16 | configure | 46 +++++++++++++++------------------------------- |
| 17 | 1 file changed, 15 insertions(+), 31 deletions(-) |
| 18 | |
| 19 | --- a/unix/configure |
| 20 | +++ b/unix/configure |
| 21 | @@ -399,9 +399,8 @@ else |
| 22 | fi |
| 23 | |
| 24 | |
| 25 | -# Now we set the 64-bit file environment and check the size of off_t |
| 26 | -# Added 11/4/2003 EG |
| 27 | -# Revised 8/12/2004 EG |
| 28 | +# LFS check borrowed from autotools sources |
| 29 | +# lib/autoconf/specific.m4 |
| 30 | |
| 31 | echo Check for Large File Support |
| 32 | cat > conftest.c << _EOF_ |
| 33 | @@ -410,23 +409,19 @@ cat > conftest.c << _EOF_ |
| 34 | # define _FILE_OFFSET_BITS 64 /* select default interface as 64 bit */ |
| 35 | # define _LARGE_FILES /* some OSes need this for 64-bit off_t */ |
| 36 | #include <sys/types.h> |
| 37 | -#include <sys/stat.h> |
| 38 | -#include <unistd.h> |
| 39 | -#include <stdio.h> |
| 40 | + |
| 41 | + /* Check that off_t can represent 2**63 - 1 correctly. |
| 42 | + We can't simply define LARGE_OFF_T to be 9223372036854775807, |
| 43 | + since some C++ compilers masquerading as C compilers |
| 44 | + incorrectly reject 9223372036854775807. */ |
| 45 | +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) |
| 46 | + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 |
| 47 | + && LARGE_OFF_T % 2147483647 == 1) |
| 48 | + ? 1 : -1]; |
| 49 | + |
| 50 | int main() |
| 51 | { |
| 52 | - off_t offset; |
| 53 | - struct stat s; |
| 54 | - /* see if have 64-bit off_t */ |
| 55 | - if (sizeof(offset) < 8) |
| 56 | - return 1; |
| 57 | - printf(" off_t is %d bytes\n", sizeof(off_t)); |
| 58 | - /* see if have 64-bit stat */ |
| 59 | - if (sizeof(s.st_size) < 8) { |
| 60 | - printf(" s.st_size is %d bytes\n", sizeof(s.st_size)); |
| 61 | - return 2; |
| 62 | - } |
| 63 | - return 3; |
| 64 | + return 0; |
| 65 | } |
| 66 | _EOF_ |
| 67 | # compile it |
| 68 | @@ -434,19 +429,8 @@ $CC -o conftest conftest.c >/dev/null 2> |
| 69 | if [ $? -ne 0 ]; then |
| 70 | echo -- no Large File Support |
| 71 | else |
| 72 | -# run it |
| 73 | - ./conftest |
| 74 | - r=$? |
| 75 | - if [ $r -eq 1 ]; then |
| 76 | - echo -- no Large File Support - no 64-bit off_t |
| 77 | - elif [ $r -eq 2 ]; then |
| 78 | - echo -- no Large File Support - no 64-bit stat |
| 79 | - elif [ $r -eq 3 ]; then |
| 80 | - echo -- yes we have Large File Support! |
| 81 | - CFLAGS="${CFLAGS} -DLARGE_FILE_SUPPORT" |
| 82 | - else |
| 83 | - echo -- no Large File Support - conftest returned $r |
| 84 | - fi |
| 85 | + echo -- yes we have Large File Support! |
| 86 | + CFLAGS="${CFLAGS} -DLARGE_FILE_SUPPORT" |
| 87 | fi |
| 88 | |
| 89 | |