This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Generate /usr/libexec/getconf files when cross-compiling
On Thu, 15 Nov 2012, Roland McGrath wrote:
> > Here is a refactoring of the existing confstr / sysconf code along
> > those lines, with a structure and using macros designed to be suitable
> > for the build-time use as well (which is not included in this patch).
>
> This looks generally good, though I'd like to see the follow-on patch
> implementing the build-time use before we conclude that this patch is
> right.
This patch includes the build-time parts. Tested x86_64.
> > - case _CS_V7_WIDTH_RESTRICTED_ENVS:
> > - /* We have to return a newline-separated list of named of
> > + /* For _CS_V7_WIDTH_RESTRICTED_ENVS, _CS_V6_WIDTH_RESTRICTED_ENVS
> > + and _CS_V5_WIDTH_RESTRICTED_ENVS:
> > +
> > + We have to return a newline-separated list of named of
>
> Not your typo, but since you're touching the line: s/named/names/
Fixed.
> > +#define KNOWN_ABSENT_ENVIRONMENT(SC_PREFIX, ENV_PREFIX, SUFFIX)
>
> It's conventional practice to use a comment in the rhs of a macro intended
> to expand to empty.
Fixed.
> > +#define KNOWN_PRESENT_ENV_STRING(STR) \
> > + if (string_len) \
>
> Don't use implicit boolean coercion: if (string_len > 0).
Fixed (this was of course an issue in the existing code converted to use
this macro).
> > +#define UNKNOWN_ENVIRONMENT(SC_PREFIX, ENV_PREFIX, SUFFIX) \
> > + if (__sysconf (_SC_##SC_PREFIX##_##SUFFIX) > 0) \
> > + { \
> > + KNOWN_PRESENT_ENVIRONMENT (SC_PREFIX, ENV_PREFIX, SUFFIX) \
> > }
>
> If a macro will be used this way, then make it have a statement-like form
> (i.e. wrap in do { ... } while (0)) so it can appear here without braces
> and with a semicolon.
Changed to make all *_ENVIRONMENT macros statement-like with semicolons in
posix-envs.def.
> > +#include "posix-envs.c"
>
> It's conventional in cases like this to #undef the macros after the
> #include, even if there isn't a second #include. Also, a file like
> this is called foo.def rather than foo.c or foo.h.
Changed in this version
2012-11-15 Joseph Myers <joseph@codesourcery.com>
* posix/getconf-speclist.c: New file.
* posix/posix-envs.def: Likewise.
* posix/confstr.c (START_ENV_GROUP): New macro.
(END_ENV_GROUP): Likewise.
(KNOWN_ABSENT_ENVIRONMENT): Likewise.
(KNOWN_PRESENT_ENV_STRING): Likewise.
(KNOWN_PRESENT_ENVIRONMENT): Likewise.
(UNKNOWN_ENVIRONMENT): Likewise.
(confstr): Include posix-envs.def instead of handling
_CS_V7_WIDTH_RESTRICTED_ENVS, _CS_V6_WIDTH_RESTRICTED_ENVS and
_CS_V5_WIDTH_RESTRICTED_ENVS directly here.
* sysdeps/posix/sysconf.c (START_ENV_GROUP): New macro.
(END_ENV_GROUP): Likewise.
(KNOWN_ABSENT_ENVIRONMENT): Likewise.
(KNOWN_PRESENT_ENVIRONMENT): Likewise.
(UNKNOWN_ENVIRONMENT): Likewise.
(__sysconf): Include posix-envs.def instead of handling associated
cases directly here.
* posix/Makefile ($(objpfx)getconf.speclist): Generate by
preprocessing getconf-speclist.c rather than running getconf or
generating empty file.
diff --git a/posix/Makefile b/posix/Makefile
index 80fbf20..c741b65 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -298,15 +298,8 @@ $(inst_libexecdir)/getconf: $(inst_bindir)/getconf \
mv -f $@/$$spec.new $@/$$spec; \
done < $(objpfx)getconf.speclist
-$(objpfx)getconf.speclist: $(objpfx)getconf
-ifeq (no,$(cross-compiling))
- LC_ALL=C GETCONF_DIR=/dev/null \
- $(run-program-prefix) $< _POSIX_V7_WIDTH_RESTRICTED_ENVS > $@.new
- LC_ALL=C GETCONF_DIR=/dev/null \
- $(run-program-prefix) $< _POSIX_V6_WIDTH_RESTRICTED_ENVS >> $@.new
- LC_ALL=C GETCONF_DIR=/dev/null \
- $(run-program-prefix) $< _XBS5_WIDTH_RESTRICTED_ENVS >> $@.new
-else
- > $@.new
-endif
+$(objpfx)getconf.speclist: getconf-speclist.c posix-envs.def
+ $(compile.c) -E -o - \
+ | grep '@@@PRESENT_' \
+ | sed -e 's/@@@PRESENT_//' -e 's/;//' > $@.new
mv -f $@.new $@
diff --git a/posix/confstr.c b/posix/confstr.c
index cad6561..c262a12 100644
--- a/posix/confstr.c
+++ b/posix/confstr.c
@@ -48,182 +48,59 @@ confstr (name, buf, len)
}
break;
- case _CS_V7_WIDTH_RESTRICTED_ENVS:
- /* We have to return a newline-separated list of named of
+ /* For _CS_V7_WIDTH_RESTRICTED_ENVS, _CS_V6_WIDTH_RESTRICTED_ENVS
+ and _CS_V5_WIDTH_RESTRICTED_ENVS:
+
+ We have to return a newline-separated list of names of
programming environements in which the widths of blksize_t,
cc_t, mode_t, nfds_t, pid_t, ptrdiff_t, size_t, speed_t,
ssize_t, suseconds_t, tcflag_t, useconds_t, wchar_t, and
wint_t types are no greater than the width of type long.
Currently this means all environment which the system allows. */
+
+#define START_ENV_GROUP(VERSION) \
+ case _CS_##VERSION##_WIDTH_RESTRICTED_ENVS: \
string_len = 0;
-#ifndef _POSIX_V7_ILP32_OFF32
- if (__sysconf (_SC_V7_ILP32_OFF32) > 0)
-#endif
-#if !defined _POSIX_V7_ILP32_OFF32 || _POSIX_V7_ILP32_OFF32 > 0
- {
- memcpy (restenvs + string_len, "POSIX_V7_ILP32_OFF32",
- sizeof "POSIX_V7_ILP32_OFF32" - 1);
- string_len += sizeof "POSIX_V7_ILP32_OFF32" - 1;
- }
-#endif
-#ifndef _POSIX_V7_ILP32_OFFBIG
- if (__sysconf (_SC_V7_ILP32_OFFBIG) > 0)
-#endif
-#if !defined _POSIX_V7_ILP32_OFFBIG || _POSIX_V7_ILP32_OFFBIG > 0
- {
- if (string_len)
- restenvs[string_len++] = '\n';
- memcpy (restenvs + string_len, "POSIX_V7_ILP32_OFFBIG",
- sizeof "POSIX_V7_ILP32_OFFBIG" - 1);
- string_len += sizeof "POSIX_V7_ILP32_OFFBIG" - 1;
- }
-#endif
-#ifndef _POSIX_V7_LP64_OFF64
- if (__sysconf (_SC_V7_LP64_OFF64) > 0)
-#endif
-#if !defined _POSIX_V7_LP64_OFF64 || _POSIX_V7_LP64_OFF64 > 0
- {
- if (string_len)
- restenvs[string_len++] = '\n';
- memcpy (restenvs + string_len, "POSIX_V7_LP64_OFF64",
- sizeof "POSIX_V7_LP64_OFF64" - 1);
- string_len += sizeof "POSIX_V7_LP64_OFF64" - 1;
- }
-#endif
-#ifndef _POSIX_V7_LPBIG_OFFBIG
- if (__sysconf (_SC_V7_LPBIG_OFFBIG) > 0)
-#endif
-#if !defined _POSIX_V7_LPBIG_OFFBIG || _POSIX_V7_LPBIG_OFFBIG > 0
- {
- if (string_len)
- restenvs[string_len++] = '\n';
- memcpy (restenvs + string_len, "POSIX_V7_LPBIG_OFFBIG",
- sizeof "POSIX_V7_LPBIG_OFFBIG" - 1);
- string_len += sizeof "POSIX_V7_LPBIG_OFFBIG" - 1;
- }
-#endif
- restenvs[string_len++] = '\0';
- string = restenvs;
+
+#define END_ENV_GROUP(VERSION) \
+ restenvs[string_len++] = '\0'; \
+ string = restenvs; \
break;
- case _CS_V6_WIDTH_RESTRICTED_ENVS:
- /* We have to return a newline-separated list of named of
- programming environements in which the widths of blksize_t,
- cc_t, mode_t, nfds_t, pid_t, ptrdiff_t, size_t, speed_t,
- ssize_t, suseconds_t, tcflag_t, useconds_t, wchar_t, and
- wint_t types are no greater than the width of type long.
+#define KNOWN_ABSENT_ENVIRONMENT(SC_PREFIX, ENV_PREFIX, SUFFIX) \
+ /* Empty. */
- Currently this means all environment which the system allows. */
- string_len = 0;
-#ifndef _POSIX_V6_ILP32_OFF32
- if (__sysconf (_SC_V6_ILP32_OFF32) > 0)
-#endif
-#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
-#ifndef _POSIX_V6_ILP32_OFFBIG
- if (__sysconf (_SC_V6_ILP32_OFFBIG) > 0)
-#endif
-#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;
- break;
+#define KNOWN_PRESENT_ENV_STRING(STR) \
+ do \
+ { \
+ if (string_len > 0) \
+ restenvs[string_len++] = '\n'; \
+ memcpy (restenvs + string_len, STR, \
+ sizeof STR - 1); \
+ string_len += sizeof STR - 1; \
+ } \
+ while (0)
- case _CS_V5_WIDTH_RESTRICTED_ENVS:
- /* We have to return a newline-separated list of named of
- programming environements in which the widths of blksize_t,
- cc_t, mode_t, nfds_t, pid_t, ptrdiff_t, size_t, speed_t,
- ssize_t, suseconds_t, tcflag_t, useconds_t, wchar_t, and
- wint_t types are no greater than the width of type long.
+#define KNOWN_PRESENT_ENVIRONMENT(SC_PREFIX, ENV_PREFIX, SUFFIX) \
+ KNOWN_PRESENT_ENV_STRING (#ENV_PREFIX "_" #SUFFIX)
- Currently this means all environment which the system allows. */
- string_len = 0;
-#ifndef _XBS5_ILP32_OFF32
- if (__sysconf (_SC_XBS5_ILP32_OFF32) > 0)
-#endif
-#if !defined _XBS5_ILP32_OFF32 || _XBS5_ILP32_OFF32 > 0
- {
- memcpy (restenvs + string_len, "XBS5_ILP32_OFF32",
- sizeof "XBS5_ILP32_OFF32" - 1);
- string_len += sizeof "XBS5_ILP32_OFF32" - 1;
- }
-#endif
-#ifndef _XBS5_ILP32_OFFBIG
- if (__sysconf (_SC_XBS5_ILP32_OFFBIG) > 0)
-#endif
-#if !defined _XBS5_ILP32_OFFBIG || _XBS5_ILP32_OFFBIG > 0
- {
- if (string_len)
- restenvs[string_len++] = '\n';
- memcpy (restenvs + string_len, "XBS5_ILP32_OFFBIG",
- sizeof "XBS5_ILP32_OFFBIG" - 1);
- string_len += sizeof "XBS5_ILP32_OFFBIG" - 1;
- }
-#endif
-#ifndef _XBS5_LP64_OFF64
- if (__sysconf (_SC_XBS5_LP64_OFF64) > 0)
-#endif
-#if !defined _XBS5_LP64_OFF64 || _XBS5_LP64_OFF64 > 0
- {
- if (string_len)
- restenvs[string_len++] = '\n';
- memcpy (restenvs + string_len, "XBS5_LP64_OFF64",
- sizeof "XBS5_LP64_OFF64" - 1);
- string_len += sizeof "XBS5_LP64_OFF64" - 1;
- }
-#endif
-#ifndef _XBS5_LPBIG_OFFBIG
- if (__sysconf (_SC_XBS5_LPBIG_OFFBIG) > 0)
-#endif
-#if !defined _XBS5_LPBIG_OFFBIG || _XBS5_LPBIG_OFFBIG > 0
- {
- if (string_len)
- restenvs[string_len++] = '\n';
- memcpy (restenvs + string_len, "XBS5_LPBIG_OFFBIG",
- sizeof "XBS5_LPBIG_OFFBIG" - 1);
- string_len += sizeof "XBS5_LPBIG_OFFBIG" - 1;
- }
-#endif
- restenvs[string_len++] = '\0';
- string = restenvs;
- break;
+#define UNKNOWN_ENVIRONMENT(SC_PREFIX, ENV_PREFIX, SUFFIX) \
+ do \
+ { \
+ if (__sysconf (_SC_##SC_PREFIX##_##SUFFIX) > 0) \
+ KNOWN_PRESENT_ENVIRONMENT (SC_PREFIX, ENV_PREFIX, SUFFIX); \
+ } \
+ while (0)
+
+#include "posix-envs.def"
+
+#undef START_ENV_GROUP
+#undef END_ENV_GROUP
+#undef KNOWN_ABSENT_ENVIRONMENT
+#undef KNOWN_PRESENT_ENV_STRING
+#undef KNOWN_PRESENT_ENVIRONMENT
+#undef UNKNOWN_ENVIRONMENT
case _CS_XBS5_ILP32_OFF32_CFLAGS:
case _CS_POSIX_V6_ILP32_OFF32_CFLAGS:
diff --git a/posix/getconf-speclist.c b/posix/getconf-speclist.c
new file mode 100644
index 0000000..72c5c3d
--- /dev/null
+++ b/posix/getconf-speclist.c
@@ -0,0 +1,42 @@
+/* List POSIX compilation environments for this libc.
+ Copyright (C) 2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <unistd.h>
+
+#define START_ENV_GROUP(VERSION) \
+ /* Empty. */
+
+#define END_ENV_GROUP(VERSION) \
+ /* Empty. */
+
+#define KNOWN_ABSENT_ENVIRONMENT(SC_PREFIX, ENV_PREFIX, SUFFIX) \
+ /* Empty. */
+
+#define KNOWN_PRESENT_ENVIRONMENT(SC_PREFIX, ENV_PREFIX, SUFFIX) \
+ @@@PRESENT_##ENV_PREFIX##_##SUFFIX
+
+#define UNKNOWN_ENVIRONMENT(SC_PREFIX, ENV_PREFIX, SUFFIX) \
+ /* Empty. */
+
+#include "posix-envs.def"
+
+#undef START_ENV_GROUP
+#undef END_ENV_GROUP
+#undef KNOWN_ABSENT_ENVIRONMENT
+#undef KNOWN_PRESENT_ENVIRONMENT
+#undef UNKNOWN_ENVIRONMENT
diff --git a/posix/posix-envs.def b/posix/posix-envs.def
new file mode 100644
index 0000000..d696c7f
--- /dev/null
+++ b/posix/posix-envs.def
@@ -0,0 +1,151 @@
+/* Handle POSIX compilation environments that may or may not be present.
+ Copyright (C) 2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Before including this file, the including file must have included
+ <bits/environments.h> (generally via <unistd.h>) and must have
+ defined the following macros, exactly one of which will be called
+ for each POSIX environment:
+
+ KNOWN_PRESENT_ENVIRONMENT, for POSIX environments that are known to
+ be supported in this libc.
+
+ KNOWN_ABSENT_ENVIRONMENT, for POSIX environments that are known not
+ to be supported on this system.
+
+ UNKNOWN_ENVIRONMENT, for POSIX environments not supported in this
+ libc but possibly supported by another libc on the same system,
+ that can be selected using the same compiler but different
+ compilation options.
+
+ Each macro has arguments (SC_PREFIX, ENV_PREFIX, SUFFIX). The
+ corresponding argument to sysconf is _SC_##SC_PREFIX##_##SUFFIX.
+ The environment name, as used with getconf, is
+ ENV_PREFIX##_##SUFFIX, and the corresponding macro is the same with
+ a leading "_".
+
+ In addition, the macros START_ENV_GROUP and END_ENV_GROUP must be
+ defined. These are called with arguments V5, V6, V7 before and
+ after the relevant groups of environments. */
+
+START_ENV_GROUP (V7)
+
+#if _POSIX_V7_ILP32_OFF32 > 0
+KNOWN_PRESENT_ENVIRONMENT (V7, POSIX_V7, ILP32_OFF32);
+#elif defined _POSIX_V7_ILP32_OFF32
+KNOWN_ABSENT_ENVIRONMENT (V7, POSIX_V7, ILP32_OFF32);
+#else
+UNKNOWN_ENVIRONMENT (V7, POSIX_V7, ILP32_OFF32);
+#endif
+
+#if _POSIX_V7_ILP32_OFFBIG > 0
+KNOWN_PRESENT_ENVIRONMENT (V7, POSIX_V7, ILP32_OFFBIG);
+#elif defined _POSIX_V7_ILP32_OFFBIG
+KNOWN_ABSENT_ENVIRONMENT (V7, POSIX_V7, ILP32_OFFBIG);
+#else
+UNKNOWN_ENVIRONMENT (V7, POSIX_V7, ILP32_OFFBIG);
+#endif
+
+#if _POSIX_V7_LP64_OFF64 > 0
+KNOWN_PRESENT_ENVIRONMENT (V7, POSIX_V7, LP64_OFF64);
+#elif defined _POSIX_V7_LP64_OFF64
+KNOWN_ABSENT_ENVIRONMENT (V7, POSIX_V7, LP64_OFF64);
+#else
+UNKNOWN_ENVIRONMENT (V7, POSIX_V7, LP64_OFF64);
+#endif
+
+#if _POSIX_V7_LPBIG_OFFBIG > 0
+KNOWN_PRESENT_ENVIRONMENT (V7, POSIX_V7, LPBIG_OFFBIG);
+#elif defined _POSIX_V7_LPBIG_OFFBIG
+KNOWN_ABSENT_ENVIRONMENT (V7, POSIX_V7, LPBIG_OFFBIG);
+#else
+UNKNOWN_ENVIRONMENT (V7, POSIX_V7, LPBIG_OFFBIG);
+#endif
+
+END_ENV_GROUP (V7)
+
+START_ENV_GROUP (V6)
+
+#if _POSIX_V6_ILP32_OFF32 > 0
+KNOWN_PRESENT_ENVIRONMENT (V6, POSIX_V6, ILP32_OFF32);
+#elif defined _POSIX_V6_ILP32_OFF32
+KNOWN_ABSENT_ENVIRONMENT (V6, POSIX_V6, ILP32_OFF32);
+#else
+UNKNOWN_ENVIRONMENT (V6, POSIX_V6, ILP32_OFF32);
+#endif
+
+#if _POSIX_V6_ILP32_OFFBIG > 0
+KNOWN_PRESENT_ENVIRONMENT (V6, POSIX_V6, ILP32_OFFBIG);
+#elif defined _POSIX_V6_ILP32_OFFBIG
+KNOWN_ABSENT_ENVIRONMENT (V6, POSIX_V6, ILP32_OFFBIG);
+#else
+UNKNOWN_ENVIRONMENT (V6, POSIX_V6, ILP32_OFFBIG);
+#endif
+
+#if _POSIX_V6_LP64_OFF64 > 0
+KNOWN_PRESENT_ENVIRONMENT (V6, POSIX_V6, LP64_OFF64);
+#elif defined _POSIX_V6_LP64_OFF64
+KNOWN_ABSENT_ENVIRONMENT (V6, POSIX_V6, LP64_OFF64);
+#else
+UNKNOWN_ENVIRONMENT (V6, POSIX_V6, LP64_OFF64);
+#endif
+
+#if _POSIX_V6_LPBIG_OFFBIG > 0
+KNOWN_PRESENT_ENVIRONMENT (V6, POSIX_V6, LPBIG_OFFBIG);
+#elif defined _POSIX_V6_LPBIG_OFFBIG
+KNOWN_ABSENT_ENVIRONMENT (V6, POSIX_V6, LPBIG_OFFBIG);
+#else
+UNKNOWN_ENVIRONMENT (V6, POSIX_V6, LPBIG_OFFBIG);
+#endif
+
+END_ENV_GROUP (V6)
+
+START_ENV_GROUP (V5)
+
+#if _XBS5_ILP32_OFF32 > 0
+KNOWN_PRESENT_ENVIRONMENT (XBS5, XBS5, ILP32_OFF32);
+#elif defined _XBS5_ILP32_OFF32
+KNOWN_ABSENT_ENVIRONMENT (XBS5, XBS5, ILP32_OFF32);
+#else
+UNKNOWN_ENVIRONMENT (XBS5, XBS5, ILP32_OFF32);
+#endif
+
+#if _XBS5_ILP32_OFFBIG > 0
+KNOWN_PRESENT_ENVIRONMENT (XBS5, XBS5, ILP32_OFFBIG);
+#elif defined _XBS5_ILP32_OFFBIG
+KNOWN_ABSENT_ENVIRONMENT (XBS5, XBS5, ILP32_OFFBIG);
+#else
+UNKNOWN_ENVIRONMENT (XBS5, XBS5, ILP32_OFFBIG);
+#endif
+
+#if _XBS5_LP64_OFF64 > 0
+KNOWN_PRESENT_ENVIRONMENT (XBS5, XBS5, LP64_OFF64);
+#elif defined _XBS5_LP64_OFF64
+KNOWN_ABSENT_ENVIRONMENT (XBS5, XBS5, LP64_OFF64);
+#else
+UNKNOWN_ENVIRONMENT (XBS5, XBS5, LP64_OFF64);
+#endif
+
+#if _XBS5_LPBIG_OFFBIG > 0
+KNOWN_PRESENT_ENVIRONMENT (XBS5, XBS5, LPBIG_OFFBIG);
+#elif defined _XBS5_LPBIG_OFFBIG
+KNOWN_ABSENT_ENVIRONMENT (XBS5, XBS5, LPBIG_OFFBIG);
+#else
+UNKNOWN_ENVIRONMENT (XBS5, XBS5, LPBIG_OFFBIG);
+#endif
+
+END_ENV_GROUP (V5)
diff --git a/sysdeps/posix/sysconf.c b/sysdeps/posix/sysconf.c
index bfe28b4..f0e82bc 100644
--- a/sysdeps/posix/sysconf.c
+++ b/sysdeps/posix/sysconf.c
@@ -790,80 +790,31 @@ __sysconf (name)
return -1;
#endif
- case _SC_XBS5_ILP32_OFF32:
-#ifdef _XBS5_ILP32_OFF32
- return _XBS5_ILP32_OFF32;
-#else
- return __sysconf_check_spec ("ILP32_OFF32");
-#endif
- case _SC_XBS5_ILP32_OFFBIG:
-#ifdef _XBS5_ILP32_OFFBIG
- return _XBS5_ILP32_OFFBIG;
-#else
- return __sysconf_check_spec ("ILP32_OFFBIG");
-#endif
- case _SC_XBS5_LP64_OFF64:
-#ifdef _XBS5_LP64_OFF64
- return _XBS5_LP64_OFF64;
-#else
- return __sysconf_check_spec ("LP64_OFF64");
-#endif
- case _SC_XBS5_LPBIG_OFFBIG:
-#ifdef _XBS5_LPBIG_OFFBIG
- return _XBS5_LPBIG_OFFBIG;
-#else
- return __sysconf_check_spec ("LPBIG_OFFBIG");
-#endif
+#define START_ENV_GROUP(VERSION) \
+ /* Empty. */
- case _SC_V6_ILP32_OFF32:
-#ifdef _POSIX_V6_ILP32_OFF32
- return _POSIX_V6_ILP32_OFF32;
-#else
- return __sysconf_check_spec ("ILP32_OFF32");
-#endif
- case _SC_V6_ILP32_OFFBIG:
-#ifdef _POSIX_V6_ILP32_OFFBIG
- return _POSIX_V6_ILP32_OFFBIG;
-#else
- return __sysconf_check_spec ("ILP32_OFFBIG");
-#endif
- case _SC_V6_LP64_OFF64:
-#ifdef _POSIX_V6_LP64_OFF64
- return _POSIX_V6_LP64_OFF64;
-#else
- return __sysconf_check_spec ("LP64_OFF64");
-#endif
- case _SC_V6_LPBIG_OFFBIG:
-#ifdef _POSIX_V6_LPBIG_OFFBIG
- return _POSIX_V6_LPBIG_OFFBIG;
-#else
- return __sysconf_check_spec ("LPBIG_OFFBIG");
-#endif
+#define END_ENV_GROUP(VERSION) \
+ /* Empty. */
- case _SC_V7_ILP32_OFF32:
-#ifdef _POSIX_V7_ILP32_OFF32
- return _POSIX_V7_ILP32_OFF32;
-#else
- return __sysconf_check_spec ("ILP32_OFF32");
-#endif
- case _SC_V7_ILP32_OFFBIG:
-#ifdef _POSIX_V7_ILP32_OFFBIG
- return _POSIX_V7_ILP32_OFFBIG;
-#else
- return __sysconf_check_spec ("ILP32_OFFBIG");
-#endif
- case _SC_V7_LP64_OFF64:
-#ifdef _POSIX_V7_LP64_OFF64
- return _POSIX_V7_LP64_OFF64;
-#else
- return __sysconf_check_spec ("LP64_OFF64");
-#endif
- case _SC_V7_LPBIG_OFFBIG:
-#ifdef _POSIX_V7_LPBIG_OFFBIG
- return _POSIX_V7_LPBIG_OFFBIG;
-#else
- return __sysconf_check_spec ("LPBIG_OFFBIG");
-#endif
+#define KNOWN_ABSENT_ENVIRONMENT(SC_PREFIX, ENV_PREFIX, SUFFIX) \
+ case _SC_##SC_PREFIX##_##SUFFIX: \
+ return _##ENV_PREFIX##_##SUFFIX
+
+#define KNOWN_PRESENT_ENVIRONMENT(SC_PREFIX, ENV_PREFIX, SUFFIX) \
+ case _SC_##SC_PREFIX##_##SUFFIX: \
+ return _##ENV_PREFIX##_##SUFFIX
+
+#define UNKNOWN_ENVIRONMENT(SC_PREFIX, ENV_PREFIX, SUFFIX) \
+ case _SC_##SC_PREFIX##_##SUFFIX: \
+ return __sysconf_check_spec (#SUFFIX)
+
+#include <posix/posix-envs.def>
+
+#undef START_ENV_GROUP
+#undef END_ENV_GROUP
+#undef KNOWN_ABSENT_ENVIRONMENT
+#undef KNOWN_PRESENT_ENVIRONMENT
+#undef UNKNOWN_ENVIRONMENT
case _SC_XOPEN_LEGACY:
return _XOPEN_LEGACY;
--
Joseph S. Myers
joseph@codesourcery.com