arrfab / rpms / glibc

Forked from rpms/glibc 4 years ago
Clone

Blame SOURCES/glibc-rh1505492-undef-49.patch

147e83
commit 4a6aca7bf8a70f1dc66a07c04aba2d7fd837602d
147e83
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
147e83
Date:   Mon Dec 29 17:37:54 2014 +0530
147e83
147e83
    Remove Wundef warnings for specification macros
147e83
    
147e83
    This patch adds a file posix-conf-vars.list that is used to generate
147e83
    macros to determine if a macro is defined as set, unset or not
147e83
    defined.  gen-posix-conf-vars.awk processes this file and generates a
147e83
    header (posix-conf-vars-def.h) with these macros.  A new header
147e83
    posix-conf-vars.h includes this generated header and defines accessor
147e83
    macros for the generated macros.
147e83
    
147e83
    Tested on x86_64.
147e83
    
147e83
            * posix/Makefile (before-compile): Add posix-conf-vars-def.h.
147e83
            ($(objpfx)posix-conf-vars-def.h): New target.
147e83
            * posix/posix-conf-vars.list: New file.
147e83
            * posix/posix-conf-vars.h: New file.
147e83
            * posix/confstr.c: Include posix-conf-vars.h.
147e83
            (confstr): Use CONF_IS_* macros.
147e83
            * posix/posix-envs.def: Include posix-conf-vars.h.  Use
147e83
            CONF_IS_* macros.
147e83
            * scripts/gen-posix-conf-vars.awk: New file.
147e83
147e83
diff --git a/posix/Makefile b/posix/Makefile
147e83
index 4034282866139aaa..c272e87a480f5254 100644
147e83
--- a/posix/Makefile
147e83
+++ b/posix/Makefile
147e83
@@ -96,7 +96,7 @@ others		:= getconf
147e83
 install-bin	:= getconf
147e83
 install-others-programs	:= $(inst_libexecdir)/getconf
147e83
 
147e83
-before-compile	+= testcases.h ptestcases.h
147e83
+before-compile	+= testcases.h ptestcases.h posix-conf-vars-def.h
147e83
 
147e83
 # So they get cleaned up.
147e83
 generated := $(addprefix wordexp-test-result, 1 2 3 4 5 6 7 8 9 10) \
147e83
@@ -288,3 +288,9 @@ $(objpfx)getconf.speclist: getconf-speclist.c posix-envs.def
147e83
 # be built both makes it available for eyeball inspection and avoids the
147e83
 # surprise of things that look like compilation being done by 'make install'.
147e83
 others: $(objpfx)getconf.speclist
147e83
+
147e83
+$(objpfx)posix-conf-vars-def.h: $(..)scripts/gen-posix-conf-vars.awk \
147e83
+				posix-conf-vars.list Makefile
147e83
+	$(make-target-directory)
147e83
+	$(AWK) -f $(filter-out Makefile, $^) > $@.tmp
147e83
+	mv -f $@.tmp $@
147e83
diff --git a/posix/confstr.c b/posix/confstr.c
147e83
index 7d86d60bc177c32d..5b03986a3678e007 100644
147e83
--- a/posix/confstr.c
147e83
+++ b/posix/confstr.c
147e83
@@ -21,6 +21,7 @@
147e83
 #include <string.h>
147e83
 #include <confstr.h>
147e83
 #include "../version.h"
147e83
+#include <posix-conf-vars.h>
147e83
 
