]> git.ipfire.org Git - thirdparty/glibc.git/commit
support: add support_address_diff function
authorYury Khrustalev <yury.khrustalev@arm.com>
Wed, 25 Mar 2026 10:04:19 +0000 (10:04 +0000)
committerYury Khrustalev <yury.khrustalev@arm.com>
Wed, 22 Apr 2026 13:55:12 +0000 (14:55 +0100)
commitd4c66edeef6ced8fd15af0b3bfdadfb80501e96e
treea48f1b442dd3288c8452ce6e24f91da49fed98b7
parent969cc1df8f467ce3367149628da426692c774083
support: add support_address_diff function

Some malloc tests compare pointers meaning to compare addresses.
On AArch64, the 64-bit value of the pointer may contain metadata
along with the values of the address.

In order to correctly compare addresses, we add new function for
AArch64 target that will use the AArch64 64 SUBP (subtract pointer)
instruction when it is available. This instruction uses the 56-bit
addresses ignoring top-byte metadata.

Best implementation is selected using ifunc resolver.

On other targets and also on AArch64 when MTE is not available this
function defaults to PTR_DIFF defined in libc-pointer-arith.h.

Three malloc tests are modified accordingly:
 - tst-memalign-2.c
 - tst-memalign-3.c
 - tst-realloc.c

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
malloc/tst-memalign-2.c
malloc/tst-memalign-3.c
malloc/tst-realloc.c
support/Makefile
support/address-diff.h [new file with mode: 0644]
sysdeps/aarch64/Makefile
sysdeps/aarch64/support-address-diff.c [new file with mode: 0644]
sysdeps/generic/Makefile
sysdeps/generic/support-address-diff.c [new file with mode: 0644]