mirror of git://sourceware.org/git/glibc.git
conformtest: Unify "macro" and "constant" handling.
This commit is contained in:
parent
fefdf57412
commit
aafc49b3fc
|
@ -1,5 +1,8 @@
|
||||||
2012-05-01 Joseph Myers <joseph@codesourcery.com>
|
2012-05-01 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
* conform/conformtest.pl: Parse all "constant" and "macro" lines
|
||||||
|
in one place. Also handle "macro-constant".
|
||||||
|
|
||||||
* conform/conformtest.pl: Only accept expected macro values with
|
* conform/conformtest.pl: Only accept expected macro values with
|
||||||
"==". Parse all "macro" lines in one place.
|
"==". Parse all "macro" lines in one place.
|
||||||
* conform/data/stdlib.h-data: Use "==" form on "macro" lines.
|
* conform/data/stdlib.h-data: Use "==" form on "macro" lines.
|
||||||
|
|
|
@ -385,54 +385,78 @@ while ($#headers >= 0) {
|
||||||
"Member \"$member\" does not have the correct type.",
|
"Member \"$member\" does not have the correct type.",
|
||||||
$res, 0);
|
$res, 0);
|
||||||
}
|
}
|
||||||
} elsif (/^constant *([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=<!]+) ([A-Za-z0-9_-]*))?/) {
|
} elsif (/^(macro|constant|macro-constant) +([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=<!]+) ([A-Za-z0-9_-]*))?/) {
|
||||||
my($const) = $1;
|
my($symbol_type) = $1;
|
||||||
my($type) = $2;
|
my($symbol) = $2;
|
||||||
my($op) = $3;
|
my($type) = $3;
|
||||||
my($value) = $4;
|
my($op) = $4;
|
||||||
|
my($value) = $5;
|
||||||
my($res) = $missing;
|
my($res) = $missing;
|
||||||
|
my($mres) = $missing;
|
||||||
|
my($cres) = $missing;
|
||||||
|
|
||||||
# Remember that this name is allowed.
|
# Remember that this name is allowed.
|
||||||
push @allow, $const;
|
push @allow, $symbol;
|
||||||
|
|
||||||
# Generate a program to test for the availability of this constant.
|
if ($symbol_type =~ /macro/) {
|
||||||
open (TESTFILE, ">$fnamebase.c");
|
# Generate a program to test for availability of this macro.
|
||||||
print TESTFILE "$prepend";
|
open (TESTFILE, ">$fnamebase.c");
|
||||||
print TESTFILE "#include <$h>\n";
|
print TESTFILE "$prepend";
|
||||||
print TESTFILE "__typeof__ ($const) a = $const;\n";
|
print TESTFILE "#include <$h>\n";
|
||||||
close (TESTFILE);
|
print TESTFILE "#ifndef $symbol\n";
|
||||||
|
print TESTFILE "# error \"Macro $symbol not defined\"\n";
|
||||||
|
print TESTFILE "#endif\n";
|
||||||
|
close (TESTFILE);
|
||||||
|
|
||||||
$res = compiletest ($fnamebase, "Testing for constant $const",
|
$mres = compiletest ($fnamebase, "Test availability of macro $symbol",
|
||||||
($optional
|
($optional
|
||||||
? "NOT PRESENT"
|
? "NOT PRESENT"
|
||||||
: "Constant \"$const\" not available."), $res,
|
: "Macro \"$symbol\" is not available."), $res,
|
||||||
$optional);
|
$optional);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($symbol_type =~ /constant/) {
|
||||||
|
# Generate a program to test for the availability of this constant.
|
||||||
|
open (TESTFILE, ">$fnamebase.c");
|
||||||
|
print TESTFILE "$prepend";
|
||||||
|
print TESTFILE "#include <$h>\n";
|
||||||
|
print TESTFILE "__typeof__ ($symbol) a = $symbol;\n";
|
||||||
|
close (TESTFILE);
|
||||||
|
|
||||||
|
$cres = compiletest ($fnamebase, "Testing for constant $symbol",
|
||||||
|
($optional
|
||||||
|
? "NOT PRESENT"
|
||||||
|
: "Constant \"$symbol\" not available."), $res,
|
||||||
|
$optional);
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = $res || $mres || $cres;
|
||||||
|
|
||||||
if (defined ($type) && ($res == 0 || !$optional)) {
|
if (defined ($type) && ($res == 0 || !$optional)) {
|
||||||
# Test the types of the members.
|
# Test the type of the symbol.
|
||||||
open (TESTFILE, ">$fnamebase.c");
|
open (TESTFILE, ">$fnamebase.c");
|
||||||
print TESTFILE "$prepend";
|
print TESTFILE "$prepend";
|
||||||
print TESTFILE "#include <$h>\n";
|
print TESTFILE "#include <$h>\n";
|
||||||
print TESTFILE "__typeof__ (($type) 0) a;\n";
|
print TESTFILE "__typeof__ (($type) 0) a;\n";
|
||||||
print TESTFILE "extern __typeof__ ($const) a;\n";
|
print TESTFILE "extern __typeof__ ($symbol) a;\n";
|
||||||
close (TESTFILE);
|
close (TESTFILE);
|
||||||
|
|
||||||
compiletest ($fnamebase, "Testing for type of constant $const",
|
compiletest ($fnamebase, "Testing for type of symbol $symbol",
|
||||||
"Constant \"$const\" does not have the correct type.",
|
"Symbol \"$symbol\" does not have the correct type.",
|
||||||
$res, 0);
|
$res, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined ($op) && ($res == 0 || !$optional)) {
|
if (defined ($op) && ($res == 0 || !$optional)) {
|
||||||
# Generate a program to test for the value of this constant.
|
# Generate a program to test for the value of this symbol.
|
||||||
open (TESTFILE, ">$fnamebase.c");
|
open (TESTFILE, ">$fnamebase.c");
|
||||||
print TESTFILE "$prepend";
|
print TESTFILE "$prepend";
|
||||||
print TESTFILE "#include <$h>\n";
|
print TESTFILE "#include <$h>\n";
|
||||||
# Negate the value since 0 means ok
|
# Negate the value since 0 means ok
|
||||||
print TESTFILE "int main (void) { return !($const $op $value); }\n";
|
print TESTFILE "int main (void) { return !($symbol $op $value); }\n";
|
||||||
close (TESTFILE);
|
close (TESTFILE);
|
||||||
|
|
||||||
$res = runtest ($fnamebase, "Testing for value of constant $const",
|
$res = runtest ($fnamebase, "Testing for value of symbol $symbol",
|
||||||
"Constant \"$const\" has not the right value.", $res);
|
"Symbol \"$symbol\" has not the right value.", $res);
|
||||||
}
|
}
|
||||||
} elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
|
} elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
|
||||||
my($symbol) = $1;
|
my($symbol) = $1;
|
||||||
|
@ -683,42 +707,6 @@ while ($#headers >= 0) {
|
||||||
|
|
||||||
$res = runtest ($fnamebase, "Testing for value of macro $macro",
|
$res = runtest ($fnamebase, "Testing for value of macro $macro",
|
||||||
"Macro \"$macro\" has not the right value.", $res);
|
"Macro \"$macro\" has not the right value.", $res);
|
||||||
} elsif (/^macro *([a-zA-Z0-9_]*) *(?:([>=<!]+) ([A-Za-z0-9_]*))?/) {
|
|
||||||
my($macro) = "$1";
|
|
||||||
my($op) = $2;
|
|
||||||
my($value) = $3;
|
|
||||||
my($res) = $missing;
|
|
||||||
|
|
||||||
# Remember that this name is allowed.
|
|
||||||
push @allow, $macro;
|
|
||||||
|
|
||||||
# Generate a program to test for availability of this macro.
|
|
||||||
open (TESTFILE, ">$fnamebase.c");
|
|
||||||
print TESTFILE "$prepend";
|
|
||||||
print TESTFILE "#include <$h>\n";
|
|
||||||
print TESTFILE "#ifndef $macro\n";
|
|
||||||
print TESTFILE "# error \"Macro $macro not defined\"\n";
|
|
||||||
print TESTFILE "#endif\n";
|
|
||||||
close (TESTFILE);
|
|
||||||
|
|
||||||
$res = compiletest ($fnamebase, "Test availability of macro $macro",
|
|
||||||
($optional
|
|
||||||
? "NOT PRESENT"
|
|
||||||
: "Macro \"$macro\" is not available."), $res,
|
|
||||||
$optional);
|
|
||||||
|
|
||||||
if (defined ($op) && ($res == 0 || !$optional)) {
|
|
||||||
# Generate a program to test for the value of this constant.
|
|
||||||
open (TESTFILE, ">$fnamebase.c");
|
|
||||||
print TESTFILE "$prepend";
|
|
||||||
print TESTFILE "#include <$h>\n";
|
|
||||||
# Negate the value since 0 means ok
|
|
||||||
print TESTFILE "int main (void) { return !($macro $op $value); }\n";
|
|
||||||
close (TESTFILE);
|
|
||||||
|
|
||||||
$res = runtest ($fnamebase, "Testing for value of macro $macro",
|
|
||||||
"Macro \"$macro\" has not the right value.", $res);
|
|
||||||
}
|
|
||||||
} elsif (/^allow-header *(.*)/) {
|
} elsif (/^allow-header *(.*)/) {
|
||||||
my($pattern) = $1;
|
my($pattern) = $1;
|
||||||
if ($seenheader{$pattern} != 1) {
|
if ($seenheader{$pattern} != 1) {
|
||||||
|
@ -751,7 +739,7 @@ while ($#headers >= 0) {
|
||||||
|
|
||||||
if (/^element *({([^}]*)}|([^ ]*)) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
|
if (/^element *({([^}]*)}|([^ ]*)) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
|
||||||
push @allow, $7;
|
push @allow, $7;
|
||||||
} elsif (/^constant *([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=<!]+) ([A-Za-z0-9_-]*))?/) {
|
} elsif (/^(macro|constant|macro-constant) +([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=<!]+) ([A-Za-z0-9_-]*))?/) {
|
||||||
push @allow, $1;
|
push @allow, $1;
|
||||||
} elsif (/^(type|tag) *({([^}]*)|([a-zA-Z0-9_]*))/) {
|
} elsif (/^(type|tag) *({([^}]*)|([a-zA-Z0-9_]*))/) {
|
||||||
my($type) = "$3$4";
|
my($type) = "$3$4";
|
||||||
|
@ -772,8 +760,6 @@ while ($#headers >= 0) {
|
||||||
push @allow, $4;
|
push @allow, $4;
|
||||||
} elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
|
} elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
|
||||||
push @allow, $4;
|
push @allow, $4;
|
||||||
} elsif (/^macro *([a-zA-Z0-9_]*) *(?:([>=<!]+) ([A-Za-z0-9_]*))?/) {
|
|
||||||
push @allow, $1;
|
|
||||||
} elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
|
} elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
|
||||||
push @allow, $1;
|
push @allow, $1;
|
||||||
} elsif (/^allow-header *(.*)/) {
|
} elsif (/^allow-header *(.*)/) {
|
||||||
|
|
Loading…
Reference in New Issue