147e83
 /* If BUF is not NULL and LEN > 0, fill in at most LEN - 1 bytes
147e83
    of BUF with the value corresponding to NAME and zero-terminate BUF.
147e83
@@ -100,9 +101,9 @@ confstr (name, buf, len)
147e83
     case _CS_POSIX_V6_ILP32_OFF32_CFLAGS:
147e83
     case _CS_POSIX_V7_ILP32_OFF32_CFLAGS:
147e83
 #ifdef __ILP32_OFF32_CFLAGS
147e83
-# if _POSIX_V7_ILP32_OFF32 == -1
147e83
+# if CONF_IS_DEFINED_UNSET (_POSIX_V7_ILP32_OFF32)
147e83
 #  error "__ILP32_OFF32_CFLAGS should not be defined"
147e83
-# elif !defined _POSIX_V7_ILP32_OFF32
147e83
+# elif CONF_IS_UNDEFINED (_POSIX_V7_ILP32_OFF32)
147e83
       if (__sysconf (_SC_V7_ILP32_OFF32) < 0)
147e83
 	break;
147e83
 # endif
147e83
@@ -115,9 +116,9 @@ confstr (name, buf, len)
147e83
     case _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS:
147e83
     case _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS:
147e83
 #ifdef __ILP32_OFFBIG_CFLAGS
147e83
-# if _POSIX_V7_ILP32_OFFBIG == -1
147e83
+# if CONF_IS_DEFINED_UNSET (_POSIX_V7_ILP32_OFFBIG)
147e83
 #  error "__ILP32_OFFBIG_CFLAGS should not be defined"
147e83
-# elif !defined _POSIX_V7_ILP32_OFFBIG
147e83
+# elif CONF_IS_UNDEFINED (_POSIX_V7_ILP32_OFFBIG)
147e83
       if (__sysconf (_SC_V7_ILP32_OFFBIG) < 0)
147e83
 	break;
147e83
 # endif
147e83
@@ -130,9 +131,9 @@ confstr (name, buf, len)
147e83
     case _CS_POSIX_V6_LP64_OFF64_CFLAGS:
147e83
     case _CS_POSIX_V7_LP64_OFF64_CFLAGS:
147e83
 #ifdef __LP64_OFF64_CFLAGS
147e83
-# if _POSIX_V7_LP64_OFF64 == -1
147e83
+# if CONF_IS_DEFINED_UNSET (_POSIX_V7_LP64_OFF64)
147e83
 #  error "__LP64_OFF64_CFLAGS should not be defined"
147e83
-# elif !defined _POSIX_V7_LP64_OFF64
147e83
+# elif CONF_IS_UNDEFINED (_POSIX_V7_LP64_OFF64)
147e83
       if (__sysconf (_SC_V7_LP64_OFF64) < 0)
147e83
 	break;
147e83
 # endif
147e83
@@ -145,9 +146,9 @@ confstr (name, buf, len)
147e83
     case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:
147e83
     case _CS_POSIX_V7_ILP32_OFF32_LDFLAGS:
147e83
 #ifdef __ILP32_OFF32_LDFLAGS
147e83
-# if _POSIX_V7_ILP32_OFF32 == -1
147e83
+# if CONF_IS_DEFINED_UNSET (_POSIX_V7_ILP32_OFF32 )
147e83
 #  error "__ILP32_OFF32_LDFLAGS should not be defined"
147e83
-# elif !defined _POSIX_V7_ILP32_OFF32
147e83
+# elif CONF_IS_UNDEFINED (_POSIX_V7_ILP32_OFF32)
147e83
       if (__sysconf (_SC_V7_ILP32_OFF32) < 0)
147e83
 	break;
147e83
 # endif
147e83
@@ -160,9 +161,9 @@ confstr (name, buf, len)
147e83
     case _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS:
147e83
     case _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS:
147e83
 #ifdef __ILP32_OFFBIG_LDFLAGS
147e83
-# if _POSIX_V7_ILP32_OFFBIG == -1
147e83
+# if CONF_IS_DEFINED_UNSET (_POSIX_V7_ILP32_OFFBIG)
147e83
 #  error "__ILP32_OFFBIG_LDFLAGS should not be defined"
147e83
-# elif !defined _POSIX_V7_ILP32_OFFBIG
147e83
+# elif CONF_IS_UNDEFINED (_POSIX_V7_ILP32_OFFBIG)
147e83
       if (__sysconf (_SC_V7_ILP32_OFFBIG) < 0)
147e83
 	break;
147e83
 # endif
147e83
@@ -175,9 +176,9 @@ confstr (name, buf, len)
147e83
     case _CS_POSIX_V6_LP64_OFF64_LDFLAGS:
147e83
     case _CS_POSIX_V7_LP64_OFF64_LDFLAGS:
147e83
 #ifdef __LP64_OFF64_LDFLAGS
147e83
-# if _POSIX_V7_LP64_OFF64 == -1
147e83
+# if CONF_IS_DEFINED_UNSET (_POSIX_V7_LP64_OFF64)
147e83
 #  error "__LP64_OFF64_LDFLAGS should not be defined"
147e83
-# elif !defined _POSIX_V7_LP64_OFF64
147e83
+# elif CONF_IS_UNDEFINED (_POSIX_V7_LP64_OFF64)
147e83
       if (__sysconf (_SC_V7_LP64_OFF64) < 0)
147e83
 	break;
147e83
 # endif
147e83
@@ -188,7 +189,8 @@ confstr (name, buf, len)
147e83
 
147e83
     case _CS_LFS_CFLAGS:
147e83
     case _CS_LFS_LINTFLAGS:
147e83
-#if _POSIX_V6_ILP32_OFF32 == 1 && _POSIX_V6_ILP32_OFFBIG == 1
147e83
+#if (CONF_IS_DEFINED_SET (_POSIX_V6_ILP32_OFF32) \
147e83
+     && CONF_IS_DEFINED_SET (_POSIX_V6_ILP32_OFFBIG))
147e83
 # define __LFS_CFLAGS "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
147e83
       /* Signal that we want the new ABI.  */
