From: Bartosz Golaszewski <brgl@bgdev.pl>
To: musl@lists.openwall.com
Cc: Rich Felker <dalias@libc.org>,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [musl] [PATCH] search: provide twalk_r()
Date: Fri, 10 Feb 2023 09:35:02 +0100 [thread overview]
Message-ID: <CAMRc=MfL04EQCAeVvPUxAa1ivgTmVzhK57Ms7q0XbUPSX2DxXA@mail.gmail.com> (raw)
In-Reply-To: <CAMKF1spErrUAaio7Zys_PWfCUmkoWpvg3n1S01AgbKKqTpd3vg@mail.gmail.com>
On Fri, Feb 10, 2023 at 3:18 AM Khem Raj <raj.khem@gmail.com> wrote:
>
> On Thu, Feb 9, 2023 at 1:26 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> >
> > On Thu, Feb 9, 2023 at 10:16 PM Rich Felker <dalias@libc.org> wrote:
> > >
> > > On Thu, Feb 09, 2023 at 09:43:42PM +0100, Bartosz Golaszewski wrote:
> > > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > > >
> > > > Provide a variant of twalk() that allows callers to pass custom user
> > > > data to it without resorting to global variables.
> > > >
> > > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > >
> > > Is there any precedent for this other than glibc, with matching
> > > signature and behavior? Without that, it looks like it's subject to
> > > the potential for conflicting definitions.
> > >
> >
> > Not sure what you mean. GLibc IS the precedent. This function has only
> > been around since glibc 2.30 (well, it's been 3 years) and requires
> > _GNU_SOURCE. It's a relatively new function but without it, twalk() is
> > quite useless.
>
> musl uses posix as its guiding light and sparingly implement other functions
>
I understand the musl philosophy but it already provides tdestroy()
which also happens to be a GNU extension.
These extensions exist for a reason - they are simply useful and
programs do use them out in the wild. twalk() on its own is brain-dead
and only useful to small programs that can afford to have global
variables. If you have a variable that tries to hold no global
context, then the possibility to pass data to the walk callback is
absolutely required. This is a general problem with those hash-map,
binary tree etc. APIs in POSIX - they don't seem to be designed very
well. GNU extensions try to address some of those issues.
> >
> > The background for this patch is: I have a low-level C library that I
> > maintain for which I try to limit external dependencies and I used
> > twalk_r() in the new version only to find out it doesn't build with
> > musl.
>
> maybe you should carry it as a fallback in your library and use it when building
> on libraries which do not provide it as a fall back.
>
That was my first thought but unfortunately struct node is not part of
the ABI and so user programs must not use it. In fact: it's not even
in the public header - callers only see a void pointer.
For me this means, that it's either limiting the availability of
libgpiosim to glibc, implementing my own binary search tree (that
would take up 300+ LOC for no reason and just end up copying existing
code anyway) or pulling in some library that provides it in C (which
would have to be something well maintained like GLib - which is huge)
just to get that single functionality which I'd really like to avoid.
In this context making musl provide twalk_r() upstream sounds like the
best solution and I'm sure my library is not the only user.
Please reconsider providing twalk_r() in musl.
Thanks
Bart
next prev parent reply other threads:[~2023-02-10 8:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 20:43 Bartosz Golaszewski
2023-02-09 21:16 ` Rich Felker
2023-02-09 21:26 ` Bartosz Golaszewski
2023-02-10 2:18 ` Khem Raj
2023-02-10 8:35 ` Bartosz Golaszewski [this message]
2023-02-10 20:07 ` Markus Wichmann
2023-02-10 21:05 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMRc=MfL04EQCAeVvPUxAa1ivgTmVzhK57Ms7q0XbUPSX2DxXA@mail.gmail.com' \
--to=brgl@bgdev.pl \
--cc=bartosz.golaszewski@linaro.org \
--cc=dalias@libc.org \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).