2 # Print a list of symbols exported by some headers that would
3 # otherwise be in the user's namespace.
4 # Copyright (C) 2018-2024 Free Software Foundation, Inc.
5 # This file is part of the GNU C Library.
7 # The GNU C Library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # The GNU C Library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with the GNU C Library; if not, see
19 # <https://www.gnu.org/licenses/>.
25 # Extra symbols possibly not found through -aux-info but still
26 # reserved by the standard: either data symbols, or symbols where the
27 # standard leaves unspecified whether the identifier is a macro or
28 # defined with external linkage.
30 EXTRA_SYMS
['ISO'] = {'errno', 'setjmp', 'va_end'}
31 EXTRA_SYMS
['ISO99'] = EXTRA_SYMS
['ISO'] |
{'math_errhandling'}
32 # stdatomic.h not yet covered by conformance tests; as per DR#419, all
33 # the generic functions there or may not be defined with external
34 # linkage (but are reserved in any case).
35 EXTRA_SYMS
['ISO11'] = EXTRA_SYMS
['ISO99']
36 # The following lists may not be exhaustive.
37 EXTRA_SYMS
['POSIX'] = (EXTRA_SYMS
['ISO']
38 |
{'environ', 'sigsetjmp', 'optarg', 'optind', 'opterr',
40 EXTRA_SYMS
['XPG4'] = (EXTRA_SYMS
['POSIX']
41 |
{'signgam', 'loc1', 'loc2', 'locs', 'daylight',
43 EXTRA_SYMS
['XPG42'] = EXTRA_SYMS
['XPG4'] |
{'getdate_err', 'h_errno'}
44 EXTRA_SYMS
['UNIX98'] = EXTRA_SYMS
['XPG42']
45 EXTRA_SYMS
['XOPEN2K'] = (EXTRA_SYMS
['POSIX']
46 |
{'signgam', 'daylight', 'timezone', 'getdate_err',
47 'h_errno', 'in6addr_any', 'in6addr_loopback'})
48 EXTRA_SYMS
['POSIX2008'] = (EXTRA_SYMS
['POSIX']
49 |
{'in6addr_any', 'in6addr_loopback'})
50 EXTRA_SYMS
['XOPEN2K8'] = (EXTRA_SYMS
['POSIX2008']
51 |
{'signgam', 'daylight', 'timezone', 'getdate_err'})
55 """The main entry point."""
56 parser
= argparse
.ArgumentParser(description
='List exported symbols.')
57 parser
.add_argument('--headers', metavar
='HEADERS',
58 help='list of headers')
59 parser
.add_argument('--standard', metavar
='STD',
60 help='standard to use when processing headers')
61 parser
.add_argument('--cc', metavar
='CC',
62 help='C compiler to use')
63 parser
.add_argument('--flags', metavar
='CFLAGS',
64 help='Compiler flags to use with CC')
65 args
= parser
.parse_args()
67 compiler
= '%s %s' % (args
.cc
, args
.flags
)
68 for header
in args
.headers
.split():
69 fns |
= glibcconform
.list_exported_functions(compiler
, args
.standard
,
71 fns |
= EXTRA_SYMS
[args
.standard
]
72 print('\n'.join(sorted(fn
for fn
in fns
if not fn
.startswith('_'))))
75 if __name__
== '__main__':