This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Support getconf -v POSIX_V6_*LP*OFF*


Hi!

Without this patch, say on x86-64
getconf -v POSIX_V6_ILP32_OFF32 LONG_BIT
getconf -v POSIX_V6_ILP64_OFF64 LONG_BIT
getconf LONG_BIT
all print the same thing (depending on if 32-bit or 64-bit /usr/bin/getconf
is installed), _POSIX_V6_WIDTH_RESTRICTED_ENVS doesn't
show both 32-bit and 64-bit specifications and e.g.
the various *CFLAGS don't include -m32/-m64 switches that are needed
on multi-abi arches to select 32-bit or 64-bit.

With this patch,
getconf -v POSIX_V6_ILP32_OFF32 LONG_BIT
on x86-64 will always print 32,
getconf -v POSIX_V6_ILP64_OFF64 LONG_BIT
always print 64,
getconf LONG_BIT will print one of these depending on:
1) if /usr/libexec/getconf/default symlink exists, then what this symlink
   points to
2) if it doesn't, whether /usr/bin/getconf is 32-bit or 64-bit
_POSIX_V6_WIDTH_RESTRICTED_ENVS now includes all 3 applicable specifications
if both 32-bit and 64-bit glibc is installed, etc.

The /usr/libexec/getconf/default symlink is not installed by glibc,
as it is intended to be populated by whatever package provides c99 program
(depending on what its compilation default will be, the same default
can be used by getconf).

2004-11-26  Jakub Jelinek  <jakub@redhat.com>

	* posix/Makefile (install-others): Add $(inst_libexecdir)/getconf.
	(CFLAGS-sysconf.c): Add -D_GETCONF_DIR.
	(CFLAGS-getconf.c): New.
	($(inst_libexecdir)/getconf): New.
	* posix/confstr.c (confstr): Use __sysconf to query specifications
	that don't have _POSIX_V6_* macros defined.  Use __*_{C,LD}FLAGS
	macros defined in bits/environments.h.
	* sysdeps/posix/sysconf.c: Include stdlib.h, string.h and
	sys/stat.h.
	(__sysconf_check_spec): New routine.
	(__sysconf): Use it.
	* posix/getconf.c (specs): Change into structure array.
	(main): If -v is not given, try to get default from
	$(libexecdir)/getconf/default.  If specification is not
	supported by this getconf, try to execute
	$(libexecdir)/getconf/$(specification).
	* sysdeps/unix/bsd/bsd4.4/freebsd/bits/environments.h: New file.
	* sysdeps/unix/sysv/linux/s390/bits/environments.h: New file.
	* sysdeps/unix/sysv/linux/powerpc/bits/environments.h: New file.
	* sysdeps/unix/sysv/linux/sparc/bits/environments.h: New file.
	* sysdeps/unix/sysv/linux/i386/bits/environments.h: New file.
	* sysdeps/unix/sysv/linux/x86_64/bits/environments.h: New file.
	* sysdeps/generic/bits/environments.h (__ILP32_OFFBIG_CFLAGS):
	Define.

--- libc/posix/Makefile.jj	2004-11-19 13:38:43.000000000 +0100
+++ libc/posix/Makefile	2004-11-26 00:30:42.870518452 +0100
@@ -91,6 +91,7 @@ tests           += wordexp-test tst-exec
 endif
 others		:= getconf
 install-bin	:= getconf
+install-others	:= $(inst_libexecdir)/getconf
 
 before-compile	:= testcases.h ptestcases.h
 
@@ -138,7 +139,7 @@ CFLAGS-waitid.c = -fexceptions
 CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-getopt.c = -fexceptions
 CFLAGS-wordexp.c = -fexceptions
-CFLAGS-sysconf.c = -fexceptions
+CFLAGS-sysconf.c = -fexceptions -DGETCONF_DIR='"$(libexecdir)/getconf"'
 CFLAGS-pathconf.c = -fexceptions
 CFLAGS-fpathconf.c = -fexceptions
 CFLAGS-spawn.c = -fexceptions
@@ -147,6 +148,7 @@ CFLAGS-spawni.c = -fexceptions
 CFLAGS-pause.c = -fexceptions
 CFLAGS-glob.c = $(uses-callbacks) -fexceptions
 CFLAGS-glob64.c = $(uses-callbacks) -fexceptions
+CFLAGS-getconf.c = -DGETCONF_DIR='"$(libexecdir)/getconf"'
 
 tstgetopt-ARGS = -a -b -cfoobar --required foobar --optional=bazbug \
 		--none random --col --color --colour
@@ -260,3 +262,13 @@ bug-glob2-ENV = MALLOC_TRACE=$(objpfx)bu
 
 $(objpfx)bug-glob2-mem: $(objpfx)bug-glob2.out
 	$(common-objpfx)malloc/mtrace $(objpfx)bug-glob2.mtrace > $@
