Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Remove Wundef warnings for specification macros
This patch adds a file posix-conf-vars.list that is used to generate macros to determine if a macro is defined as set, unset or not defined. gen-posix-conf-vars.awk processes this file and generates a header (posix-conf-vars-def.h) with these macros. A new header posix-conf-vars.h includes this generated header and defines accessor macros for the generated macros. Tested on x86_64. * posix/Makefile (before-compile): Add posix-conf-vars-def.h. ($(objpfx)posix-conf-vars-def.h): New target. * posix/posix-conf-vars.list: New file. * posix/posix-conf-vars.h: New file. * posix/confstr.c: Include posix-conf-vars.h. (confstr): Use CONF_IS_* macros. * posix/posix-envs.def: Include posix-conf-vars.h. Use CONF_IS_* macros. * scripts/gen-posix-conf-vars.awk: New file.
- Loading branch information
Siddhesh Poyarekar
committed
Dec 29, 2014
1 parent
0025b4c
commit 4a6aca7
Showing
7 changed files
with
191 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* Macros to check if a POSIX configuration variable is defined or set. | ||
Copyright (C) 1991-2014 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/>. */ | ||
|
||
#ifndef _POSIX_CONF_VARS_H | ||
#define _POSIX_CONF_VARS_H | ||
|
||
/* The script gen-posix-conf-vars.awk generates the header | ||
posix-conf-vars-def.h from the list file posix-conf-vars.list and defines | ||
CONF_DEF_* macros for each entry in the list file set to either of | ||
CONF_DEF_UNDEFINED, CONF_DEF_DEFINED_SET or CONF_DEF_DEFINED_UNSET. To | ||
check configuration variables within glibc code, use the configuration macro | ||
functions instead of checking for definitions of the macros. */ | ||
|
||
#include <posix-conf-vars-def.h> | ||
|
||
#define CONF_DEF_UNDEFINED 1 | ||
#define CONF_DEF_DEFINED_SET 2 | ||
#define CONF_DEF_DEFINED_UNSET 3 | ||
|
||
/* The configuration variable is not defined. */ | ||
#define CONF_IS_UNDEFINED(conf) (CONF_DEF##conf == CONF_DEF_UNDEFINED) | ||
|
||
/* The configuration variable is defined. It may or may not be set. */ | ||
#define CONF_IS_DEFINED(conf) (CONF_DEF##conf != CONF_DEF_UNDEFINED) | ||
|
||
/* The configuration variable is defined and set. */ | ||
#define CONF_IS_DEFINED_SET(conf) (CONF_DEF##conf == CONF_DEF_DEFINED_SET) | ||
|
||
/* The configuration variable is defined but not set. */ | ||
#define CONF_IS_DEFINED_UNSET(conf) (CONF_DEF##conf == CONF_DEF_DEFINED_UNSET) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Configuration variables identified by getconf. The heading of each section | ||
# is of the format TYPE PREFIX with the opening curly brace on the same line. | ||
# TYPE can either be SYSCONF, PATHCONF, CONFSTR or SPEC. Variable names are | ||
# put one on each line with a curly brace on its own line ending the section. | ||
|
||
SPEC POSIX { | ||
V6_ILP32_OFF32 | ||
V6_ILP32_OFFBIG | ||
V6_LP64_OFF64 | ||
V6_LPBIG_OFFBIG | ||
V7_ILP32_OFF32 | ||
V7_ILP32_OFFBIG | ||
V7_LP64_OFF64 | ||
V7_LPBIG_OFFBIG | ||
} | ||
|
||
SPEC XBS5 { | ||
ILP32_OFF32 | ||
ILP32_OFFBIG | ||
LP64_OFF64 | ||
LPBIG_OFFBIG | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Generate posix-conf-vars-def.h with definitions for CONF_DEF{CONF} for each | ||
# configuration variable that getconf or sysconf may use. Currently it is | ||
# equipped only to generate such macros for specification macros and for | ||
# SYSCONF macros in the _POSIX namespace. | ||
|
||
BEGIN { | ||
prefix = "" | ||
} | ||
|
||
$1 ~ /^#/ || $0 ~ /^\s*$/ { | ||
next | ||
} | ||
|
||
# Begin a new prefix. | ||
$NF == "{" { | ||
type = $1 | ||
prefix = $2 | ||
next | ||
} | ||
|
||
$1 == "}" { | ||
prefix = "" | ||
type = "" | ||
next | ||
} | ||
|
||
{ | ||
if (prefix == "" && type == "" && sc_prefix == "") { | ||
printf ("Syntax error at %s:%d\n", FILENAME, FNR) > "/dev/stderr" | ||
exit 1 | ||
} | ||
|
||
# The prefix and variable names are indices and the value indicates what type | ||
# of variable it is. The possible options are: | ||
# CONFSTR: A configuration string | ||
# SYSCONF: A numeric value | ||
# SPEC: A specification | ||
conf[prefix][$1] = type | ||
} | ||
|
||
END { | ||
print "/* AUTOGENERATED by gen-posix-conf-vars.awk. DO NOT EDIT. */\n" | ||
|
||
# Generate macros that specify if a sysconf macro is defined and/or set. | ||
for (p in conf) { | ||
for (c in conf[p]) { | ||
printf "#ifndef _%s_%s\n", p, c | ||
printf "# define CONF_DEF_%s_%s CONF_DEF_UNDEFINED\n", p, c | ||
# CONFSTR have string values and they are not set or unset. | ||
if (conf[p][c] != "CONFSTR") { | ||
printf "#else\n" | ||
printf "# if _%s_%s > 0\n", p, c | ||
printf "# define CONF_DEF_%s_%s CONF_DEF_DEFINED_SET\n", p, c | ||
printf "# else\n" | ||
printf "# define CONF_DEF_%s_%s CONF_DEF_DEFINED_UNSET\n", p, c | ||
printf "# endif\n" | ||
} | ||
printf "#endif\n\n" | ||
} | ||
} | ||
} |