Re: Reducing duplication of bit operation code.

2024-12-20 Thread Bruno Haible via Gnulib discussion list
Collin Funk wrote: > I see that MSVC supports both typeof and __typeof__ since Visual Studio > 17.9. The difference is 'typeof' requires compiling with the latest > language standard, but '__typeof__' can be used with any language > version [1]. > > I've applied the two attached patches to detect

Re: Reducing duplication of bit operation code.

2024-12-19 Thread Collin Funk
Hi Bruno, Bruno Haible writes: > Also, I see that MSVC is not well covered by this default in stdbit.in.h: > > #else > /* This platform is so old that it lacks typeof, so _Generic is likely >missing or unreliable. The C23 standard seems to allow yielding B >(which is always unsigned lon

Re: Reducing duplication of bit operation code.

2024-12-17 Thread Paul Eggert
On 2024-12-17 19:17, Collin Funk wrote: They are a part of POSIX and missing on some platforms. Fine, but we don't need a Gnulib module for every POSIX API, even if the API is not obsolete. Particularly an API like ffs, which is present only because stdbit.h didn't exist way back when. And r

Re: Reducing duplication of bit operation code.

2024-12-17 Thread Collin Funk
Hi Paul, Paul Eggert writes: > Why not instead encourage callers of these modules to use the > C23-style modules instead? For example, mark ffs as obsolescent and > suggest stdc_trailing_zeros as its replacement. This should improve > overall maintainability in the long run, while lessening oppo

Re: Reducing duplication of bit operation code.

2024-12-17 Thread Paul Eggert
On 2024-12-17 14:56, Bruno Haible via Gnulib discussion list wrote: Hi Collin, Is there any reason not to use stdbit.h for ffs, ffsl, ffsll, count-leading-zeros, count-one-bits, count-trailing-zeros? Before doing so, how about making sure that stdbit.in.h works at least as well as the old cod

Re: Reducing duplication of bit operation code.

2024-12-17 Thread Bruno Haible via Gnulib discussion list
Hi Collin, > Is there any reason not to use stdbit.h for ffs, ffsl, ffsll, > count-leading-zeros, count-one-bits, count-trailing-zeros? Before doing so, how about making sure that stdbit.in.h works at least as well as the old code w.r.t. inlining (assuming -O1 or higher)? (Recall that these funct

Re: Reducing duplication of bit operation code.

2024-12-17 Thread Paul Eggert
On 2024-12-17 12:44, Collin Funk wrote: Is there any reason not to use stdbit.h for ffs, ffsl, ffsll, count-leading-zeros, count-one-bits, count-trailing-zeros? Why not instead encourage callers of these modules to use the C23-style modules instead? For example, mark ffs as obsolescent and sug

Reducing duplication of bit operation code.

2024-12-17 Thread Collin Funk
Hi, Now that we have stdbit.h I think that it would be nice to reduce the duplication in all the bit operation modules. Is there any reason not to use stdbit.h for ffs, ffsl, ffsll, count-leading-zeros, count-one-bits, count-trailing-zeros? I've attached an unpushed patch for count-one-bits and