+
+$(inst_libexecdir)/getconf: $(objpfx)getconf FORCE
+	$(addprefix $(..)./scripts/mkinstalldirs ,\
+		    $(filter-out $(wildcard $@),$@))
+	for spec in `LC_ALL=C GETCONF_DIR=/dev/null \
+		     $(run-program-prefix) $< \
+		     _POSIX_V6_WIDTH_RESTRICTED_ENVS`; do \
+		$(INSTALL_PROGRAM) $< $@/$$spec.new; \
+		mv -f $@/$$spec.new $@/$$spec; \
+	done
--- libc/posix/confstr.c.jj	2004-11-25 21:37:42.000000000 +0100
+++ libc/posix/confstr.c	2004-11-25 23:31:35.000000000 +0100
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991,96,97,2000-2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996, 1997, 2000-2002, 2003, 2004
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -54,50 +55,153 @@ confstr (name, buf, len)
 
 	 Currently this means all environment which the system allows.  */
       {
-	static const char restenvs[] =
-#if _POSIX_V6_ILP32_OFF32 > 0
-	"_POSIX_V6_ILP32_OFF32"
+	char restenvs[4 * sizeof "_POSIX_V6_LPBIG_OFFBIG"];
+
+	string_len = 0;
+#ifndef _POSIX_V6_ILP32_OFF32
+        if (__sysconf (_SC_V6_ILP32_OFF32) > 0)
 #endif
-#if _POSIX_V6_ILP32_OFFBIG > 0
-# if _POSIX_V6_ILP32_OFF32 > 0
-	"\n"
-# endif
-	"_POSIX_V6_ILP32_OFFBIG"
+#if !defined _POSIX_V6_ILP32_OFF32 || _POSIX_V6_ILP32_OFF32 > 0
+          {
+            memcpy (restenvs + string_len, "_POSIX_V6_ILP32_OFF32",
+                    sizeof "_POSIX_V6_ILP32_OFF32" - 1);
+            string_len += sizeof "_POSIX_V6_ILP32_OFF32" - 1;
+          }
 #endif
-#if _POSIX_V6_LP64_OFF64 > 0
-# if _POSIX_V6_ILP32_OFF32 > 0 || _POSIX_V6_ILP32_OFFBIG > 0
-	"\n"
-# endif
-	"_POSIX_V6_LP64_OFF64"
+#ifndef _POSIX_V6_ILP32_OFFBIG
+        if (__sysconf (_SC_V6_ILP32_OFFBIG) > 0)
 #endif
-#if _POSIX_V6_LPBIG_OFFBIG > 0
-# if _POSIX_V6_ILP32_OFF32 > 0 || _POSIX_V6_ILP32_OFFBIG > 0 \
-     || _POSIX_V6_LP64_OFF64 > 0
-	"\n"
-# endif
-	"_POSIX_V6_LPBIG_OFFBIG"
+#if !defined _POSIX_V6_ILP32_OFFBIG || _POSIX_V6_ILP32_OFFBIG > 0
+          {
+            if (string_len)
+              restenvs[string_len++] = '\n';
+            memcpy (restenvs + string_len, "_POSIX_V6_ILP32_OFFBIG",
+                    sizeof "_POSIX_V6_ILP32_OFFBIG" - 1);
+            string_len += sizeof "_POSIX_V6_ILP32_OFFBIG" - 1;
+          }
+#endif
+#ifndef _POSIX_V6_LP64_OFF64
+        if (__sysconf (_SC_V6_LP64_OFF64) > 0)
+#endif
+#if !defined _POSIX_V6_LP64_OFF64 || _POSIX_V6_LP64_OFF64 > 0
+          {
+            if (string_len)
+              restenvs[string_len++] = '\n';
+            memcpy (restenvs + string_len, "_POSIX_V6_LP64_OFF64",
+                    sizeof "_POSIX_V6_LP64_OFF64" - 1);
+            string_len += sizeof "_POSIX_V6_LP64_OFF64" - 1;
+          }
+#endif
+#ifndef _POSIX_V6_LPBIG_OFFBIG
+        if (__sysconf (_SC_V6_LPBIG_OFFBIG) > 0)
+#endif
+#if !defined _POSIX_V6_LPBIG_OFFBIG || _POSIX_V6_LPBIG_OFFBIG > 0
+          {
+            if (string_len)
+              restenvs[string_len++] = '\n';
+            memcpy (restenvs + string_len, "_POSIX_V6_LPBIG_OFFBIG",
+                    sizeof "_POSIX_V6_LPBIG_OFFBIG" - 1);
+            string_len += sizeof "_POSIX_V6_LPBIG_OFFBIG" - 1;
+          }
 #endif
-	  ;
+        restenvs[string_len++] = '\0';
 	string = restenvs;
-	string_len = sizeof (restenvs);
       }
       break;
 
+    case _CS_XBS5_ILP32_OFF32_CFLAGS:
+    case _CS_POSIX_V6_ILP32_OFF32_CFLAGS:
+#ifdef __ILP32_OFF32_CFLAGS
+# if _POSIX_V6_ILP32_OFF32 == -1
+#  error __ILP32_OFF32_CFLAGS shouldn't be defined
+# elif !defined _POSIX_V6_ILP32_OFF32
+      if (__sysconf (_SC_V6_ILP32_OFF32) < 0)
+        break;
+# endif
+      string = __ILP32_OFF32_CFLAGS;
+      string_len = sizeof (__ILP32_OFF32_CFLAGS);
+#endif
+      break;
+
     case _CS_XBS5_ILP32_OFFBIG_CFLAGS:
     case _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS:
