bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bash patch for better large-file support


From: Paul Eggert
Subject: bash patch for better large-file support
Date: Tue, 10 Apr 2001 12:30:31 -0700 (PDT)

bash 2.05 uses an old method for configuring large files that has been
superseded in other GNU utilities.  This new method is more portable
in practice -- for example, it works even on when cross-compiling, and
it works even when someone compiles bash with a C++ compiler
masquerading as a C compiler (which is common in some places).  This
new method will eventually appear in autoconf.  Here is a patch to
convert bash to use this method.

This patch attempts to minimize the conversion effort when autoconf
adds support for large files.  When that happens, you should be able
to convert to the autoconf version by removing the largefile stuff
from aclocal.m4, removing the AC_ARG_ENABLE(largefile, ...) line from
configure.in, and replacing BASH_SYS_LARGEFILE with AC_SYS_LARGEFILE
in configure.in.

Also, this patch removes BASH_CHECK_OFF_T_64, which is not used in
bash 2.05.

2001-04-10  Paul Eggert  <address@hidden>

        * NEWS, doc/bashref.texi: Describe --enable-largefile.

        * configure.in: Document new --enable-largefile option.
        Invoke BASH_SYS_LARGEFILE (renamed from BASH_LARGE_FILE_SUPPORT) after
        AC_MINIX to avoid autoconf warnings.

        * config.h.in (_FILE_OFFSET_BITS, _LARGE_FILES): New macros.

        * aclocal.m4 (BASH_SYS_LARGEFILE): Renamed from
        BASH_LARGE_FILE_SUPPORT, for consistency with the
        AC_SYS_LARGEFILE used by other utilities (and the upcoming
        autoconf release).
        (BASH_SYS_LARGEFILE_TEST_INCLUDES, BASH_SYS_LARGEFILE_MACRO_VALUE):
        New macros.
        (BASH_CHECK_OFF_T_64): Remove; not used.

===================================================================
RCS file: NEWS,v
retrieving revision 2.5
retrieving revision 2.5.0.1
diff -pu -r2.5 -r2.5.0.1
--- NEWS        2001/04/04 14:44:08     2.5
+++ NEWS        2001/04/10 19:21:48     2.5.0.1
@@ -1,3 +1,6 @@
+*   configure has a new option, `--enable-largefile', to compile in
+    support for large files (enabled by default).
+
 This is a terse description of the new features added to bash-2.05 since
 the release of bash-2.04.  As always, the manual page (doc/bash.1) is
 the place to look for complete descriptions.
===================================================================
RCS file: doc/bashref.texi,v
retrieving revision 2.5
retrieving revision 2.5.0.1
diff -pu -r2.5 -r2.5.0.1
--- doc/bashref.texi    2001/03/28 19:49:52     2.5
+++ doc/bashref.texi    2001/04/10 19:15:14     2.5.0.1
@@ -6164,6 +6164,12 @@ builtin commands (@pxref{Bash History Fa
 This enables the job control features (@pxref{Job Control}),
 if the operating system supports them.
 
address@hidden --enable-largefile
+Enable support for
address@hidden://www.sas.com/standards/large.file/x_open.20Mar96.html, large
+files} if the operating system requires special compiler options to
+build programs that can access large files.
+
 @item --enable-net-redirections
 This enables the special handling of filenames of the form
 @code{/dev/tcp/@var{host}/@var{port}} and
===================================================================
RCS file: configure.in,v
retrieving revision 2.5
retrieving revision 2.5.0.1
diff -pu -r2.5 -r2.5.0.1
--- configure.in        2001/01/23 17:57:24     2.5
+++ configure.in        2001/04/10 19:15:14     2.5.0.1
@@ -160,6 +160,7 @@ AC_ARG_ENABLE(extended-glob, --enable-ex
 AC_ARG_ENABLE(help-builtin, --enable-help-builtin      include the help 
builtin, opt_help=$enableval)
 AC_ARG_ENABLE(history, --enable-history        turn on command history, 
opt_history=$enableval)
 AC_ARG_ENABLE(job-control, --enable-job-control        enable job control 
features, opt_job_control=$enableval)
+AC_ARG_ENABLE(largefile, --enable-largefile    enable support for large files)
 AC_ARG_ENABLE(net-redirections, --enable-net-redirections      enable 
/dev/tcp/host/port redirection, opt_net_redirs=$enableval)
 AC_ARG_ENABLE(process-substitution, --enable-process-substitution      enable 
process substitution, opt_process_subst=$enableval)
 AC_ARG_ENABLE(progcomp, --enable-progcomp      enable programmable completion 
and the complete builtin, opt_progcomp=$enableval)
@@ -262,12 +263,13 @@ dnl compilation checks
 dnl AC_PROG_CC sets $cross_compiling to `yes' if cross-compiling for a
 dnl different environment
 AC_PROG_CC
