public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Interest in having a mempbrk() function in glibc
@ 2022-01-06  6:44 Zhao Wei Liew
  2022-01-06 10:20 ` Cristian Rodríguez
  0 siblings, 1 reply; 3+ messages in thread
From: Zhao Wei Liew @ 2022-01-06  6:44 UTC (permalink / raw)
  To: libc-alpha

Hi,

Is there any interest in having a mempbrk() function in glibc? It would be
the mem* version of strpbrk(); it takes a len parameter instead of relying
on the string being null-terminated.

I ask because it seems that there is significant interest in the wild, with
several projects implementing their own mempbrk(), such as Abseil [1] and
Wireshark [2]. In fact, Wireshark even implements a SSE4.2 version of
mempbrk() for strings with length 16 or more [3].

Personally, I've come across a related missed optimization with
libstdc++'s string_view::find_first_of(), which is implemented with
memchr() [4]. It appears that the whole missed optimization could've been
avoided if string_view::find_first_of() was implemented with a mempbrk()
function.

Hence, may I know what your thoughts are of having mempbrk() in glibc?
Thanks!

[1]:
https://github.com/abseil/abseil-cpp/blob/1ae9b71c474628d60eb251a3f62967fe64151bb2/absl/strings/internal/memutil.cc#L76

[2]:
https://github.com/wireshark/wireshark/blob/eb5f4eea99593b92298bacecc5c9d885cc13a9ad/wsutil/ws_mempbrk.c#L64

[3]:
https://github.com/wireshark/wireshark/blob/eb5f4eea99593b92298bacecc5c9d885cc13a9ad/wsutil/ws_mempbrk_sse42.c#L99

[4]:
https://stackoverflow.com/questions/70433152/missed-optimization-with-string-viewfind-first-of

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Interest in having a mempbrk() function in glibc
  2022-01-06  6:44 Interest in having a mempbrk() function in glibc Zhao Wei Liew
@ 2022-01-06 10:20 ` Cristian Rodríguez
  2022-01-06 10:25   ` Zhao Wei Liew
  0 siblings, 1 reply; 3+ messages in thread
From: Cristian Rodríguez @ 2022-01-06 10:20 UTC (permalink / raw)
  To: Zhao Wei Liew; +Cc: libc-alpha

Is there a patch to review or support ?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Interest in having a mempbrk() function in glibc
  2022-01-06 10:20 ` Cristian Rodríguez
@ 2022-01-06 10:25   ` Zhao Wei Liew
  0 siblings, 0 replies; 3+ messages in thread
From: Zhao Wei Liew @ 2022-01-06 10:25 UTC (permalink / raw)
  To: Cristian Rodríguez; +Cc: libc-alpha

On Thu, 6 Jan 2022 at 18:20, Cristian Rodríguez <crrodriguez@opensuse.org>
wrote:

> Is there a patch to review or support ?
>

Not right now but I could work on one. I mainly wanted to understand
whether it makes sense to do so, as I'm unsure if it is something that
folks would support.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-06 10:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-06  6:44 Interest in having a mempbrk() function in glibc Zhao Wei Liew
2022-01-06 10:20 ` Cristian Rodríguez
2022-01-06 10:25   ` Zhao Wei Liew

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).