mirror of
https://github.com/apache/nuttx.git
synced 2026-03-23 22:43:57 +08:00
Some checks failed
Build Documentation / build-html (push) Has been cancelled
- Introduced Kconfig options for stdbit.h, allowing architecture-specific and generic implementations. - Added new documentation for stdbit.h, detailing its usage and configuration. - Updated CMake and Makefile to handle the inclusion of stdbit.h based on configuration settings. This enhances the NuttX library with optional C23 bit manipulation utilities, improving functionality for architectures that support it. Signed-off-by: Arjav Patel <arjav1528@gmail.com>
31 lines
1.2 KiB
ReStructuredText
31 lines
1.2 KiB
ReStructuredText
========
|
|
stdbit.h
|
|
========
|
|
|
|
The optional C23 ``stdbit.h`` header provides bit manipulation macros
|
|
(endianness, leading/trailing zeros and ones, count, single-bit test,
|
|
bit width, bit floor, bit ceil). NuttX provides this header only when
|
|
explicitly enabled via Kconfig.
|
|
|
|
Configuration
|
|
=============
|
|
|
|
- **CONFIG_ARCH_HAVE_STDBIT_H** (bool, selected by arch)
|
|
Architecture indicates it provides ``arch/<arch>/include/stdbit.h``.
|
|
|
|
- **CONFIG_ARCH_STDBIT_H** (bool "stdbit.h", depends on ARCH_HAVE_STDBIT_H)
|
|
Use the redirecting header. The build copies
|
|
``include/nuttx/lib/stdbit.h`` to ``include/stdbit.h``; that header
|
|
then includes ``<arch/stdbit.h>`` when this option is set.
|
|
|
|
- **CONFIG_LIBC_STDBIT_GENERIC** (bool "stdbit.h (generic C23)")
|
|
Use the generic C23 implementation. The same redirecting file
|
|
``include/nuttx/lib/stdbit.h`` is copied to ``include/stdbit.h``,
|
|
and the generic implementation is used (no arch header). Requires
|
|
compiler builtins (e.g. ``__builtin_clz``, ``__builtin_ctz``,
|
|
``__builtin_popcount``); see ``CONFIG_HAVE_BUILTIN_*`` in
|
|
``nuttx/compiler.h``.
|
|
|
|
Either **CONFIG_ARCH_STDBIT_H** or **CONFIG_LIBC_STDBIT_GENERIC** may be
|
|
enabled so that ``#include <stdbit.h>`` is available.
|