glibc/scripts
Zack Weinberg 2ec0b166bf Use a proper C tokenizer to implement the obsolete typedefs test.
The test for obsolete typedefs in installed headers was implemented
using grep, and could therefore get false positives on e.g. “ulong”
in a comment.  It was also scanning all of the headers included by
our headers, and therefore testing headers we don’t control, e.g.
Linux kernel headers.

This patch splits the obsolete-typedef test from
scripts/check-installed-headers.sh to a separate program,
scripts/check-obsolete-constructs.py.  Being implemented in Python,
it is feasible to make it tokenize C accurately enough to avoid false
positives on the contents of comments and strings.  It also only
examines $(headers) in each subdirectory--all the headers we install,
but not any external dependencies of those headers.  Headers whose
installed name starts with finclude/ are ignored, on the assumption
that they contain Fortran.

It is also feasible to make the new test understand the difference
between _defining_ the obsolete typedefs and _using_ the obsolete
typedefs, which means posix/{bits,sys}/types.h no longer need to be
exempted.  This uncovered an actual bug in bits/types.h: __quad_t and
__u_quad_t were being used to define __S64_TYPE, __U64_TYPE,
__SQUAD_TYPE and __UQUAD_TYPE.  These are changed to __int64_t and
__uint64_t respectively.  This is a safe change, despite the comments
in bits/types.h claiming a difference between __quad_t and __int64_t,
because those comments are incorrect.  In all current ABIs, both
__quad_t and __int64_t are ‘long’ when ‘long’ is a 64-bit type, and
‘long long’ when ‘long’ is a 32-bit type, and similarly for __u_quad_t
and __uint64_t.  (Changing the types to be what the comments say they
are would be an ABI break, as it affects C++ name mangling.)  This
patch includes a minimal change to make the comments not completely
wrong.

sys/types.h was defining the legacy BSD u_intN_t typedefs using a
construct that was not necessarily consistent with how the C99 uintN_t
typedefs are defined, and is also too complicated for the new script to
understand (it lexes C relatively accurately, but it does not attempt
to expand preprocessor macros, nor does it do any actual parsing).
This patch cuts all of that out and uses bits/types.h's __uintN_t typedefs
to define u_intN_t instead.  This is verified to not change the ABI on
any supported architecture, via the c++-types test, which means u_intN_t
and uintN_t were, in fact, consistent on all supported architectures.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* scripts/check-obsolete-constructs.py: New test script.
	* scripts/check-installed-headers.sh: Remove tests for
	obsolete typedefs, superseded by check-obsolete-constructs.py.
	* Rules: Run scripts/check-obsolete-constructs.py over $(headers)
	as a special test.  Update commentary.
	* posix/bits/types.h (__SQUAD_TYPE, __S64_TYPE): Define as __int64_t.
	(__UQUAD_TYPE, __U64_TYPE): Define as __uint64_t.
	Update commentary.
	* posix/sys/types.h (__u_intN_t): Remove.
	(u_int8_t): Typedef using __uint8_t.
	(u_int16_t): Typedef using __uint16_t.
	(u_int32_t): Typedef using __uint32_t.
	(u_int64_t): Typedef using __uint64_t.

(cherry picked from commit 711a322a23)
2019-06-05 14:15:01 +02:00
..
abi-versions.awk Remove bitrotten --enable-oldest-abi (bug 6652). 2014-09-16 17:45:03 +00:00
abilist.awk scripts/abilist.awk: Handle special _end symbol for Hurd 2018-11-30 22:22:57 +01:00
backport-support.sh Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
build-many-glibcs.py Use binutils 2.32 branch in build-many-glibcs.py. 2019-01-21 22:51:18 +00:00
check-c++-types.sh Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
check-execstack.awk check-execstack: Permit sysdeps to xfail some libs 2018-07-20 03:28:14 +02:00
check-initfini.awk Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
check-installed-headers.sh Use a proper C tokenizer to implement the obsolete typedefs test. 2019-06-05 14:15:01 +02:00
check-local-headers.sh Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
check-localplt.awk Extend local PLT reference check 2015-07-29 11:58:06 -07:00
check-obsolete-constructs.py Use a proper C tokenizer to implement the obsolete typedefs test. 2019-06-05 14:15:01 +02:00
check-textrel.awk Do check-textrel test using readelf rather than a build-time C program. 2012-05-01 13:27:11 -07:00
config-uname.sh Rejigger header generation for default uname implementation. 2010-08-24 11:56:52 -07:00
config.guess Update miscellaneous files from upstream sources. 2019-01-01 00:52:59 +00:00
config.sub Update miscellaneous files from upstream sources. 2019-01-01 00:52:59 +00:00
cpp Make shebang interpreter directives consistent 2016-01-07 04:03:21 -05:00
cross-test-ssh.sh Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
documented.sh Make shebang interpreter directives consistent 2016-01-07 04:03:21 -05:00
evaluate-test.sh Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
firstversions.awk Fix bug in firstversions.awk version range handling. 2012-01-28 12:02:44 -05:00
gen-as-const.py Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
gen-libc-abis Make shebang interpreter directives consistent 2016-01-07 04:03:21 -05:00
gen-libc-modules.awk Auto-generate libc-modules.h 2014-11-19 12:16:00 +05:30
gen-posix-conf-vars.awk Remove uses of sprintf in gen-posix-conf-vars.awk 2015-01-02 11:16:35 +05:30
gen-rrtypes.py Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
gen-sorted.awk Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
gen-tunables.awk Fix range check in do_tunable_update_val 2017-09-27 02:44:09 +05:30
glibcextract.py Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
haveversions.awk Don't build libnsl for new ABIs 2018-09-24 10:23:10 +02:00
install-sh Update miscellaneous files from upstream sources. 2018-12-06 17:21:47 +00:00
lib-names.awk Clean up gnu/lib-names.h generation (bug 14171). 2014-09-26 17:33:04 +00:00
list-fixed-bugs.py Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
list-sources.sh Update scripts/list-sources.sh for ports repository merge. 2014-06-26 21:30:07 +00:00
localplt.awk Support PLT and GOT references in local PIC check 2015-10-14 06:00:02 -07:00
merge-test-results.sh Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
mkinstalldirs Update miscellaneous files from upstream sources. 2018-12-06 17:21:47 +00:00
move-if-change Update miscellaneous files from upstream sources. 2019-01-01 00:52:59 +00:00
output-format.sed 2004-08-13 Daniel Jacobowitz <dan@debian.org> 2004-08-14 06:54:39 +00:00
pylint Implement benchmarking script in python 2014-03-21 17:32:50 +05:30
pylintrc pylintrc: disable reports 2015-11-11 13:41:57 -05:00
rellns-sh Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
soversions.awk Remove bitrotten --enable-oldest-abi (bug 6652). 2014-09-16 17:45:03 +00:00
sysd-rules.awk sysd-rules: Cut down the number of rtld-% pattern rules 2016-09-20 10:41:05 +02:00
test-installation.pl Update copyright dates not handled by scripts/update-copyrights. 2019-01-01 00:15:13 +00:00
test_printers_common.py Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
test_printers_exceptions.py Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
update-abilist.sh Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
update-copyrights Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
versionlist.awk Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
versions.awk Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00