-BASH_LARGE_FILE_SUPPORT
 
 dnl test for Unix variants
 AC_ISC_POSIX
 AC_MINIX
 
+BASH_SYS_LARGEFILE
+
 dnl test for non-Unix variants
 AC_CYGWIN
 AC_MINGW32
===================================================================
RCS file: config.h.in,v
retrieving revision 2.5
retrieving revision 2.5.0.1
diff -pu -r2.5 -r2.5.0.1
--- config.h.in 2000/10/02 13:44:22     2.5
+++ config.h.in 2001/04/10 19:15:14     2.5.0.1
@@ -686,6 +686,12 @@
 /* Define if job control is unusable or unsupported. */
 #undef JOB_CONTROL_MISSING
 
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
+
+/* Define for large files, on AIX-style hosts. */
+#undef _LARGE_FILES
+
 /* Do we need to define _KERNEL to get the RLIMIT_* defines from
    <sys/resource.h>? */
 #undef RLIMIT_NEEDS_KERNEL
===================================================================
RCS file: aclocal.m4,v
retrieving revision 2.5
retrieving revision 2.5.0.1
diff -pu -r2.5 -r2.5.0.1
--- aclocal.m4  2000/11/21 15:42:10     2.5
+++ aclocal.m4  2001/04/10 19:15:14     2.5.0.1
@@ -1307,41 +1307,71 @@ fi
 
 dnl
 dnl If available, use support for large files unless the user specified
-dnl one of the CPPFLAGS, LDFLAGS, or LIBS variables (<address@hidden>
-dnl via GNU patch 2.5)
+dnl --disable-largefile (<address@hidden> via GNU tar 1.13.19's
+dnl m4/largefile.m4 serial 19)
 dnl
