[Toybox] [PATCH] getconf: add cache size sysconf() queries.

enh enh at google.com
Thu Oct 26 09:24:01 PDT 2023


On Thu, Oct 26, 2023 at 4:05 AM Rob Landley <rob at landley.net> wrote:
>
> On 10/25/23 18:08, enh via Toybox wrote:
> > It can otherwise be quite awkward to get at this --- riscv64 puts it all
> > neatly in the ELF auxv, x86-64 has it all in /proc, arm64 only exposes
> > L1 instruction/data line sizes.
> >
> > Annoyingly, none of musl, the BSDs, or Apple implement these sysconf()
> > queries. But they're useful (and otherwise inaccessible from the command
> > line) for the systems that _do_ support them.
>
> Um, that's kind of impressively ugly. I think this is a case where I actually
> would prefer the #ifdef around the block of CONF() calls, because marshalling
> data to ourselves is sad and marshalling noting to ourselves is silly.

yeah, the argument for the _existing_ ones was "these are common, and
saying 'don't know' is potentially useful for callers". but that
argument's a lot weaker here, where "most" libcs don't support the
queries (though "most" by install base do, which is what makes it a
judgement call).

> The thing about the apple defines is they're scattered around (it doesn't have
> AVPHYS_PAGES but does have PHYS_PAGES right after it, the two THREAD_ROBUST
> entries are punched out of a dozen contiguous thread entries it has the rest of,
> and V7_ENV is all the way down in confstrs...
>
> But this new one is a contiguous all-or-nothing block and if we're going to have
> the #ifdef anyway we could just put it around the block and save we could just
> #ifdef out the block instead and save 16 lines and the duplicate comment.
>
> I moved it.

i've sent a patch to fix the implementation, but the idea's fine by me :-)

> Rob


More information about the Toybox mailing list