147e83
       string = __LFS_CFLAGS;
147e83
diff --git a/posix/posix-conf-vars.h b/posix/posix-conf-vars.h
147e83
new file mode 100644
147e83
index 0000000000000000..6faf29f56b55b7e8
147e83
--- /dev/null
147e83
+++ b/posix/posix-conf-vars.h
147e83
@@ -0,0 +1,48 @@
147e83
+/* Macros to check if a POSIX configuration variable is defined or set.
147e83
+
147e83
+   Copyright (C) 1991-2014 Free Software Foundation, Inc.
147e83
+   This file is part of the GNU C Library.
147e83
+
147e83
+   The GNU C Library is free software; you can redistribute it and/or
147e83
+   modify it under the terms of the GNU Lesser General Public
147e83
+   License as published by the Free Software Foundation; either
147e83
+   version 2.1 of the License, or (at your option) any later version.
147e83
+
147e83
+   The GNU C Library is distributed in the hope that it will be useful,
147e83
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
147e83
+   Lesser General Public License for more details.
147e83
+
147e83
+   You should have received a copy of the GNU Lesser General Public
147e83
+   License along with the GNU C Library; if not, see
147e83
+   <http://www.gnu.org/licenses/>.  */
147e83
+
147e83
+#ifndef _POSIX_CONF_VARS_H
147e83
+#define _POSIX_CONF_VARS_H
147e83
+
147e83
+/* The script gen-posix-conf-vars.awk generates the header
147e83
+   posix-conf-vars-def.h from the list file posix-conf-vars.list and defines
147e83
+   CONF_DEF_* macros for each entry in the list file set to either of
147e83
+   CONF_DEF_UNDEFINED, CONF_DEF_DEFINED_SET or CONF_DEF_DEFINED_UNSET.  To
147e83
+   check configuration variables within glibc code, use the configuration macro
147e83
+   functions instead of checking for definitions of the macros.  */
147e83
+
147e83
+#include <posix-conf-vars-def.h>
147e83
+
147e83
+#define CONF_DEF_UNDEFINED	1
147e83
+#define CONF_DEF_DEFINED_SET	2
147e83
+#define CONF_DEF_DEFINED_UNSET	3
147e83
+
147e83
+/* The configuration variable is not defined.  */
147e83
+#define CONF_IS_UNDEFINED(conf) (CONF_DEF##conf == CONF_DEF_UNDEFINED)
147e83
+
147e83
+/* The configuration variable is defined.  It may or may not be set.  */
147e83
+#define CONF_IS_DEFINED(conf) (CONF_DEF##conf != CONF_DEF_UNDEFINED)
147e83
+
147e83
+/* The configuration variable is defined and set.  */
147e83
+#define CONF_IS_DEFINED_SET(conf) (CONF_DEF##conf == CONF_DEF_DEFINED_SET)
147e83
+
147e83
+/* The configuration variable is defined but not set.  */
147e83
+#define CONF_IS_DEFINED_UNSET(conf) (CONF_DEF##conf == CONF_DEF_DEFINED_UNSET)
147e83
+
147e83
+#endif
147e83
diff --git a/posix/posix-conf-vars.list b/posix/posix-conf-vars.list
147e83
new file mode 100644
147e83
index 0000000000000000..8f308c216626c59c
147e83
--- /dev/null
147e83
+++ b/posix/posix-conf-vars.list
147e83
@@ -0,0 +1,22 @@
147e83
+# Configuration variables identified by getconf.  The heading of each section
147e83
+# is of the format TYPE PREFIX with the opening curly brace on the same line.
147e83
+# TYPE can either be SYSCONF, PATHCONF, CONFSTR or SPEC.  Variable names are
147e83
+# put one on each line with a curly brace on its own line ending the section.
147e83
+
147e83
+SPEC POSIX {
147e83
+  V6_ILP32_OFF32
147e83
+  V6_ILP32_OFFBIG
147e83
+  V6_LP64_OFF64
147e83
+  V6_LPBIG_OFFBIG
147e83
+  V7_ILP32_OFF32
147e83
+  V7_ILP32_OFFBIG
147e83
+  V7_LP64_OFF64
147e83
+  V7_LPBIG_OFFBIG
147e83
+}
147e83
+
147e83
+SPEC XBS5 {
147e83
+  ILP32_OFF32
147e83
+  ILP32_OFFBIG
147e83
+  LP64_OFF64
147e83
+  LPBIG_OFFBIG
147e83
+}
147e83
diff --git a/posix/posix-envs.def b/posix/posix-envs.def
147e83
index c32ea8acfcfebb78..e820e6dbe3fa3b61 100644
147e83
--- a/posix/posix-envs.def
147e83
+++ b/posix/posix-envs.def
147e83
@@ -42,35 +42,37 @@
147e83
    defined.  These are called with arguments V5, V6, V7 before and