+#ifdef __ILP32_OFFBIG_CFLAGS
+# if _POSIX_V6_ILP32_OFFBIG == -1
+#  error __ILP32_OFFBIG_CFLAGS shouldn't be defined
+# elif !defined _POSIX_V6_ILP32_OFFBIG
+      if (__sysconf (_SC_V6_ILP32_OFFBIG) < 0)
+        break;
+# endif
+      string = __ILP32_OFFBIG_CFLAGS;
+      string_len = sizeof (__ILP32_OFFBIG_CFLAGS);
+#endif
+      break;
+
+    case _CS_XBS5_LP64_OFF64_CFLAGS:
+    case _CS_POSIX_V6_LP64_OFF64_CFLAGS:
+#ifdef __LP64_OFF64_CFLAGS
+# if _POSIX_V6_LP64_OFF64 == -1
+#  error __LP64_OFF64_CFLAGS shouldn't be defined
+# elif !defined _POSIX_V6_LP64_OFF64
+      if (__sysconf (_SC_V6_LP64_OFF64) < 0)
+        break;
+# endif
+      string = __LP64_OFF64_CFLAGS;
+      string_len = sizeof (__LP64_OFF64_CFLAGS);
+#endif
+      break;
+
+    case _CS_XBS5_ILP32_OFF32_LDFLAGS:
+    case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:
+#ifdef __ILP32_OFF32_LDFLAGS
+# if _POSIX_V6_ILP32_OFF32 == -1
+#  error __ILP32_OFF32_LDFLAGS shouldn't be defined
+# elif !defined _POSIX_V6_ILP32_OFF32
+      if (__sysconf (_SC_V6_ILP32_OFF32) < 0)
+        break;
+# endif
+      string = __ILP32_OFF32_LDFLAGS;
+      string_len = sizeof (__ILP32_OFF32_LDFLAGS);
+#endif
+      break;
+
+    case _CS_XBS5_ILP32_OFFBIG_LDFLAGS:
+    case _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS:
+#ifdef __ILP32_OFFBIG_LDFLAGS
+# if _POSIX_V6_ILP32_OFFBIG == -1
+#  error __ILP32_OFFBIG_LDFLAGS shouldn't be defined
+# elif !defined _POSIX_V6_ILP32_OFFBIG
+      if (__sysconf (_SC_V6_ILP32_OFFBIG) < 0)
+        break;
+# endif
+      string = __ILP32_OFFBIG_LDFLAGS;
+      string_len = sizeof (__ILP32_OFFBIG_LDFLAGS);
+#endif
+      break;
+
+    case _CS_XBS5_LP64_OFF64_LDFLAGS:
+    case _CS_POSIX_V6_LP64_OFF64_LDFLAGS:
+#ifdef __LP64_OFF64_LDFLAGS
+# if _POSIX_V6_LP64_OFF64 == -1
+#  error __LP64_OFF64_LDFLAGS shouldn't be defined
+# elif !defined _POSIX_V6_LP64_OFF64
+      if (__sysconf (_SC_V6_LP64_OFF64) < 0)
+        break;
+# endif
+      string = __LP64_OFF64_LDFLAGS;
+      string_len = sizeof (__LP64_OFF64_LDFLAGS);
+#endif
+      break;
+
     case _CS_LFS_CFLAGS:
     case _CS_LFS_LINTFLAGS:
-#if _XBS5_LP64_OFF64 == -1 && _XBS5_LPBIG_OFFBIG == -1 && _XBS5_ILP32_OFFBIG == 1
+#if _POSIX_V6_ILP32_OFF32 == 1 && _POSIX_V6_ILP32_OFFBIG == 1
+# define __LFS_CFLAGS "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
       /* Signal that we want the new ABI.  */
-      {
-	static const char file_offset[]
-	  = "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64";
-	string = file_offset;
-	string_len = sizeof (file_offset);
-      }
-      break;
+      string = __LFS_CFLAGS;
+      string_len = sizeof (__LFS_CFLAGS);
 #endif
-      /* FALLTHROUGH */
+      break;
 
     case _CS_LFS_LDFLAGS:
     case _CS_LFS_LIBS:
@@ -106,12 +210,9 @@ confstr (name, buf, len)
 
     case _CS_LFS64_CFLAGS:
     case _CS_LFS64_LINTFLAGS:
-      if (sizeof (off_t) != sizeof (off64_t))
-	{
-	  static const char lf64_source[] = "-D_LARGEFILE64_SOURCE";
-	  string = lf64_source;
-	  string_len = sizeof (lf64_source);
-	}
+#define __LFS64_CFLAGS "-D_LARGEFILE64_SOURCE"
+      string = __LFS64_CFLAGS;
+      string_len = sizeof (__LFS64_CFLAGS);
       break;
 
     case _CS_LFS64_LDFLAGS:
@@ -119,15 +220,10 @@ confstr (name, buf, len)
       /* No special libraries or linker flags needed.  */
       break;
 
-    case _CS_XBS5_ILP32_OFF32_CFLAGS:
-    case _CS_XBS5_ILP32_OFF32_LDFLAGS:
     case _CS_XBS5_ILP32_OFF32_LIBS:
     case _CS_XBS5_ILP32_OFF32_LINTFLAGS:
-    case _CS_XBS5_ILP32_OFFBIG_LDFLAGS:
     case _CS_XBS5_ILP32_OFFBIG_LIBS:
     case _CS_XBS5_ILP32_OFFBIG_LINTFLAGS:
-    case _CS_XBS5_LP64_OFF64_CFLAGS:
-    case _CS_XBS5_LP64_OFF64_LDFLAGS:
     case _CS_XBS5_LP64_OFF64_LIBS:
     case _CS_XBS5_LP64_OFF64_LINTFLAGS:
     case _CS_XBS5_LPBIG_OFFBIG_CFLAGS:
@@ -135,15 +231,10 @@ confstr (name, buf, len)
     case _CS_XBS5_LPBIG_OFFBIG_LIBS:
     case _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS:
 
-    case _CS_POSIX_V6_ILP32_OFF32_CFLAGS:
-    case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:
     case _CS_POSIX_V6_ILP32_OFF32_LIBS:
     case _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS:
-    case _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS:
     case _CS_POSIX_V6_ILP32_OFFBIG_LIBS:
     case _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS:
