[PATCH v3] aarch64: add support for hwcap3,4
enh
enh@google.com
Wed Apr 23 12:19:07 GMT 2025
On Wed, Apr 23, 2025 at 5:22 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * Yury Khrustalev:
>
> > Hi,
> >
> >> From: enh <enh@google.com>
> >> Sent: 22 April 2025 04:58 PM
> >> To: Yury Khrustalev
> >> Cc: libc-alpha@sourceware.org; fweimer@redhat.com; adhemerval.zanella@linaro.org
> >> Subject: Re: [PATCH v3] aarch64: add support for hwcap3,4
> >>
> >> On Tue, Apr 22, 2025 at 11:52 AM enh <enh@google.com> wrote:
> >> ...
> >> having updated some ifunc resolvers to see what this looks like, i
> >> find the "off by one" in the array versus the constants quite
> >> off-putting.
> >>
> >> adding
> >> ```
> >> #define _hwcap3 _hwcap_array[2]
> >> ```
> >> etc seems quite tempting for better readability at the call sites.
> >
> > To be honest, I would just do that:
> >
> > struct __ifunc_arg_t
> > {
> > unsigned long _size;
> > unsigned long _hwcap_array[_IFUNC_HWCAP_MAX];
> > };
> >
> > And define these macros for the sake of existing code to compiler
> > without errors:
> >
> > #define _hwcap _hwcap_array[0]
> > #define _hwcap2 _hwcap_array[1]
>
> We can turn the argument into an const unsigned long int * pointer, with
> the size in at index 0. Then _IFUNC_HWCAP_MAX won't be needed, and
> access can use something like
>
> __ifunc_hwcap (const unsigned long int *__arg, unsigned long int __index)
> {
> return __index - 1 < __arg[0] ? __arg[__index] : 0;
> }
>
> So __ifunc_hwcap (arg, 1) to access AT_HWCAP, __ifunc_hwcap (arg, 2) for
> AT_HWCAP2, and in the future __ifunc_hwcap (arg, 3).
oh, i love that!
> Thanks,
> Florian
>
More information about the Libc-alpha
mailing list