-AC_DEFUN(BASH_LARGE_FILE_SUPPORT,
-[AC_MSG_CHECKING(whether large file support needs explicit enabling)
-ac_getconfs=''
-ac_result=yes
-ac_set=''
-ac_shellvars='CPPFLAGS LDFLAGS LIBS'
-for ac_shellvar in $ac_shellvars; do
-  case $ac_shellvar in
-  CPPFLAGS) ac_lfsvar=LFS_CFLAGS ac_lfs64var=LFS64_CFLAGS ;;
-  *) ac_lfsvar=LFS_$ac_shellvar ac_lfs64var=LFS64_$ac_shellvar ;;
-  esac
-  eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
-  (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
-  ac_getconf=`getconf $ac_lfsvar`
-  ac_getconf64=`getconf $ac_lfs64var`
-  ac_getconfs=$ac_getconfs$ac_getconf\ $ac_getconf64
-  eval ac_test_$ac_shellvar="\$ac_getconf\ \$ac_getconf64"
-done
-case "$ac_result$ac_getconfs" in
-yes) ac_result=no ;;
-esac
-case "$ac_result$ac_set" in
-yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
-esac
-AC_MSG_RESULT($ac_result)
-case $ac_result in
-yes)
-  for ac_shellvar in $ac_shellvars; do
-    eval $ac_shellvar=\$ac_test_$ac_shellvar
-  done ;;
-esac
-])
+dnl Internal subroutine of BASH_SYS_LARGEFILE.
+dnl BASH_SYS_LARGEFILE_TEST_INCLUDES
+AC_DEFUN(BASH_SYS_LARGEFILE_TEST_INCLUDES,
+  [[#include <sys/types.h>
+    /* Check that off_t can represent 2**63 - 1 correctly.
+       We can't simply "#define LARGE_OFF_T 9223372036854775807",
+       since some C++ compilers masquerading as C compilers
+       incorrectly reject 9223372036854775807.  */
+#   define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+    int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+                       && LARGE_OFF_T % 2147483647 == 1)
+                      ? 1 : -1];
+  ]])
+
+dnl Internal subroutine of BASH_SYS_LARGEFILE.
+dnl BASH_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, 
INCLUDES, FUNCTION-BODY)
+AC_DEFUN(BASH_SYS_LARGEFILE_MACRO_VALUE,
+  [AC_CACHE_CHECK([for $1 value needed for large files], $3,
+     [$3=no
+      AC_TRY_COMPILE([$5],
+       [$6], 
+       ,
+       [AC_TRY_COMPILE([#define $1 $2]
+[$5]
+          ,
+          [$6],
+          [$3=$2])])])
+   if test "[$]$3" != no; then
+     AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
+   fi])
+
+AC_DEFUN(BASH_SYS_LARGEFILE,
+  [AC_REQUIRE([AC_PROG_CC])
+   if test "$enable_largefile" != no; then
+
+     AC_CACHE_CHECK([for special C compiler options needed for large files],
+       ac_cv_sys_largefile_CC,
+       [ac_cv_sys_largefile_CC=no
+        if test "$GCC" != yes; then
+         # IRIX 6.2 and later do not support large files by default,
+         # so use the C compiler's -n32 option if that helps.
+         AC_TRY_COMPILE(BASH_SYS_LARGEFILE_TEST_INCLUDES, , ,
+           [ac_save_CC="$CC"
+            CC="$CC -n32"
+            AC_TRY_COMPILE(BASH_SYS_LARGEFILE_TEST_INCLUDES, ,
+              ac_cv_sys_largefile_CC=' -n32')
+            CC="$ac_save_CC"])
+        fi])
+     if test "$ac_cv_sys_largefile_CC" != no; then
+       CC="$CC$ac_cv_sys_largefile_CC"
+     fi
+
+     BASH_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
+       ac_cv_sys_file_offset_bits,
+       [Number of bits in a file offset, on hosts where this is settable.],
+       BASH_SYS_LARGEFILE_TEST_INCLUDES)
+     BASH_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
+       ac_cv_sys_large_files,
+       [Define for large files, on AIX-style hosts.],
+       BASH_SYS_LARGEFILE_TEST_INCLUDES)
+   fi
+  ])
 
 dnl
 dnl AC_SYS_RESTARTABLE_SYSCALLS tests only for restarted system calls
@@ -1395,25 +1425,6 @@ if test $bash_cv_sys_restartable_syscall
   AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS)
 fi
 ])
-dnl
-dnl Check for 64-bit off_t -- used for malloc alignment
-dnl
-dnl C does not allow duplicate case labels, so the compile will fail if
-dnl sizeof(off_t) is > 4.
-dnl
-AC_DEFUN(BASH_CHECK_OFF_T_64,
-[AC_CACHE_CHECK(for 64-bit off_t, bash_cv_off_t_64,
-AC_TRY_COMPILE([
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <sys/types.h>
-],[
-switch (0) case 0: case (sizeof (off_t) <= 4):;
-], bash_cv_off_t_64=no, bash_cv_off_t_64=yes))
-if test $bash_cv_off_t_64 = yes; then
-        AC_DEFINE(HAVE_OFF_T_64)
-fi])
 
 AC_DEFUN(BASH_STRUCT_TIMEVAL,
 [AC_MSG_CHECKING(for struct timeval in sys/time.h and time.h)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]