-    case _CS_POSIX_V6_LP64_OFF64_CFLAGS:
-    case _CS_POSIX_V6_LP64_OFF64_LDFLAGS:
     case _CS_POSIX_V6_LP64_OFF64_LIBS:
     case _CS_POSIX_V6_LP64_OFF64_LINTFLAGS:
     case _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS:
--- libc/posix/getconf.c.jj	2004-03-13 10:23:14.000000000 +0100
+++ libc/posix/getconf.c	2004-11-25 23:23:12.098597221 +0100
@@ -917,12 +917,12 @@ static const struct conf vars[] =
   };
 
 
-static const char *specs[] =
+static struct { const char *name; int num; } specs[] =
   {
-    "POSIX_V6_ILP32_OFF32",
-    "POSIX_V6_ILP32_OFFBIG",
-    "POSIX_V6_LP64_OFF64",
-    "POSIX_V6_LPBIG_OFFBIG"
+    { "POSIX_V6_ILP32_OFF32", _SC_V6_ILP32_OFF32 },
+    { "POSIX_V6_ILP32_OFFBIG", _SC_V6_ILP32_OFFBIG },
+    { "POSIX_V6_LP64_OFF64", _SC_V6_LP64_OFF64 },
+    { "POSIX_V6_LPBIG_OFFBIG", _SC_V6_LPBIG_OFFBIG }
   };
 static const int nspecs = sizeof (specs) / sizeof (specs[0]);
 
@@ -963,11 +963,14 @@ warranty; not even for MERCHANTABILITY o
       return 0;
     }
 
+  const char *getconf_dir = getenv ("GETCONF_DIR") ?: GETCONF_DIR;
+  size_t getconf_dirlen = strlen (getconf_dir);
+
+  const char *spec = NULL;
+  char buf[sizeof "POSIX_V6_LPBIG_OFFBIG"];
+  char *argv0 = argv[0];
   if (argc > 1 && strncmp (argv[1], "-v", 2) == 0)
     {
-      const char *spec;
-      int i;
-
       if (argv[1][2] == '\0')
 	{
 	  if (argc < 3)
@@ -983,18 +986,62 @@ warranty; not even for MERCHANTABILITY o
 	  argv += 1;
 	  argc += 1;
 	}
+    }
+  else
+    {
+      char default_name[getconf_dirlen + sizeof "/default"];
+      memcpy (mempcpy (default_name, getconf_dir, getconf_dirlen),
+              "/default", sizeof "/default");
+      int len = readlink (default_name, buf, sizeof buf - 1);
+      if (len > 0)
+	{
+	  buf[len] = '\0';
+	  spec = buf;
+	}
+    }
 
-      /* Check for the specifications we know.  This is simple in the
-	 moment.  */
+  /* Check for the specifications we know.  */
+  if (spec != NULL)
+    {
+      int i;
       for (i = 0; i < nspecs; ++i)
-	if (strcmp (spec, specs[i]) == 0)
+	if (strcmp (spec, specs[i].name) == 0)
 	  break;
 
       if (i == nspecs)
 	error (2, 0, _("unknown specification \"%s\""), spec);
 
-      /* And now we forget the specification.  We don't do anything different
-	 with or without it.  */
+      switch (specs[i].num)
+	{
+#ifndef _POSIX_V6_ILP32_OFF32
+	  case _SC_V6_ILP32_OFF32:
+#endif
+#ifndef _POSIX_V6_ILP32_OFFBIG
+	  case _SC_V6_ILP32_OFFBIG:
+#endif
+#ifndef _POSIX_V6_LP64_OFF64
+	  case _SC_V6_LP64_OFF64:
+#endif
+#ifndef _POSIX_V6_LPBIG_OFFBIG
+	  case _SC_V6_LPBIG_OFFBIG:
+#endif
+	    {
+	      const char *args[argc + 3];
+	      size_t spec_len = strlen (spec);
+	      char getconf_name[getconf_dirlen + 2 + spec_len + 1];
+	      memcpy (mempcpy (mempcpy (getconf_name, getconf_dir,
+	                                getconf_dirlen),
+                               "/_", 2), spec, spec_len + 1);
+	      args[0] = argv0;
+	      args[1] = "-v";
+	      args[2] = spec;
+	      memcpy (&args[3], &argv[1], argc * sizeof (argv[1]));
+	      execv (getconf_name, (char * const *) args);
+	      error (4, errno, _("Couldn't execute %s"), getconf_name);
+	    }
+	  default:
+	    break;
+	}
     }
 
   if (argc < 2 || argc > 3)
