Re: [PATCH v2 0/2] Add C23 stdbit.h functionality
Joel Sherrill <[email protected]> Thu, 16 Apr 2026 15:55:33 -0500
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <CAF9ehCVg+06tHYn2a1PDOXzmBXBBKg4XCopCv+AF7xJzniSfZQ@mail.gmail.com> |
On Mon, Apr 13, 2026 at 5:51 AM Corinna Vinschen <[email protected]> wrote: > Hi Joel, > > > is that your original patchset, rather than the fixed one? > > Your stdbit/Makefile.inc is still using the incorrect %D, rather than > %D%. > > The new files in the stdbit subdir don't build on Cygwin, because you're > including limits.h without defining __STDC_WANT_IEC_60559_BFP_EXT__. > This will only work if you set __ISO_C_VISIBLE >= 2023, which is NOT the > default when building newlib. You have to make sure this stuff builds > even if __ISO_C_VISIBLE >= 2023 is NOT defined while building newlib. > I addressed this by adding "stdbit_internal.h" which provides definitions or the _WIDTH symbols used if they aren't already defined. I checked this by building with -std equal to gnu99, gnu11, and the default for the GCC head which is C23. This minimized changes to the FreeBSD code. I don't think we want to define __STDC_WANT_IEC_60559_BFP_EXT__ because I am pretty sure newlib is missing most of these. https://en.cppreference.com/w/c/experimental/fpext1.html > > Next, these functions would be better also defined as macros in > stdbit.h, so the (in all cases trivial) functionality would be inlined > rather than adding the function calling overhead. > The implementation is unmodified from FreeBSD. I don't see the value of deviating from their implementation at this time. If someone wants to do that, OK but we cannot just copy it from glibc. Also if you end up with all macros and inline functions, wouldn't that make it impossible to export them? > > Last but not least, the new functions should be exported by Cygwin. > I. e., winsup/cygwin/cygwin.din needs to add them (in alphabetic order) > and CYGWIN_VERSION_API_MINOR in winsup/cygwin/include/cygwin/version.h > needs to be bumped. If this part of the patch isn't quite correct, it's > not much of a problem, but it would be nice to at least make an effort. > Done. Patch set coming. Fingers crossed. --joel > > > Thanks, > Corinna > > > On Apr 10 14:21, Joel Sherrill wrote: > > In response to comments on the previous version of this patch, > > I submitted my first Cygwin patch to add the missing _WIDTH > > constants to the Cygwin limits.h. That patch is now merged > > which hopefully removes the barrier for merging this. > > > > Note that a limits.h implementation can "include_next" the > > GCC limits.h and it will provide many constants. Cygwin > > had a self-contained version and they had to be added. > > > > Two patches: > > - 0001 - adds the files > > - 0002 - regenerates > > > > --joel > > > > Joel Sherrill (2): > > newlib/libc: Add C23 stdbit.h from FreeBSD > > Makefile.inc, stdbit/Makefile.inc: Add stdbit > > > > newlib/libc/Makefile.inc | 1 + > > newlib/libc/include/stdbit.h | 124 ++++++++++++++++++ > > newlib/libc/stdbit/Makefile.inc | 15 +++ > > newlib/libc/stdbit/stdc_bit_ceil.3 | 81 ++++++++++++ > > newlib/libc/stdbit/stdc_bit_ceil.c | 71 ++++++++++ > > newlib/libc/stdbit/stdc_bit_floor.3 | 83 ++++++++++++ > > newlib/libc/stdbit/stdc_bit_floor.c | 53 ++++++++ > > newlib/libc/stdbit/stdc_bit_width.3 | 104 +++++++++++++++ > > newlib/libc/stdbit/stdc_bit_width.c | 53 ++++++++ > > newlib/libc/stdbit/stdc_count_ones.3 | 85 ++++++++++++ > > newlib/libc/stdbit/stdc_count_ones.c | 38 ++++++ > > newlib/libc/stdbit/stdc_count_zeros.3 | 84 ++++++++++++ > > newlib/libc/stdbit/stdc_count_zeros.c | 38 ++++++ > > newlib/libc/stdbit/stdc_first_leading_one.3 | 93 +++++++++++++ > > newlib/libc/stdbit/stdc_first_leading_one.c | 57 ++++++++ > > newlib/libc/stdbit/stdc_first_leading_zero.3 | 92 +++++++++++++ > > newlib/libc/stdbit/stdc_first_leading_zero.c | 57 ++++++++ > > newlib/libc/stdbit/stdc_first_trailing_one.3 | 110 ++++++++++++++++ > > newlib/libc/stdbit/stdc_first_trailing_one.c | 52 ++++++++ > > newlib/libc/stdbit/stdc_first_trailing_zero.3 | 93 +++++++++++++ > > newlib/libc/stdbit/stdc_first_trailing_zero.c | 53 ++++++++ > > newlib/libc/stdbit/stdc_has_single_bit.3 | 98 ++++++++++++++ > > newlib/libc/stdbit/stdc_has_single_bit.c | 38 ++++++ > > newlib/libc/stdbit/stdc_leading_ones.3 | 86 ++++++++++++ > > newlib/libc/stdbit/stdc_leading_ones.c | 60 +++++++++ > > newlib/libc/stdbit/stdc_leading_zeros.3 | 86 ++++++++++++ > > newlib/libc/stdbit/stdc_leading_zeros.c | 60 +++++++++ > > newlib/libc/stdbit/stdc_trailing_ones.3 | 86 ++++++++++++ > > newlib/libc/stdbit/stdc_trailing_ones.c | 56 ++++++++ > > newlib/libc/stdbit/stdc_trailing_zeros.3 | 87 ++++++++++++ > > newlib/libc/stdbit/stdc_trailing_zeros.c | 56 ++++++++ > > 31 files changed, 2150 insertions(+) > > create mode 100644 newlib/libc/include/stdbit.h > > create mode 100644 newlib/libc/stdbit/Makefile.inc > > create mode 100644 newlib/libc/stdbit/stdc_bit_ceil.3 > > create mode 100644 newlib/libc/stdbit/stdc_bit_ceil.c > > create mode 100644 newlib/libc/stdbit/stdc_bit_floor.3 > > create mode 100644 newlib/libc/stdbit/stdc_bit_floor.c > > create mode 100644 newlib/libc/stdbit/stdc_bit_width.3 > > create mode 100644 newlib/libc/stdbit/stdc_bit_width.c > > create mode 100644 newlib/libc/stdbit/stdc_count_ones.3 > > create mode 100644 newlib/libc/stdbit/stdc_count_ones.c > > create mode 100644 newlib/libc/stdbit/stdc_count_zeros.3 > > create mode 100644 newlib/libc/stdbit/stdc_count_zeros.c > > create mode 100644 newlib/libc/stdbit/stdc_first_leading_one.3 > > create mode 100644 newlib/libc/stdbit/stdc_first_leading_one.c > > create mode 100644 newlib/libc/stdbit/stdc_first_leading_zero.3 > > create mode 100644 newlib/libc/stdbit/stdc_first_leading_zero.c > > create mode 100644 newlib/libc/stdbit/stdc_first_trailing_one.3 > > create mode 100644 newlib/libc/stdbit/stdc_first_trailing_one.c > > create mode 100644 newlib/libc/stdbit/stdc_first_trailing_zero.3 > > create mode 100644 newlib/libc/stdbit/stdc_first_trailing_zero.c > > create mode 100644 newlib/libc/stdbit/stdc_has_single_bit.3 > > create mode 100644 newlib/libc/stdbit/stdc_has_single_bit.c > > create mode 100644 newlib/libc/stdbit/stdc_leading_ones.3 > > create mode 100644 newlib/libc/stdbit/stdc_leading_ones.c > > create mode 100644 newlib/libc/stdbit/stdc_leading_zeros.3 > > create mode 100644 newlib/libc/stdbit/stdc_leading_zeros.c > > create mode 100644 newlib/libc/stdbit/stdc_trailing_ones.3 > > create mode 100644 newlib/libc/stdbit/stdc_trailing_ones.c > > create mode 100644 newlib/libc/stdbit/stdc_trailing_zeros.3 > > create mode 100644 newlib/libc/stdbit/stdc_trailing_zeros.c > > > > -- > > 2.47.3 >