[PATCH] memchr.3: Deprecate rawmemchr(3)
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Fri Jan 6 12:57:03 GMT 2023
- Previous message (by thread): [PATCH] memchr.3: Deprecate rawmemchr(3)
- Next message (by thread): [PATCH] bind.2, mount_setattr.2, openat2.2, perf_event_open.2, pidfd_send_signal.2, recvmmsg.2, seccomp_unotify.2, select_tut.2, sendmmsg.2, set_thread_area.2, sysctl.2, bzero.3, getaddrinfo.3, getaddrinfo_a.3, getutent.3, mbrtowc.3, mbsinit.3, rtime.3, rtnetlink.3, strptime.3, NULL.3const, size_t.3type, void.3type, aio.7, netlink.7, unix.7: Prefer bzero(3) over memset(3)
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Hi Alex,
> It is not optimized, and it calls either strlen(3) or memchr(3), so the
> caller can do it directly, and it will be better.
>
> Suggested-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
> Signed-off-by: Alejandro Colomar <alx@kernel.org>
This looks good to me. Btw in the codesearch there are about 800
uses, the majority looks like prototypes etc, so there are few actual
uses. Interestingly GLIBC still contains this:
#ifdef _LIBC
p = __rawmemchr (p, '\0');
#else
p = strchr (p, '\0');
#endif
The strchr (p, 0) is optimized by compilers into strlen (since that's
obviously the right optimization) so adding rawmemchr was not
only wasted effort, but it made things slower as well. So we should
remove these uses from GLIBC.
Cheers,
Wilco
- Previous message (by thread): [PATCH] memchr.3: Deprecate rawmemchr(3)
- Next message (by thread): [PATCH] bind.2, mount_setattr.2, openat2.2, perf_event_open.2, pidfd_send_signal.2, recvmmsg.2, seccomp_unotify.2, select_tut.2, sendmmsg.2, set_thread_area.2, sysctl.2, bzero.3, getaddrinfo.3, getaddrinfo_a.3, getutent.3, mbrtowc.3, mbsinit.3, rtime.3, rtnetlink.3, strptime.3, NULL.3const, size_t.3type, void.3type, aio.7, netlink.7, unix.7: Prefer bzero(3) over memset(3)
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Libc-alpha
mailing list