2 # Test that glibc's sys/socket.h SO_* constants match the kernel's.
3 # Copyright (C) 2018-2024 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
6 # The GNU C Library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # The GNU C Library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with the GNU C Library; if not, see
18 # <https://www.gnu.org/licenses/>.
26 """The main entry point."""
27 parser
= argparse
.ArgumentParser(
28 description
="Test that glibc's sys/socket.h constants "
29 "match the kernel's.")
30 parser
.add_argument('--cc', metavar
='CC',
31 help='C compiler (including options) to use')
32 args
= parser
.parse_args()
35 return glibcextract
.compare_macro_consts(
36 source_1
=define
+ '#include <sys/socket.h>\n',
37 # Some constants in <asm/socket.h> may depend on the size
39 source_2
='#include <sys/types.h>\n'
40 '#include <asm/socket.h>\n',
42 # We cannot compare all macros because some macros cannot
43 # be expanded as constants, and glibcextract currently is
44 # not able to isolate errors.
46 # <sys/socket.h> and <asm/socket.h> are not a good match.
47 # Most socket-related constants are not defined in any
48 # UAPI header. Check only the intersection of the macros
49 # in both headers. Regular tests ensure that expected
50 # macros for _GNU_SOURCE are present, and the conformance
51 # tests cover most of the other modes.
54 # _GNU_SOURCE is defined by include/libc-symbols.h, which is
55 # included by the --cc command. Defining _ISOMAC does not prevent
59 check('#undef _GNU_SOURCE\n'),
60 check('#undef _GNU_SOURCE\n'
61 '#define _POSIX_SOURCE 1\n'))
64 if __name__
== '__main__':