From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11162 invoked from network); 10 Feb 2023 08:35:29 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 10 Feb 2023 08:35:29 -0000 Received: (qmail 11482 invoked by uid 550); 10 Feb 2023 08:35:26 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 11443 invoked from network); 10 Feb 2023 08:35:25 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Lo/mWj1WBFlFLfsrde0GH9csnWEax7PQ2dxWbuEcnTc=; b=CKKhF3DZC5Kblw3Yg+eKqUSiERs6WQ5couRBllQQ74P/VW/0qPCRwhRgEO18lVLYL0 kRCL3ykNlfgeuLHgANmUsS1h5PZzl6ryYlphCqIOt/n8FWUOWAg8cmRR+131Sbx4oSng ft6aWlPWruMceOLc0YnbhgbUSdg93SHMrU0ju/oS79CklCpAnPjUiTX4ulD5UbVCx968 4u90bPk5Imbp0B7DPhfZjN0xl77E1V1tXIiQutzMcQQ0cI1q857W4XEN7CM8kytJhq4+ 0MoyodaQE63VONPGnpNgGQqxA6KQ7nfn+/oxSqBGNotcZSoOeiirSs0Z5awzVp+pUIgV ffYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Lo/mWj1WBFlFLfsrde0GH9csnWEax7PQ2dxWbuEcnTc=; b=5XZXpMrplYWFV8y5axX8ubFTX8roqdgkSzbl2C1j9DcFECgBdmumaDcN6dMHCnRyhZ GhfQPG/UgkoKTs3BgP4OQ8LXTiAmDOjQIkmJHb+cShHQphiJ9x7VZGuZgNfNmyCte854 XoA5FL1KSDTj9cgdWLVgWrGW/7WMoQe3ahEDPTMVAiXCLha2Q/SqcvW0sdKlSrN8Q58y qK/AY5EaJVorIJC9V4XLiiTylQYmJlUnw6E6WAdjS7bBYKfOr1pK95Eg91lJN673iYlo Tj11cpEyWxTDqu6aiHRYYaloEHbHwQBTHHrjV4YWnT9ENJsty2H2owE2TpO46JwaQwI0 9F8A== X-Gm-Message-State: AO0yUKXZcJP3h1qbK6xxoj6TqTgHWURcmjto2WAH5gjFgs0mDExrJENX QRgKQXxfk/r2cszT+040ZlEuOVkMGYkHd4YPFUKakPECvuSURw== X-Google-Smtp-Source: AK7set+2imLVyodZXnZ7A53lJaseyDZJgkfocXKYmT56R1OzoYcLaZhvB4NMcxZrdav3cNoii/DTE0msmgfYBqLvvDE= X-Received: by 2002:a67:c908:0:b0:408:6a8f:d1c6 with SMTP id w8-20020a67c908000000b004086a8fd1c6mr3143551vsk.73.1676018113132; Fri, 10 Feb 2023 00:35:13 -0800 (PST) MIME-Version: 1.0 References: <20230209204342.643785-1-brgl@bgdev.pl> <20230209211649.GX4163@brightrain.aerifal.cx> In-Reply-To: From: Bartosz Golaszewski Date: Fri, 10 Feb 2023 09:35:02 +0100 Message-ID: To: musl@lists.openwall.com Cc: Rich Felker , Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Subject: Re: [musl] [PATCH] search: provide twalk_r() On Fri, Feb 10, 2023 at 3:18 AM Khem Raj wrote: > > On Thu, Feb 9, 2023 at 1:26 PM Bartosz Golaszewski wrote: > > > > On Thu, Feb 9, 2023 at 10:16 PM Rich Felker wrote: > > > > > > On Thu, Feb 09, 2023 at 09:43:42PM +0100, Bartosz Golaszewski wrote: > > > > From: Bartosz Golaszewski > > > > > > > > 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 > > > > > > 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