| Message ID | 20260410192110.804896-1-joel@rtems.org |
|---|---|
| Headers |
Return-Path: <newlib-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 80EC34BA2E1B for <patchwork@sourceware.org>; Fri, 10 Apr 2026 19:22:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 80EC34BA2E1B X-Original-To: newlib@sourceware.org Delivered-To: newlib@sourceware.org Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) by sourceware.org (Postfix) with ESMTPS id 465AA4BA2E05 for <newlib@sourceware.org>; Fri, 10 Apr 2026 19:21:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 465AA4BA2E05 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rtems.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 465AA4BA2E05 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.169 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775848901; cv=none; b=Snso5P0odnRtmCjtvjaNiZ82MTdNVYz0/NcQyD9ch5xL0J+dMN+JCDBAzjJk/NUJDrgdt1y/NDL33WzhfvD1+ke2rNivWRTaqGYgQYRfrlwhjKoI5kN+cIo0HcGANmQuse+cgCz6DnAWNiL4ayISuXvPFFDktoTTwhyweQeMTPE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775848901; c=relaxed/simple; bh=3lz0BPT7T4Xeyb8TrHGrd2vv2Bjiv01udEnS9PIaV30=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=G1WUU5XMKv9q36AtxAnOMfd1Xvze4K+Bla4GCXSM6kEj4LcVZZ5zRCYaffep2sEyk7lg1bHgevgMN6jA/dPln/XVQdWZL4a6RQZ9UYonej1hHe1wXjzulBbTivvxeXyPjqV2aym77n+HQMZCgblt/dcy9Uny4F0neoBteCkdp70= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 465AA4BA2E05 Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-7982c3b7da9so22272707b3.1 for <newlib@sourceware.org>; Fri, 10 Apr 2026 12:21:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775848900; x=1776453700; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0ukV2G5+g+EaiwxTAhl9j9/ZcHYaaZRgrD2R/F849kM=; b=Fu+Gd/ySNQ0WMYFrDuT6Nxxk6UjgwhswwpbK1qZKNsWwVN7koMinIG7AD+lCm/IMxC 9LcJ/I32J6X4fyWkRsjbeuhvlq4wWIMCJxd9UVJzECgdU0HsJjr3BPp49r0dac6102GJ fO8K+BTx+nFmpaDZ/l4Gj4f2VuaIbwgzfZu6rRJSBEMeH0ahg08Z7PNSLc8oljWaYiV4 2B77ZPg/B4fFbwumy1FlX6XmXiKwQerkZl9mTJGpJRVrLKJQ7pIkyv+LUX5ylPLDnq6T /50JwCgICCWEnv9h9hmOHNXzGnK/LRXAECj8GMzRZwPaZUqrjXVUXOve9JsLPB4dIUlh V5ng== X-Gm-Message-State: AOJu0Yzt68D5cZQ+SFIjNqlDUMnkx1B+1yiEY4T9MJ5MjysUCoJQLhUl KPlwx4dwb+ZuCGiY6DlRK4Z4YFRglCg8TPwWUcHRYs9X3A4AW8wpAsiZuv2MoQ== X-Gm-Gg: AeBDieuO69Hxof4cnuRLdScpgp5Cvm7YyEg+zitm5shAPwigkveNHWnebYH0Rf1nM0Z 5fOQbhdq/fHe7UWNxbAALQ/oiFO7j8628I5UzIBcgIW9XbVvO6FMinW1YeqfD1FMQMTEAIHEGCL 7yB7aOtZg1wvC8JnvfaiBKKbardudZ+0iNGIuM8SL1GZ/LhFAeZ7GXerZsxObLkx4mG4Lpw2gyl 2E8ZmqFQl9JvL0cJ7IrsPisgiHpYZqCLlnOOWArF6fqgLyOXqOD2CNStZpddcrZe4mZirw54ac/ FrdQwzSFM7SgVxaKwvyAQt0+jdDwcZnPyUR2BVgbFgu+7t1ZvJBI3GNI5ZZ7/iiZAMShr4ZPQoO YFQrYoOvKCrb4cvUDk3efbUrHxrkE1x3iLnOQDAQgzOMIk2pIns/8cepHSs/Gj9QZatySgZ6azd yXBlCMCYPiKdawOjhhPMvCShA8X1RKVr/3y9qBbPwG57XR/MCU7os2ahXhh39H0MTYT3pkTZL6 X-Received: by 2002:a05:690c:e68b:20b0:7ac:248a:986e with SMTP id 00721157ae682-7af71478e53mr32690987b3.28.1775848899760; Fri, 10 Apr 2026 12:21:39 -0700 (PDT) Received: from gitlab.oarcorp.com (d27-96-189-151.evv.wideopenwest.com. [96.27.151.189]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7af3d3c1aa6sm17819087b3.20.2026.04.10.12.21.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2026 12:21:39 -0700 (PDT) From: Joel Sherrill <joel@rtems.org> To: newlib@sourceware.org Cc: Joel Sherrill <joel@rtems.org> Subject: [PATCH v2 0/2] Add C23 stdbit.h functionality Date: Fri, 10 Apr 2026 14:21:08 -0500 Message-ID: <20260410192110.804896-1-joel@rtems.org> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3029.5 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Newlib mailing list <newlib.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/newlib>, <mailto:newlib-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/newlib/> List-Post: <mailto:newlib@sourceware.org> List-Help: <mailto:newlib-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/newlib>, <mailto:newlib-request@sourceware.org?subject=subscribe> Errors-To: newlib-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
Add C23 stdbit.h functionality
|
|
Message
Joel Sherrill
April 10, 2026, 7:21 p.m. UTC
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
Comments
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. 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. 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. 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
On Mon, Apr 13, 2026 at 5:51 AM Corinna Vinschen <corinna@vinschen.de> 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 >
Hi Joel, On Apr 16 15:55, Joel Sherrill wrote: > On Mon, Apr 13, 2026 at 5:51 AM Corinna Vinschen <corinna@vinschen.de> > 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 That wasn't the point. The point was to set this *while building newlib*. The most simple way would have been to add a line #define __STDC_WANT_IEC_60559_BFP_EXT__ to the files in stdbit. Corinna
On 2026-04-16 14:55, Joel Sherrill wrote: > On Mon, Apr 13, 2026 at 5:51 AM Corinna Vinschen wrote: > 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. > > 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? FreeBSD may be assuming using whatever their current compilers are and which will automatically inline trivial leaf functions of this sort, whereas newlib and your build variants can not usually assume much compiler capability nor much memory available on targets.