147e83
    after the relevant groups of environments.  */
147e83
 
147e83
+#include <posix-conf-vars.h>
147e83
+
147e83
 START_ENV_GROUP (V7)
147e83
 
147e83
-#if _POSIX_V7_ILP32_OFF32 > 0
147e83
+#if CONF_IS_DEFINED_SET (_POSIX_V7_ILP32_OFF32)
147e83
 KNOWN_PRESENT_ENVIRONMENT (V7, POSIX_V7, ILP32_OFF32)
147e83
-#elif defined _POSIX_V7_ILP32_OFF32
147e83
+#elif CONF_IS_DEFINED (_POSIX_V7_ILP32_OFF32)
147e83
 KNOWN_ABSENT_ENVIRONMENT (V7, POSIX_V7, ILP32_OFF32)
147e83
 #else
147e83
 UNKNOWN_ENVIRONMENT (V7, POSIX_V7, ILP32_OFF32)
147e83
 #endif
147e83
 
147e83
-#if _POSIX_V7_ILP32_OFFBIG > 0
147e83
+#if CONF_IS_DEFINED_SET (_POSIX_V7_ILP32_OFFBIG)
147e83
 KNOWN_PRESENT_ENVIRONMENT (V7, POSIX_V7, ILP32_OFFBIG)
