Skip to content

Commit 495af7a

Browse files
committed
Documentation: add stdbit.h reference
Signed-off-by: Arjav Patel <arjav1528@gmail.com>
1 parent c200f2f commit 495af7a

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

Documentation/components/libs/libc/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ functions. So we have::
5151
sched - sched.h
5252
search - search.h
5353
semaphore - semaphore.h
54+
stdbit - stdbit.h (optional C23)
5455
stdio - stdio.h
5556
stdlib - stdlib.h
5657
string - string.h (and legacy strings.h and non-standard nuttx/b2c.h)
@@ -155,5 +156,6 @@ Implementation Details
155156
:caption: Contents:
156157

157158
search.rst
159+
stdbit.rst
158160
stream.rst
159161
zoneinfo.rst
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
======
2+
stdbit.h
3+
========
4+
5+
The optional C23 ``stdbit.h`` header provides bit manipulation macros
6+
(endianness, leading/trailing zeros and ones, count, single-bit test,
7+
bit width, bit floor, bit ceil). NuttX provides this header only when
8+
explicitly enabled via Kconfig.
9+
10+
Configuration
11+
=============
12+
13+
- **CONFIG_ARCH_HAVE_STDBIT_H** (bool, selected by arch)
14+
Architecture indicates it provides ``arch/<arch>/include/stdbit.h``.
15+
16+
- **CONFIG_ARCH_STDBIT_H** (bool "stdbit.h", depends on ARCH_HAVE_STDBIT_H)
17+
Use the redirecting header. The build copies
18+
``include/nuttx/lib/stdbit.h`` to ``include/stdbit.h``; that header
19+
then includes ``<arch/stdbit.h>`` when this option is set.
20+
21+
- **CONFIG_LIBC_STDBIT_GENERIC** (bool "stdbit.h (generic C23)")
22+
Use the generic C23 implementation. The same redirecting file
23+
``include/nuttx/lib/stdbit.h`` is copied to ``include/stdbit.h``,
24+
and the generic implementation is used (no arch header). Requires
25+
compiler builtins (e.g. ``__builtin_clz``, ``__builtin_ctz``,
26+
``__builtin_popcount``); see ``CONFIG_HAVE_BUILTIN_*`` in
27+
``nuttx/compiler.h``.
28+
29+
Either **CONFIG_ARCH_STDBIT_H** or **CONFIG_LIBC_STDBIT_GENERIC** may be
30+
enabled so that ``#include <stdbit.h>`` is available.

0 commit comments

Comments
 (0)