Blame conform/list-header-symbols.pl

Packit 6c4009
#!/usr/bin/perl
Packit 6c4009
Packit 6c4009
# Print a list of symbols exported by some headers that would
Packit 6c4009
# otherwise be in the user's namespace.
Packit 6c4009
Packit 6c4009
# Copyright (C) 2014-2018 Free Software Foundation, Inc.
Packit 6c4009
# This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
# The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
# modify it under the terms of the GNU Lesser General Public
Packit 6c4009
# License as published by the Free Software Foundation; either
Packit 6c4009
# version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
# The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
# Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
# You should have received a copy of the GNU Lesser General Public
Packit 6c4009
# License along with the GNU C Library; if not, see
Packit 6c4009
# <http://www.gnu.org/licenses/>.
Packit 6c4009
Packit 6c4009
use GlibcConform;
Packit 6c4009
use Getopt::Long;
Packit 6c4009
Packit 6c4009
GetOptions ('headers=s' => \$headers, 'standard=s' => \$standard,
Packit 6c4009
	    'flags=s' => \$flags, 'cc=s' => \$CC, 'tmpdir=s' => \$tmpdir);
Packit 6c4009
@headers = split (/\s+/, $headers);
Packit 6c4009
Packit 6c4009
# Extra symbols possibly not found through -aux-info but still
Packit 6c4009
# reserved by the standard: either data symbols, or symbols where the
Packit 6c4009
# standard leaves unspecified whether the identifier is a macro or
Packit 6c4009
# defined with external linkage.
Packit 6c4009
$extra_syms{"ISO"} = ["errno", "setjmp", "va_end"];
Packit 6c4009
$extra_syms{"ISO99"} = ["errno", "math_errhandling", "setjmp", "va_end"];
Packit 6c4009
# stdatomic.h not yet covered by conformance tests; as per DR#419, all
Packit 6c4009
# the generic functions there or may not be defined with external
Packit 6c4009
# linkage (but are reserved in any case).
Packit 6c4009
$extra_syms{"ISO11"} = ["errno", "math_errhandling", "setjmp", "va_end"];
Packit 6c4009
# The following lists may not be exhaustive.
Packit 6c4009
$extra_syms{"POSIX"} = ["errno", "setjmp", "va_end", "environ", "sigsetjmp",
Packit 6c4009
			"optarg", "optind", "opterr", "optopt", "tzname"];
Packit 6c4009
$extra_syms{"XPG4"} = ["errno", "setjmp", "va_end", "environ", "signgam",
Packit 6c4009
		       "loc1", "loc2", "locs", "sigsetjmp", "optarg",
Packit 6c4009
		       "optind", "opterr", "optopt", "daylight", "timezone",
Packit 6c4009
		       "tzname"];
Packit 6c4009
$extra_syms{"XPG42"} = ["errno", "setjmp", "va_end", "environ", "signgam",
Packit 6c4009
		       "loc1", "loc2", "locs", "sigsetjmp", "optarg",
Packit 6c4009
		       "optind", "opterr", "optopt", "daylight", "timezone",
Packit 6c4009
		       "tzname", "getdate_err", "h_errno"];
Packit 6c4009
$extra_syms{"UNIX98"} = ["errno", "setjmp", "va_end", "environ", "signgam",
Packit 6c4009
			 "loc1", "loc2", "locs", "sigsetjmp", "optarg",
Packit 6c4009
			 "optind", "opterr", "optopt", "daylight", "timezone",
Packit 6c4009
			 "tzname", "getdate_err", "h_errno"];
Packit 6c4009
$extra_syms{"XOPEN2K"} = ["errno", "setjmp", "va_end", "environ", "signgam",
Packit 6c4009
			  "sigsetjmp", "optarg", "optind", "opterr", "optopt",
Packit 6c4009
			  "daylight", "timezone", "tzname", "getdate_err",
Packit 6c4009
			  "h_errno", "in6addr_any", "in6addr_loopback"];
Packit 6c4009
$extra_syms{"XOPEN2K8"} = ["errno", "setjmp", "va_end", "environ", "signgam",
Packit 6c4009
			   "sigsetjmp", "optarg", "optind", "opterr", "optopt",
Packit 6c4009
			   "daylight", "timezone", "tzname", "getdate_err",
Packit 6c4009
			   "in6addr_any", "in6addr_loopback"];
Packit 6c4009
$extra_syms{"POSIX2008"} = ["errno", "setjmp", "va_end", "environ",
Packit 6c4009
			    "sigsetjmp", "optarg", "optind", "opterr", "optopt",
Packit 6c4009
			    "tzname", "in6addr_any", "in6addr_loopback"];
Packit 6c4009
Packit 6c4009
%user_syms = ();
Packit 6c4009
Packit 6c4009
foreach my $header (@headers) {
Packit 6c4009
  @syms = list_exported_functions ("$CC $flags", $standard, $header, $tmpdir);
Packit 6c4009
  foreach my $sym (@syms) {
Packit 6c4009
    if ($sym !~ /^_/) {
Packit 6c4009
      $user_syms{$sym} = 1;
Packit 6c4009
    }
Packit 6c4009
  }
Packit 6c4009
}
Packit 6c4009
foreach my $sym (@{$extra_syms{$standard}}) {
Packit 6c4009
  $user_syms{$sym} = 1;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
foreach my $sym (sort keys %user_syms) {
Packit 6c4009
  print "$sym\n";
Packit 6c4009
}