[PATCH] support: add __address_diff function
Yury Khrustalev
yury.khrustalev@arm.com
Wed Mar 25 12:20:38 GMT 2026
Hello Florian
Thanks for the feedback!
On Wed, Mar 25, 2026 at 12:52:13PM +0100, Florian Weimer wrote:
> * Yury Khrustalev:
>
> > diff --git a/support/pointer-arith.h b/support/pointer-arith.h
> > new file mode 100644
> > index 0000000000..fc9cf593ac
> > --- /dev/null
> > +++ b/support/pointer-arith.h
> > @@ -0,0 +1,31 @@
>
> > +#ifndef _POINTER_ARITH_H
> > +#define _POINTER_ARITH_H 1
> > +
> > +#include <stddef.h>
> > +#include <libc-pointer-arith.h>
> > +
> > +#ifdef __ARM_ARCH_ISA_A64
> > +ptrdiff_t __address_diff (const void *lhs, const void *rhs);
> > +#else
> > +#define __address_diff PTR_DIFF
> > +#endif /* __ARM_ARCH_ISA_A64 */
> > +
> > +#endif
>
> Given that it's in support/, it should probably be called
> support_address_diff or something. We don't use __ mangling under
> support/.
OK
> The #ifdef is not necessary, sysdeps overrides should work for support/
> headers.
I've tried this but it doesn't seem to be working. Ideally, I want to
have the support_pointer_arith.c file only under sysdeps/aarch64 because
for all other targets the PTR_DIFF macro should be used, but makefile in
the support folder should probably be modified for this?
Any help here very much appreciated.
> The comment should say that the difference is computed in
> bytes, not elements.
OK, though it is difference in addresses, so it's implied that it's in
bytes? I will clarify in the comment anyway.
Thanks,
Yury
More information about the Libc-alpha
mailing list