147e83
-#elif defined _POSIX_V7_ILP32_OFFBIG
147e83
+#elif CONF_IS_DEFINED (_POSIX_V7_ILP32_OFFBIG)
147e83
 KNOWN_ABSENT_ENVIRONMENT (V7, POSIX_V7, ILP32_OFFBIG)
147e83
 #else
147e83
 UNKNOWN_ENVIRONMENT (V7, POSIX_V7, ILP32_OFFBIG)
147e83
 #endif
147e83
 
147e83
-#if _POSIX_V7_LP64_OFF64 > 0
147e83
+#if CONF_IS_DEFINED_SET (_POSIX_V7_LP64_OFF64)
147e83
 KNOWN_PRESENT_ENVIRONMENT (V7, POSIX_V7, LP64_OFF64)
147e83
-#elif defined _POSIX_V7_LP64_OFF64
147e83
+#elif CONF_IS_DEFINED (_POSIX_V7_LP64_OFF64)
147e83
 KNOWN_ABSENT_ENVIRONMENT (V7, POSIX_V7, LP64_OFF64)
147e83
 #else
147e83
 UNKNOWN_ENVIRONMENT (V7, POSIX_V7, LP64_OFF64)
147e83
 #endif
147e83
 
147e83
-#if _POSIX_V7_LPBIG_OFFBIG > 0
147e83
+#if CONF_IS_DEFINED_SET (_POSIX_V7_LPBIG_OFFBIG)
147e83
 KNOWN_PRESENT_ENVIRONMENT (V7, POSIX_V7, LPBIG_OFFBIG)
147e83
-#elif defined _POSIX_V7_LPBIG_OFFBIG
147e83
+#elif CONF_IS_DEFINED (_POSIX_V7_LPBIG_OFFBIG)
147e83
 KNOWN_ABSENT_ENVIRONMENT (V7, POSIX_V7, LPBIG_OFFBIG)
147e83
 #else
147e83
 UNKNOWN_ENVIRONMENT (V7, POSIX_V7, LPBIG_OFFBIG)
147e83
@@ -80,33 +82,33 @@ END_ENV_GROUP (V7)
147e83
 
147e83
 START_ENV_GROUP (V6)
147e83
 
147e83
-#if _POSIX_V6_ILP32_OFF32 > 0
147e83
+#if CONF_IS_DEFINED_SET (_POSIX_V6_ILP32_OFF32)
147e83
 KNOWN_PRESENT_ENVIRONMENT (V6, POSIX_V6, ILP32_OFF32)
147e83
-#elif defined _POSIX_V6_ILP32_OFF32
147e83
+#elif CONF_IS_DEFINED (_POSIX_V6_ILP32_OFF32)
147e83
 KNOWN_ABSENT_ENVIRONMENT (V6, POSIX_V6, ILP32_OFF32)
147e83
 #else
147e83
 UNKNOWN_ENVIRONMENT (V6, POSIX_V6, ILP32_OFF32)
147e83
 #endif
147e83
 
147e83
-#if _POSIX_V6_ILP32_OFFBIG > 0
147e83
+#if CONF_IS_DEFINED_SET (_POSIX_V6_ILP32_OFFBIG)
147e83
 KNOWN_PRESENT_ENVIRONMENT (V6, POSIX_V6, ILP32_OFFBIG)
147e83
-#elif defined _POSIX_V6_ILP32_OFFBIG
147e83
+#elif CONF_IS_DEFINED (_POSIX_V6_ILP32_OFFBIG)
147e83
 KNOWN_ABSENT_ENVIRONMENT (V6, POSIX_V6, ILP32_OFFBIG)
147e83
 #else
147e83
 UNKNOWN_ENVIRONMENT (V6, POSIX_V6, ILP32_OFFBIG)
147e83
 #endif
