[PATCH v4 3/3] aarch64: helper function to access hwcap elements in ifunc resolver
Florian Weimer
fweimer@redhat.com
Fri Apr 25 15:25:43 GMT 2025
> On Fri, Apr 25, 2025 at 7:35 AM Yury Khrustalev <yury.khrustalev@arm.com> wrote:
>>
>> Add a portable way to access HWCAP elements via the parameter(s)
>> passed to an ifunc resolver checking the _IFUNC_ARG_HWCAP in the
>> first parameter and size of the buffer in the second parameter.
>>
>> Note that 0 is return when the requested element is not available.
>>
>> Also add an enum for HWCAP element IDs to facilitate writing more
>> readable code.
>> ---
>> sysdeps/aarch64/sys/ifunc.h | 25 +++++++++++++++++++++++++
>> sysdeps/aarch64/tst-ifunc-arg-1.c | 12 ++++++++++++
>> sysdeps/aarch64/tst-ifunc-arg-2.c | 11 +++++++++++
>> 3 files changed, 48 insertions(+)
>>
>> diff --git a/sysdeps/aarch64/sys/ifunc.h b/sysdeps/aarch64/sys/ifunc.h
>> index fd4d49f00b..d74eb560e5 100644
>> --- a/sysdeps/aarch64/sys/ifunc.h
>> +++ b/sysdeps/aarch64/sys/ifunc.h
>> @@ -19,6 +19,8 @@
>> #ifndef _SYS_IFUNC_H
>> #define _SYS_IFUNC_H
>>
>> +#include <sys/cdefs.h>
>> +
>> /* A second argument is passed to the ifunc resolver. */
>> #define _IFUNC_ARG_HWCAP (1ULL << 62)
>>
>> @@ -64,4 +66,27 @@ struct __ifunc_arg_t
>>
>> typedef struct __ifunc_arg_t __ifunc_arg_t;
>>
>> +/* ID values for the helper function below. */
>> +enum
>> +{
>> + __IFUNC_HWCAP = 1,
>> + __IFUNC_HWCAP2,
>> + __IFUNC_HWCAP3,
>> + __IFUNC_HWCAP4,
>> +};
>
> i get why you're adding this enum -- so you can say __IFUNC_HWCAP
> rather than 1, which isn't as clear as 2 and later -- but this seems
> to partly defeat the purpose of switching to the function. one of the
> beauties of the function is that you never need to touch this header
> again. personally i think i'd rather live with 1 than undo that?
HWCAP is already passed as the first argument of the IFUNC resolver, so
I don't think people would write
__ifunc_hwcap (1, hwcap, args)
to get this value. Wouldn't they just use hwcap directly?
Thanks,
Florian
More information about the Libc-alpha
mailing list