--- libc/sysdeps/unix/bsd/bsd4.4/freebsd/bits/environments.h.jj	2004-11-25 14:47:03.000000000 +0100
+++ libc/sysdeps/unix/bsd/bsd4.4/freebsd/bits/environments.h	2004-11-25 14:52:42.000000000 +0100
@@ -0,0 +1,72 @@
+/* Copyright (C) 1999, 2001, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _UNISTD_H
+# error "Never include this file directly.  Use <unistd.h> instead"
+#endif
+
+#include <bits/wordsize.h>
+
+/* This header should define the following symbols under the described
+   situations.  A value `1' means that the model is always supported,
+   `-1' means it is never supported.  Undefined means it cannot be
+   statically decided.
+
+   _POSIX_V6_ILP32_OFF32   32bit int, long, pointers, and off_t type
+   _POSIX_V6_ILP32_OFFBIG  32bit int, long, and pointers and larger off_t type
+
+   _POSIX_V6_LP64_OFF32	   64bit long and pointers and 32bit off_t type
+   _POSIX_V6_LPBIG_OFFBIG  64bit long and pointers and large off_t type
+
+   The macros _XBS5_ILP32_OFF32, _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and
+   _XBS5_LPBIG_OFFBIG were used in previous versions of the Unix standard
+   and are available only for compatibility.
+*/
+
+#if __WORDSIZE == 64
+
+/* We can never provide environments with 32-bit wide pointers.  */
+# define _POSIX_V6_ILP32_OFF32	-1
+# define _POSIX_V6_ILP32_OFFBIG	-1
+# define _XBS5_ILP32_OFF32	-1
+# define _XBS5_ILP32_OFFBIG	-1
+/* We also have no use (for now) for an environment with bigger pointers
+   and offsets.  */
+# define _POSIX_V6_LPBIG_OFFBIG	-1
+# define _XBS5_LPBIG_OFFBIG	-1
+
+/* By default we have 64-bit wide `long int', pointers and `off_t'.  */
+# define _POSIX_V6_LP64_OFF64	1
+# define _XBS5_LP64_OFF64	1
+
+#else /* __WORDSIZE == 32 */
+
+/* By default we have 32-bit wide `int', `long int', pointers
+   and 64-bit `off_t'.  */
+# define _POSIX_V6_ILP32_OFF32	-1
+# define _POSIX_V6_ILP32_OFFBIG	1
+# define _XBS5_ILP32_OFF32	-1
+# define _XBS5_ILP32_OFFBIG	1
+
+/* We can never provide environments with 64-bit wide pointers.  */
+# define _POSIX_V6_LP64_OFF64	-1
+# define _POSIX_V6_LPBIG_OFFBIG	-1
+# define _XBS5_LP64_OFF64	-1
+# define _XBS5_LPBIG_OFFBIG	-1
+
+#endif /* __WORDSIZE == 32 */
--- libc/sysdeps/unix/sysv/linux/s390/bits/environments.h.jj	2004-11-25 15:07:07.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/s390/bits/environments.h	2004-11-25 22:39:26.000000000 +0100
@@ -0,0 +1,87 @@
+/* Copyright (C) 1999, 2001, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _UNISTD_H
+# error "Never include this file directly.  Use <unistd.h> instead"
+#endif
+
+#include <bits/wordsize.h>
+
+/* This header should define the following symbols under the described
+   situations.  A value `1' means that the model is always supported,
+   `-1' means it is never supported.  Undefined means it cannot be
+   statically decided.
+
+   _POSIX_V6_ILP32_OFF32   32bit int, long, pointers, and off_t type
+   _POSIX_V6_ILP32_OFFBIG  32bit int, long, and pointers and larger off_t type
+
+   _POSIX_V6_LP64_OFF32	   64bit long and pointers and 32bit off_t type
+   _POSIX_V6_LPBIG_OFFBIG  64bit long and pointers and large off_t type
+
+   The macros _XBS5_ILP32_OFF32, _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and
+   _XBS5_LPBIG_OFFBIG were used in previous versions of the Unix standard
+   and are available only for compatibility.
+*/
+
+#if __WORDSIZE == 64
+
+/* Environments with 32-bit wide pointers are optionally provided.
+   Therefore following macros aren't defined:
+   # undef _POSIX_V6_ILP32_OFF32
+   # undef _POSIX_V6_ILP32_OFFBIG
+   # undef _XBS5_ILP32_OFF32
+   # undef _XBS5_ILP32_OFFBIG
+   and users need to check at runtime.  */
+
+/* We also have no use (for now) for an environment with bigger pointers
+   and offsets.  */
+# define _POSIX_V6_LPBIG_OFFBIG	-1
+# define _XBS5_LPBIG_OFFBIG	-1
+
+/* By default we have 64-bit wide `long int', pointers and `off_t'.  */
+# define _POSIX_V6_LP64_OFF64	1
+# define _XBS5_LP64_OFF64	1
+
+#else /* __WORDSIZE == 32 */
+
+/* By default we have 32-bit wide `int', `long int', pointers and `off_t'
+   and all platforms support LFS.  */
+# define _POSIX_V6_ILP32_OFF32	1
+# define _POSIX_V6_ILP32_OFFBIG	1
+# define _XBS5_ILP32_OFF32	1
+# define _XBS5_ILP32_OFFBIG	1
+
+/* We optionally provide an environment with the above size but an 64-bit
+   side `off_t'.  Therefore we don't define _XBS5_ILP32_OFFBIG.  */
+
+/* Environments with 64-bit wide pointers can be provided,
+   so these macros aren't defined:
+   # undef _POSIX_V6_LP64_OFF64
+   # undef _POSIX_V6_LPBIG_OFFBIG
+   # undef _XBS5_LP64_OFF64
+   # undef _XBS5_LPBIG_OFFBIG
+   and sysconf tests for it at runtime.  */
+
+#endif /* __WORDSIZE == 32 */
+
+#define __ILP32_OFF32_CFLAGS	"-m31"
+#define __ILP32_OFFBIG_CFLAGS	"-m31 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+#define __ILP32_OFF32_LDFLAGS	"-m31"
+#define __ILP32_OFFBIG_LDFLAGS	"-m31"
+#define __LP64_OFF64_CFLAGS	"-m64"
+#define __LP64_OFF64_LDFLAGS	"-m64"
--- libc/sysdeps/unix/sysv/linux/powerpc/bits/environments.h.jj	2004-11-25 15:07:07.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/powerpc/bits/environments.h	2004-11-25 22:39:52.000000000 +0100
@@ -0,0 +1,87 @@
+/* Copyright (C) 1999, 2001, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _UNISTD_H
+# error "Never include this file directly.  Use <unistd.h> instead"
+#endif
+
+#include <bits/wordsize.h>
+
+/* This header should define the following symbols under the described
+   situations.  A value `1' means that the model is always supported,
+   `-1' means it is never supported.  Undefined means it cannot be
+   statically decided.
+
+   _POSIX_V6_ILP32_OFF32   32bit int, long, pointers, and off_t type
+   _POSIX_V6_ILP32_OFFBIG  32bit int, long, and pointers and larger off_t type
+
+   _POSIX_V6_LP64_OFF32	   64bit long and pointers and 32bit off_t type
+   _POSIX_V6_LPBIG_OFFBIG  64bit long and pointers and large off_t type
+
+   The macros _XBS5_ILP32_OFF32, _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and
+   _XBS5_LPBIG_OFFBIG were used in previous versions of the Unix standard
+   and are available only for compatibility.
+*/
+
+#if __WORDSIZE == 64
+
+/* Environments with 32-bit wide pointers are optionally provided.
+   Therefore following macros aren't defined:
+   # undef _POSIX_V6_ILP32_OFF32
+   # undef _POSIX_V6_ILP32_OFFBIG
+   # undef _XBS5_ILP32_OFF32
+   # undef _XBS5_ILP32_OFFBIG
+   and users need to check at runtime.  */
+
+/* We also have no use (for now) for an environment with bigger pointers
+   and offsets.  */
+# define _POSIX_V6_LPBIG_OFFBIG	-1
+# define _XBS5_LPBIG_OFFBIG	-1
+
+/* By default we have 64-bit wide `long int', pointers and `off_t'.  */
+# define _POSIX_V6_LP64_OFF64	1
+# define _XBS5_LP64_OFF64	1
+
+#else /* __WORDSIZE == 32 */
+
+/* By default we have 32-bit wide `int', `long int', pointers and `off_t'
+   and all platforms support LFS.  */
+# define _POSIX_V6_ILP32_OFF32	1
+# define _POSIX_V6_ILP32_OFFBIG	1
+# define _XBS5_ILP32_OFF32	1
+# define _XBS5_ILP32_OFFBIG	1
+
+/* We optionally provide an environment with the above size but an 64-bit
+   side `off_t'.  Therefore we don't define _XBS5_ILP32_OFFBIG.  */
+
+/* Environments with 64-bit wide pointers can be provided,
+   so these macros aren't defined:
+   # undef _POSIX_V6_LP64_OFF64
+   # undef _POSIX_V6_LPBIG_OFFBIG
+   # undef _XBS5_LP64_OFF64
+   # undef _XBS5_LPBIG_OFFBIG
+   and sysconf tests for it at runtime.  */
+
+#endif /* __WORDSIZE == 32 */
+
+#define __ILP32_OFF32_CFLAGS	"-m32"
+#define __ILP32_OFFBIG_CFLAGS	"-m32 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+#define __ILP32_OFF32_LDFLAGS	"-m32"
+#define __ILP32_OFFBIG_LDFLAGS	"-m32"
+#define __LP64_OFF64_CFLAGS	"-m64"
+#define __LP64_OFF64_LDFLAGS	"-m64"
--- libc/sysdeps/unix/sysv/linux/sparc/bits/environments.h.jj	2004-11-25 15:07:07.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/sparc/bits/environments.h	2004-11-25 22:40:18.000000000 +0100
@@ -0,0 +1,87 @@
+/* Copyright (C) 1999, 2001, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _UNISTD_H
+# error "Never include this file directly.  Use <unistd.h> instead"
+#endif
+
+#include <bits/wordsize.h>
+
+/* This header should define the following symbols under the described
+   situations.  A value `1' means that the model is always supported,
+   `-1' means it is never supported.  Undefined means it cannot be
+   statically decided.
+
+   _POSIX_V6_ILP32_OFF32   32bit int, long, pointers, and off_t type
+   _POSIX_V6_ILP32_OFFBIG  32bit int, long, and pointers and larger off_t type
+
+   _POSIX_V6_LP64_OFF32	   64bit long and pointers and 32bit off_t type
+   _POSIX_V6_LPBIG_OFFBIG  64bit long and pointers and large off_t type
+
+   The macros _XBS5_ILP32_OFF32, _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and
+   _XBS5_LPBIG_OFFBIG were used in previous versions of the Unix standard
+   and are available only for compatibility.
+*/
+
+#if __WORDSIZE == 64
+
+/* Environments with 32-bit wide pointers are optionally provided.
+   Therefore following macros aren't defined:
+   # undef _POSIX_V6_ILP32_OFF32
+   # undef _POSIX_V6_ILP32_OFFBIG
+   # undef _XBS5_ILP32_OFF32
+   # undef _XBS5_ILP32_OFFBIG
+   and users need to check at runtime.  */
+
+/* We also have no use (for now) for an environment with bigger pointers
+   and offsets.  */
+# define _POSIX_V6_LPBIG_OFFBIG	-1
+# define _XBS5_LPBIG_OFFBIG	-1
+
+/* By default we have 64-bit wide `long int', pointers and `off_t'.  */
+# define _POSIX_V6_LP64_OFF64	1
+# define _XBS5_LP64_OFF64	1
+
+#else /* __WORDSIZE == 32 */
+
+/* By default we have 32-bit wide `int', `long int', pointers and `off_t'
+   and all platforms support LFS.  */
+# define _POSIX_V6_ILP32_OFF32	1
+# define _POSIX_V6_ILP32_OFFBIG	1
+# define _XBS5_ILP32_OFF32	1
+# define _XBS5_ILP32_OFFBIG	1
+
+/* We optionally provide an environment with the above size but an 64-bit
+   side `off_t'.  Therefore we don't define _XBS5_ILP32_OFFBIG.  */
+
+/* Environments with 64-bit wide pointers can be provided,
+   so these macros aren't defined:
+   # undef _POSIX_V6_LP64_OFF64
+   # undef _POSIX_V6_LPBIG_OFFBIG
+   # undef _XBS5_LP64_OFF64
+   # undef _XBS5_LPBIG_OFFBIG
+   and sysconf tests for it at runtime.  */
+
+#endif /* __WORDSIZE == 32 */
+
+#define __ILP32_OFF32_CFLAGS	"-m32"
+#define __ILP32_OFFBIG_CFLAGS	"-m32 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+#define __ILP32_OFF32_LDFLAGS	"-m32"
+#define __ILP32_OFFBIG_LDFLAGS	"-m32"
+#define __LP64_OFF64_CFLAGS	"-m64"
+#define __LP64_OFF64_LDFLAGS	"-m64"
--- libc/sysdeps/unix/sysv/linux/i386/bits/environments.h.jj	2004-11-25 14:54:44.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/i386/bits/environments.h	2004-11-25 22:40:53.976979058 +0100
@@ -0,0 +1,62 @@
+/* Copyright (C) 1999, 2001, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _UNISTD_H
+# error "Never include this file directly.  Use <unistd.h> instead"
+#endif
+
+/* This header should define the following symbols under the described
+   situations.  A value `1' means that the model is always supported,
+   `-1' means it is never supported.  Undefined means it cannot be
+   statically decided.
+
+   _POSIX_V6_ILP32_OFF32   32bit int, long, pointers, and off_t type
+   _POSIX_V6_ILP32_OFFBIG  32bit int, long, and pointers and larger off_t type
+
+   _POSIX_V6_LP64_OFF32	   64bit long and pointers and 32bit off_t type
+   _POSIX_V6_LPBIG_OFFBIG  64bit long and pointers and large off_t type
+
+   The macros _XBS5_ILP32_OFF32, _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and
+   _XBS5_LPBIG_OFFBIG were used in previous versions of the Unix standard
+   and are available only for compatibility.
+*/
+
+/* By default we have 32-bit wide `int', `long int', pointers and `off_t'
+   and all platforms support LFS.  */
+#define _POSIX_V6_ILP32_OFF32	1
+#define _POSIX_V6_ILP32_OFFBIG	1
+#define _XBS5_ILP32_OFF32	1
+#define _XBS5_ILP32_OFFBIG	1
+
+/* We optionally provide an environment with the above size but an 64-bit
+   side `off_t'.  Therefore we don't define _XBS5_ILP32_OFFBIG.  */
+
+/* Environments with 64-bit wide pointers can be provided,
+   so these macros aren't defined:
+   # undef _POSIX_V6_LP64_OFF64
+   # undef _POSIX_V6_LPBIG_OFFBIG
+   # undef _XBS5_LP64_OFF64
+   # undef _XBS5_LPBIG_OFFBIG
+   and sysconf tests for it at runtime.  */
+
+#define __ILP32_OFF32_CFLAGS	"-m32"
+#define __ILP32_OFFBIG_CFLAGS	"-m32 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+#define __ILP32_OFF32_LDFLAGS	"-m32"
+#define __ILP32_OFFBIG_LDFLAGS	"-m32"
+#define __LP64_OFF64_CFLAGS	"-m64"
+#define __LP64_OFF64_LDFLAGS	"-m64"
--- libc/sysdeps/unix/sysv/linux/x86_64/bits/environments.h.jj	2004-11-25 15:07:07.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/x86_64/bits/environments.h	2004-11-25 22:41:09.000000000 +0100
@@ -0,0 +1,87 @@
+/* Copyright (C) 1999, 2001, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _UNISTD_H
+# error "Never include this file directly.  Use <unistd.h> instead"
+#endif
+
+#include <bits/wordsize.h>
+
+/* This header should define the following symbols under the described
+   situations.  A value `1' means that the model is always supported,
+   `-1' means it is never supported.  Undefined means it cannot be
+   statically decided.
+
+   _POSIX_V6_ILP32_OFF32   32bit int, long, pointers, and off_t type
+   _POSIX_V6_ILP32_OFFBIG  32bit int, long, and pointers and larger off_t type
+
+   _POSIX_V6_LP64_OFF32	   64bit long and pointers and 32bit off_t type
+   _POSIX_V6_LPBIG_OFFBIG  64bit long and pointers and large off_t type
+
+   The macros _XBS5_ILP32_OFF32, _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and
+   _XBS5_LPBIG_OFFBIG were used in previous versions of the Unix standard
+   and are available only for compatibility.
+*/
+
+#if __WORDSIZE == 64
+
+/* Environments with 32-bit wide pointers are optionally provided.
+   Therefore following macros aren't defined:
+   # undef _POSIX_V6_ILP32_OFF32
+   # undef _POSIX_V6_ILP32_OFFBIG
+   # undef _XBS5_ILP32_OFF32
+   # undef _XBS5_ILP32_OFFBIG
+   and users need to check at runtime.  */
+
+/* We also have no use (for now) for an environment with bigger pointers
+   and offsets.  */
+# define _POSIX_V6_LPBIG_OFFBIG	-1
+# define _XBS5_LPBIG_OFFBIG	-1
+
+/* By default we have 64-bit wide `long int', pointers and `off_t'.  */
+# define _POSIX_V6_LP64_OFF64	1
+# define _XBS5_LP64_OFF64	1
+
+#else /* __WORDSIZE == 32 */
+
+/* By default we have 32-bit wide `int', `long int', pointers and `off_t'
+   and all platforms support LFS.  */
+# define _POSIX_V6_ILP32_OFF32	1
+# define _POSIX_V6_ILP32_OFFBIG	1
+# define _XBS5_ILP32_OFF32	1
+# define _XBS5_ILP32_OFFBIG	1
+
+/* We optionally provide an environment with the above size but an 64-bit
+   side `off_t'.  Therefore we don't define _XBS5_ILP32_OFFBIG.  */
+
+/* Environments with 64-bit wide pointers can be provided,
+   so these macros aren't defined:
+   # undef _POSIX_V6_LP64_OFF64
+   # undef _POSIX_V6_LPBIG_OFFBIG
+   # undef _XBS5_LP64_OFF64
+   # undef _XBS5_LPBIG_OFFBIG
+   and sysconf tests for it at runtime.  */
+
+#endif /* __WORDSIZE == 32 */
+
+#define __ILP32_OFF32_CFLAGS	"-m32"
+#define __ILP32_OFFBIG_CFLAGS	"-m32 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+#define __ILP32_OFF32_LDFLAGS	"-m32"
+#define __ILP32_OFFBIG_LDFLAGS	"-m32"
+#define __LP64_OFF64_CFLAGS	"-m64"
+#define __LP64_OFF64_LDFLAGS	"-m64"
--- libc/sysdeps/posix/sysconf.c.jj	2004-06-11 14:46:00.000000000 +0200
+++ libc/sysdeps/posix/sysconf.c	2004-11-25 22:47:52.000000000 +0100
@@ -23,14 +23,20 @@
 #include <pwd.h>
 #include <stddef.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <time.h>
 #include <unistd.h>
 #include <sys/param.h>