147e83
 
147e83
-#if _POSIX_V6_LP64_OFF64 > 0
147e83
+#if CONF_IS_DEFINED_SET (_POSIX_V6_LP64_OFF64)
147e83
 KNOWN_PRESENT_ENVIRONMENT (V6, POSIX_V6, LP64_OFF64)
147e83
-#elif defined _POSIX_V6_LP64_OFF64
147e83
+#elif CONF_IS_DEFINED (_POSIX_V6_LP64_OFF64)
147e83
 KNOWN_ABSENT_ENVIRONMENT (V6, POSIX_V6, LP64_OFF64)
147e83
 #else
147e83
 UNKNOWN_ENVIRONMENT (V6, POSIX_V6, LP64_OFF64)
147e83
 #endif
147e83
 
147e83
-#if _POSIX_V6_LPBIG_OFFBIG > 0
147e83
+#if CONF_IS_DEFINED_SET (_POSIX_V6_LPBIG_OFFBIG)
147e83
 KNOWN_PRESENT_ENVIRONMENT (V6, POSIX_V6, LPBIG_OFFBIG)
147e83
-#elif defined _POSIX_V6_LPBIG_OFFBIG
147e83
+#elif CONF_IS_DEFINED (_POSIX_V6_LPBIG_OFFBIG)
147e83
 KNOWN_ABSENT_ENVIRONMENT (V6, POSIX_V6, LPBIG_OFFBIG)
147e83
 #else
147e83
 UNKNOWN_ENVIRONMENT (V6, POSIX_V6, LPBIG_OFFBIG)
147e83
@@ -116,33 +118,33 @@ END_ENV_GROUP (V6)
147e83
 
147e83
 START_ENV_GROUP (V5)
147e83
 
147e83
-#if _XBS5_ILP32_OFF32 > 0
147e83
+#if CONF_IS_DEFINED_SET (_XBS5_ILP32_OFF32)
147e83
 KNOWN_PRESENT_ENVIRONMENT (XBS5, XBS5, ILP32_OFF32)
147e83
-#elif defined _XBS5_ILP32_OFF32
147e83
+#elif CONF_IS_DEFINED (_XBS5_ILP32_OFF32)
147e83
 KNOWN_ABSENT_ENVIRONMENT (XBS5, XBS5, ILP32_OFF32)
147e83
 #else
147e83
 UNKNOWN_ENVIRONMENT (XBS5, XBS5, ILP32_OFF32)
147e83
 #endif
147e83
 
147e83
-#if _XBS5_ILP32_OFFBIG > 0
147e83
+#if CONF_IS_DEFINED_SET (_XBS5_ILP32_OFFBIG)
147e83
 KNOWN_PRESENT_ENVIRONMENT (XBS5, XBS5, ILP32_OFFBIG)
147e83
-#elif defined _XBS5_ILP32_OFFBIG
147e83
+#elif CONF_IS_DEFINED (_XBS5_ILP32_OFFBIG)
147e83
 KNOWN_ABSENT_ENVIRONMENT (XBS5, XBS5, ILP32_OFFBIG)
147e83
 #else
147e83
 UNKNOWN_ENVIRONMENT (XBS5, XBS5, ILP32_OFFBIG)
147e83
 #endif
147e83
 
147e83
-#if _XBS5_LP64_OFF64 > 0
147e83
+#if CONF_IS_DEFINED_SET (_XBS5_LP64_OFF64)
147e83
 KNOWN_PRESENT_ENVIRONMENT (XBS5, XBS5, LP64_OFF64)
147e83
-#elif defined _XBS5_LP64_OFF64
147e83
+#elif CONF_IS_DEFINED (_XBS5_LP64_OFF64)
147e83
 KNOWN_ABSENT_ENVIRONMENT (XBS5, XBS5, LP64_OFF64)
147e83
 #else
147e83
 UNKNOWN_ENVIRONMENT (XBS5, XBS5, LP64_OFF64)
