[PATCH v7] String: Add support for __memcmpeq() ABI on all targets

Adhemerval Zanella adhemerval.zanella@linaro.org
Thu Oct 21 20:26:10 GMT 2021



On 21/10/2021 17:23, Noah Goldstein wrote:
> On Thu, Oct 21, 2021 at 3:02 PM Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>>
>>>>> diff --git a/string/string.h b/string/string.h
>>>>> index 04e1b7067d..d0b714f836 100644
>>>>> --- a/string/string.h
>>>>> +++ b/string/string.h
>>>>> @@ -64,6 +64,22 @@ extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
>>>>>  extern int memcmp (const void *__s1, const void *__s2, size_t __n)
>>>>>       __THROW __attribute_pure__ __nonnull ((1, 2));
>>>>>
>>>>> +/* Compare N bytes of S1 and S2.  Return zero if S1 and S2 are equal.
>>>>> +   Return some non-zero value otherwise.
>>>>> +
>>>>> +   Essentially __memcmpeq has the exact same semantics as memcmp
>>>>> +   except the return value is less constrained.  memcmp is always a
>>>>> +   correct implementation of __memcmpeq.  As well !!memcmp, -memcmp,
>>>>> +   or bcmp are correct implementations.
>>>>> +
>>>>> +   __memcmpeq is meant to be used by compilers when memcmp return is
>>>>> +   only used for its bolean value.
>>>>> +
>>>>> +   __memcmpeq is declared only for use by compilers.  Programs should
>>>>> +   continue to use memcmp.  */
>>>>> +extern int __memcmpeq (const void *__s1, const void *__s2, size_t __n)
>>>>> +     __THROW __attribute_pure__ __nonnull ((1, 2));
>>>>
>>>> Please add an internal one in include/string.h so that it can be called
>>>> within libc.so bypassing PLT.  Find one place in glibc where __memcmpeq
>>>> can be used and use it.
>>>
>>> Usage outside of a test? It is currently used directly in string/tester.c
>>
>>
>> Add a libc_hidden_proto on include/string.h and a libc_hidden_def on
>> each implementation to create a local alias that bypass PLT if we
>> eventually need to call it from within glibc.
> 
> Does each place this patch does 'weak_alias(memcmp, __memcmpeq)`
> need a 'libc_hidden_def' for '__memcmpeq'?

Yes, it might not generate regression, but it will once we start to call
__memcmpeq internally (which compiler might generate eventually).


More information about the Libc-alpha mailing list