+#include <sys/stat.h>
 #include <sys/sysinfo.h>
 #include <sys/types.h>
 #include <regex.h>
 
 
+static long int __sysconf_check_spec (const char *spec);
+
+
 /* Get the value of the system variable NAME.  */
 long int
 __sysconf (name)
@@ -781,50 +787,50 @@ __sysconf (name)
 #ifdef _XBS5_ILP32_OFF32
       return _XBS5_ILP32_OFF32;
 #else
-      return -1;
+      return __sysconf_check_spec ("ILP32_OFF32");
 #endif
     case _SC_XBS5_ILP32_OFFBIG:
 #ifdef _XBS5_ILP32_OFFBIG
       return _XBS5_ILP32_OFFBIG;
 #else
-      return -1;
+      return __sysconf_check_spec ("ILP32_OFFBIG");
 #endif
     case _SC_XBS5_LP64_OFF64:
 #ifdef _XBS5_LP64_OFF64
       return _XBS5_LP64_OFF64;
 #else
-      return -1;
+      return __sysconf_check_spec ("LP64_OFF64");
 #endif
     case _SC_XBS5_LPBIG_OFFBIG:
 #ifdef _XBS5_LPBIG_OFFBIG
       return _XBS5_LPBIG_OFFBIG;
 #else