147e83
 #endif
147e83
 
147e83
-#if _XBS5_LPBIG_OFFBIG > 0
147e83
+#if CONF_IS_DEFINED_SET (_XBS5_LPBIG_OFFBIG)
147e83
 KNOWN_PRESENT_ENVIRONMENT (XBS5, XBS5, LPBIG_OFFBIG)
147e83
-#elif defined _XBS5_LPBIG_OFFBIG
147e83
+#elif CONF_IS_DEFINED (_XBS5_LPBIG_OFFBIG)
147e83
 KNOWN_ABSENT_ENVIRONMENT (XBS5, XBS5, LPBIG_OFFBIG)
147e83
 #else
147e83
 UNKNOWN_ENVIRONMENT (XBS5, XBS5, LPBIG_OFFBIG)
147e83
diff --git a/scripts/gen-posix-conf-vars.awk b/scripts/gen-posix-conf-vars.awk
147e83
new file mode 100644
147e83
index 0000000000000000..16e20fc1007bd2f5
147e83
--- /dev/null
147e83
+++ b/scripts/gen-posix-conf-vars.awk
147e83
@@ -0,0 +1,61 @@
147e83
+# Generate posix-conf-vars-def.h with definitions for CONF_DEF{CONF} for each
147e83
+# configuration variable that getconf or sysconf may use.  Currently it is
147e83
+# equipped only to generate such macros for specification macros and for
147e83
+# SYSCONF macros in the _POSIX namespace.
147e83
+
147e83
+BEGIN {
147e83
+  prefix = ""
147e83
+}
147e83
+
147e83
+$1 ~ /^#/ || $0 ~ /^\s*$/ {
147e83
+  next
147e83
+}
147e83
+
147e83
+# Begin a new prefix.
147e83
+$NF == "{" {
147e83
+  type = $1
147e83
+  prefix = $2
147e83
+  next
147e83
+}
147e83
+
147e83
+$1 == "}" {
147e83
+  prefix = ""
147e83
+  type = ""
147e83
+  next
147e83
+}
147e83
+
147e83
+{
147e83
+  if (prefix == "" && type == "" && sc_prefix == "") {
147e83
+    printf ("Syntax error at %s:%d\n", FILENAME, FNR) > "/dev/stderr"
147e83
+    exit 1
147e83
+  }
147e83
+
147e83
+  # The prefix and variable names are indices and the value indicates what type
147e83
+  # of variable it is.  The possible options are:
147e83
+  # CONFSTR: A configuration string
147e83
+  # SYSCONF: A numeric value
147e83
+  # SPEC: A specification
147e83
+  conf[prefix][$1] = type
147e83
+}
147e83
+
147e83
+END {
147e83
+  print "/* AUTOGENERATED by gen-posix-conf-vars.awk.  DO NOT EDIT.  */\n"
147e83
+
147e83
+  # Generate macros that specify if a sysconf macro is defined and/or set.
147e83
+  for (p in conf) {
147e83
+    for (c in conf[p]) {
147e83
+      printf "#ifndef _%s_%s\n", p, c
147e83
+      printf "# define CONF_DEF_%s_%s CONF_DEF_UNDEFINED\n", p, c
147e83
+      # CONFSTR have string values and they are not set or unset.
147e83
+      if (conf[p][c] != "CONFSTR") {
147e83
+	printf "#else\n"
147e83
+	printf "# if _%s_%s > 0\n", p, c
147e83
+	printf "#  define CONF_DEF_%s_%s CONF_DEF_DEFINED_SET\n", p, c
147e83
+	printf "# else\n"
147e83
+	printf "#  define CONF_DEF_%s_%s CONF_DEF_DEFINED_UNSET\n", p, c
147e83
+	printf "# endif\n"
147e83
+      }
147e83
+      printf "#endif\n\n"
147e83
+    }
147e83
+  }
147e83
+}