def main(): """The main entry point.""" parser = argparse.ArgumentParser( description="Test that glibc's sys/mman.h constants " "match the kernel's.") parser.add_argument('--cc', metavar='CC', help='C compiler (including options) to use') args = parser.parse_args() linux_version_headers = linux_kernel_version(args.cc) linux_version_glibc = (4, 20) sys.exit(glibcextract.compare_macro_consts( '#define _GNU_SOURCE 1\n' '#include <sys/mman.h>\n', '#define _GNU_SOURCE 1\n' '#include <linux/mman.h>\n', args.cc, 'MAP_.*', # A series of MAP_HUGE_<size> macros are defined by the kernel # but not by glibc. MAP_UNINITIALIZED is kernel-only. # MAP_FAILED is not a MAP_* flag and is glibc-only, as is the # MAP_ANON alias for MAP_ANONYMOUS. MAP_RENAME, MAP_AUTOGROW, # MAP_LOCAL and MAP_AUTORSRV are in the kernel header for # MIPS, marked as "not used by linux"; SPARC has MAP_INHERIT # in the kernel header, but does not use it. 'MAP_HUGE_[0-9].*|MAP_UNINITIALIZED|MAP_FAILED|MAP_ANON' '|MAP_RENAME|MAP_AUTOGROW|MAP_LOCAL|MAP_AUTORSRV|MAP_INHERIT', linux_version_glibc > linux_version_headers, linux_version_headers > linux_version_glibc))
def main(): """The main entry point.""" parser = argparse.ArgumentParser( description="Test that glibc's sys/mman.h constants " "match the kernel's.") parser.add_argument('--cc', metavar='CC', help='C compiler (including options) to use') args = parser.parse_args() linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc) linux_version_glibc = (5, 5) sys.exit( glibcextract.compare_macro_consts( '#define _GNU_SOURCE 1\n' '#include <sys/mman.h>\n', '#define _GNU_SOURCE 1\n' '#include <linux/mman.h>\n', args.cc, 'MAP_.*', # A series of MAP_HUGE_<size> macros are defined by the kernel # but not by glibc. MAP_UNINITIALIZED is kernel-only. # MAP_FAILED is not a MAP_* flag and is glibc-only, as is the # MAP_ANON alias for MAP_ANONYMOUS. MAP_RENAME, MAP_AUTOGROW, # MAP_LOCAL and MAP_AUTORSRV are in the kernel header for # MIPS, marked as "not used by linux"; SPARC has MAP_INHERIT # in the kernel header, but does not use it. 'MAP_HUGE_[0-9].*|MAP_UNINITIALIZED|MAP_FAILED|MAP_ANON' '|MAP_RENAME|MAP_AUTOGROW|MAP_LOCAL|MAP_AUTORSRV|MAP_INHERIT', linux_version_glibc > linux_version_headers, linux_version_headers > linux_version_glibc))
def check(cte, exclude=None): return glibcextract.compare_macro_consts( '#include <sys/mount.h>\n', '#include <asm/fcntl.h>\n' '#include <linux/mount.h>\n', args.cc, cte, exclude, linux_version_glibc > linux_version_headers, linux_version_headers > linux_version_glibc)
def main(): """The main entry point.""" parser = argparse.ArgumentParser( description="Test that glibc's signal numbers match the kernel's.") parser.add_argument('--cc', metavar='CC', help='C compiler (including options) to use') args = parser.parse_args() sys.exit(glibcextract.compare_macro_consts( '#define _GNU_SOURCE 1\n' '#include <signal.h>\n', '#define _GNU_SOURCE 1\n' '#include <stddef.h>\n' '#include <asm/signal.h>\n', args.cc, # Filter out constants that aren't signal numbers. 'SIG[A-Z]+', # Discard obsolete signal numbers and unrelated constants: # SIGCLD, SIGIOT, SIGSWI, SIGUNUSED. # SIGSTKSZ, SIGRTMIN, SIGRTMAX. 'SIG(CLD|IOT|RT(MIN|MAX)|STKSZ|SWI|UNUSED)'))
def check(define): return glibcextract.compare_macro_consts( source_1=define + '#include <sys/socket.h>\n', # Some constants in <asm/socket.h> may depend on the size # of pid_t or time_t. source_2='#include <sys/types.h>\n' '#include <asm/socket.h>\n', cc=args.cc, # We cannot compare all macros because some macros cannot # be expanded as constants, and glibcextract currently is # not able to isolate errors. macro_re='SOL?_.*', # <sys/socket.h> and <asm/socket.h> are not a good match. # Most socket-related constants are not defined in any # UAPI header. Check only the intersection of the macros # in both headers. Regular tests ensure that expected # macros for _GNU_SOURCE are present, and the conformance # tests cover most of the other modes. allow_extra_1=True, allow_extra_2=True)
def main(): """The main entry point.""" parser = argparse.ArgumentParser( description="Test that glibc's signal numbers match the kernel's.") parser.add_argument('--cc', metavar='CC', help='C compiler (including options) to use') args = parser.parse_args() sys.exit(glibcextract.compare_macro_consts( '#define _GNU_SOURCE 1\n' '#include <signal.h>\n', '#define _GNU_SOURCE 1\n' '#include <stddef.h>\n' '#include <asm/signal.h>\n', args.cc, # Filter out constants that aren't signal numbers. 'SIG[A-Z]+', # Discard obsolete signal numbers and unrelated constants: # SIGCLD, SIGIOT, SIGSWI, SIGUNUSED. # SIGSTKSZ, SIGRTMIN, SIGRTMAX. 'SIG(CLD|IOT|RT(MIN|MAX)|STKSZ|SWI|UNUSED)'))
def main(): """The main entry point.""" parser = argparse.ArgumentParser( description="Test that glibc's sys/pidfd.h constants " "match the kernel's.") parser.add_argument('--cc', metavar='CC', help='C compiler (including options) to use') args = parser.parse_args() linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc) # Linux started to provide pidfd.h with 5.10. if linux_version_headers < (5, 10): sys.exit(77) linux_version_glibc = (5, 18) sys.exit( glibcextract.compare_macro_consts( '#include <sys/pidfd.h>\n', '#include <asm/fcntl.h>\n' '#include <linux/pidfd.h>\n', args.cc, 'PIDFD_.*', None, linux_version_glibc > linux_version_headers, linux_version_headers > linux_version_glibc))