-      return -1;
+      return __sysconf_check_spec ("LPBIG_OFFBIG");
 #endif
 
     case _SC_V6_ILP32_OFF32:
 #ifdef _POSIX_V6_ILP32_OFF32
       return _POSIX_V6_ILP32_OFF32;
 #else
-      return -1;
+      return __sysconf_check_spec ("ILP32_OFF32");
 #endif
     case _SC_V6_ILP32_OFFBIG:
 #ifdef _POSIX_V6_ILP32_OFFBIG
       return _POSIX_V6_ILP32_OFFBIG;
 #else
-      return -1;
+      return __sysconf_check_spec ("ILP32_OFFBIG");
 #endif
     case _SC_V6_LP64_OFF64:
 #ifdef _POSIX_V6_LP64_OFF64
       return _POSIX_V6_LP64_OFF64;
 #else
-      return -1;
+      return __sysconf_check_spec ("LP64_OFF64");
 #endif
     case _SC_V6_LPBIG_OFFBIG:
 #ifdef _POSIX_V6_LPBIG_OFFBIG
       return _POSIX_V6_LPBIG_OFFBIG;
 #else
-      return -1;
+      return __sysconf_check_spec ("LPBIG_OFFBIG");
 #endif
 
     case _SC_XOPEN_LEGACY:
