Hi Cristian, On 12/29/22 20:50, Alejandro Colomar wrote:
On 12/29/22 20:45, Cristian Rodríguez wrote:On Thu, Dec 29, 2022 at 4:20 PM Alejandro Colomar via Libc-alpha <libc-alpha@xxxxxxxxxxxxxx> wrote:
[...]
The library itself uses this function mostly to find NULL as an optimization. This is all before GCC handled all of this so it is mostly obsolete. gcc replaces null byte searches that use str*chr with s + strlen(s) and expands memchr c=null and rawmemchr-like patterns inline.You mean that GCC does the following?: inline size_t strlen(const char *s) { return rawmemchr(s, '\0');
Obvious typo here: I forgot to subtract s.
}If so, great, because I am writing a libc replacement, and was implementing strlen(3) exactly like that, which is why I needed the docs. It may be something not very useful, but I guess it's still very useful for libc internals.
It seems I misunderstood your email. I've seen that glibc implements rawmemchr(3) in terms of strlen(3) and memchr(3). So it seems better to just not implement this function in my library, and optimize strlen(3) directly. The non-'\0' case seems useless, so probably not worth this function unless I see a use for it.
Cheers, Alex -- <http://www.alejandro-colomar.es/>
Attachment:
OpenPGP_signature
Description: OpenPGP digital signature