@@ -1189,3 +1195,24 @@ __sysconf (name)
 #undef __sysconf
 weak_alias (__sysconf, sysconf)
 libc_hidden_def (__sysconf)
+
+static long int
+__sysconf_check_spec (const char *spec)
+{
+  int save_errno = errno;
+
+  const char *getconf_dir = __secure_getenv ("GETCONF_DIR") ?: GETCONF_DIR;
+  size_t getconf_dirlen = strlen (getconf_dir);
+  size_t speclen = strlen (spec);
+
+  char name[getconf_dirlen + sizeof ("/_POSIX_V6_") + speclen];
+  memcpy (mempcpy (mempcpy (name, getconf_dir, getconf_dirlen),
+		   "/_POSIX_V6_", sizeof ("/_POSIX_V6_") - 1),
+	  spec, speclen + 1);
+
+  struct stat64 st;
+  long int ret = __xstat64 (_STAT_VER, name, &st) >= 0 ? 1 : -1;
+
+  __set_errno (save_errno);
+  return ret;
+}
--- libc/sysdeps/generic/bits/environments.h.jj	2001-07-06 06:55:50.000000000 +0200
+++ libc/sysdeps/generic/bits/environments.h	2004-11-25 22:41:41.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2001, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -72,4 +72,7 @@
 # define _XBS5_LP64_OFF64	-1
 # define _XBS5_LPBIG_OFFBIG	-1
 
+/* CFLAGS.  */
+#define __ILP32_OFFBIG_CFLAGS   "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+
 #endif /* __WORDSIZE == 32 */

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]