This commit introduces a new Kconfig option LIBC_MUTEX_BACKTRACE_SKIP tocontrol the
number of initial addresses skipped when generating mutex backtraces.
Key changes:
1. Add LIBC_MUTEX_BACKTRACE_SKIP Kconfig entry (depends on
LIBC_MUTEX_BACKTRACE > 0), defaulting to 2. This option lets users configure
how many leading addresses are omitted from the mutex backtrace output.
2. Modify the nxmutex_add_backtrace() function to pass the new config value
as the skip parameter to sched_backtrace(), replacing the hardcoded 0.
This enhancement improves the usability of mutex backtraces by allowing removalof uninformative
initial stack frames (e.g., backtrace helper functions ormutex acquisition wrappers), making the
relevant call stack entries more visiblefor debugging lock-related issues.
The default value (2) maintains sensibleout-of-the-box behavior while enabling customization for specific use cases.
Signed-off-by: chao an <anchao.archer@bytedance.com>
Intermediate files of make depend like .ddc and .dds may remain
when make is interrupted. Remove them using make distclean.
Signed-off-by: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com>
Add support for ARMv6-M and ARMv8-M Baseline architectures
(Cortex-M0/M0+/M23) in the mcount profiling function. These cores
only support limited Thumb-1 instruction set and require different
assembly instructions compared to ARMv7-M and higher.
Changes:
- Use MOVS+BICS instead of BIC for bit clearing on M0/M23
- Separate register restore for limited push/pop instructions
- Use BX instead of direct POP to PC on M0/M23
Signed-off-by: yinshengkai <yinshengkai@bytedance.com>
Add lib_bsdmemset.c from newlib (Red Hat BSD license) which provides
an optimized memset using word-aligned writes and loop unrolling for
improved performance on larger buffers.
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
1. remove_item It needs to use the full path to exclude the file, otherwise the exclusion will fail
2. No include path was added, resulting in the header file not being found
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
Fix violations of MISRA C:2012 Rule 10.4 (operand of unsigned and signed)
in cancellation point handling code.
Changed all CANCEL_FLAG_* macro definitions and their usage to use unsigned
literals (1u instead of 1) to ensure consistent unsigned arithmetic when
performing bitwise operations. This eliminates mixed signed/unsigned operand
violations in:
- CANCEL_FLAG_NONCANCELABLE
- CANCEL_FLAG_CANCEL_ASYNC
- CANCEL_FLAG_CANCEL_PENDING
The changes affect cancellation point entry/exit logic, cancellation state
management, and cancellation type handling across both kernel and libc
implementations.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
Mark __stack_chk_guard and __stack_chk_fail as weak symbols to prevent linker
conflicts when multiple definitions of these stack protection symbols exist
across different compilation units.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Update the closing preprocessor comment in tls_getinfo.c to accurately reflect
the simplified conditional compilation check. The comment now correctly represents
the actual guard condition used for the tls_get_info function implementation.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Simplify the compilation condition for tls_get_info() by removing the
CONFIG_TLS_ALIGNED check and adding an undef directive to ensure the function
is available in most cases rather than being limited to kernel or non-aligned TLS builds.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
This patch adds an AUTOSAR-style CRC library used by E2E functionality.
It introduces multiple CRC variants (CRC8, CRC16, CRC32, CRC64) and the
corresponding public headers and implementation files.
Key changes:
- Public headers: `include/nuttx/crc8.h`, `include/nuttx/crc16.h`,
`include/nuttx/crc32.h`, `include/nuttx/crc64.h` with new APIs for
specific polynomial variants and incremental (part) helpers.
- Implementations added under `libs/libc/misc/` for several polynomials:
- `lib_crc16h1021.c` (CRC-16 CCITT-FALSE)
- `lib_crc16h8005.c`
- `lib_crc32h04c11db7.c`
- `lib_crc32hf4acfb13.c`
- `lib_crc64emac.c`
- `lib_crc8h1d.c`
- `lib_crc8h2f.c`
- Build files updated to include the new sources.
This addition provides low-level CRC primitives required by higher-level
protocols and test suites.
Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
- Add c++config.h to improve libstdc++ configuration support
- Update CMakeLists.txt and libsupc++.defs to integrate the new config header
- Remove the obsolete 0001-libsupc-Add-missing-header-files.patch to clean up the codebase
These changes enhance the maintainability and portability of the C++ standard library and simplify the build process.
Remove atomic64-based 64-bit perf counter support for 32-bit systems
where atomic64 operations are unavailable, simplifying userspace perf
implementation to avoid unsupported atomic operations.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Add ARCH_HAVE_PERF_EVENTS_USER_ACCESS capability to allow applications
to directly access hardware perf counters via perf_gettime() from
userspace, enabling performance monitoring and profiling without syscalls.
Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
Change the default pthread mutex robustness from ROBUST to UNSAFE when
CONFIG_PTHREAD_MUTEX_BOTH is enabled. This reflects the practical default
and allows removal of tracking code for non-robust mutexes, improving
performance and reducing memory overhead.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
This lock is currently used in three places,
mainly to protect tls->tl_mhead. Among them,
pthread_mutex_add and pthread_mutex_remove involve
writing to tls->tl_mhead, and there is
certainly no conflict within the same thread.
As for pthread_mutex_inconsistent, it involves reading. Currently,
it can only be called when the TCB task corresponding to
this tls exits, and the TCB corresponding to the
tls can no longer continue to run.
It seems that adding the lock serves no real purpose.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
This change removes redundant and unreachable checks of `status != REG_OK`
that were reported by static code scanning. Two occurrences were fixed in
`libs/libc/regex/regcomp.c`
Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
This patch adds support for building libsupc++ (the C++ runtime
support library from GCC's libstdc++-v3).
libsupc++ provides core C++ runtime support including:
- Exception handling (eh_*.cc)
- RTTI (Run-Time Type Information)
- Memory allocation operators (new/delete)
- Type info support
The implementation includes:
- libsupc++.defs for libsupc++ build integration
- support make and cmake build
- Use gthr.h, gthr-posix.h and unwind-pe.h from libgcc
- LIBSTDCXX_VERSION config option with default 14.2.0
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
Add compilation condition for 'nx_vsyslog' syscall.
Export 'sched_note_printf_ip' syscall when CONFIG_SYSLOG_TO_SCHED_NOTE=y
Put the implementation of sched_note_printf_ip in libc/misc/lib_note.c
Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
Replace DEBUGASSERT checks with proper NULL pointer validation in getpid() and
task_get_info() functions. Return IDLE_PROCESS_ID or -ESRCH on NULL conditions
instead of asserting, improving robustness during early system startup and error conditions.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Move pthread mutex operations from kernel-space syscall
interface to user-space implementations
to reduce syscall overhead. Relocate mutex holder list
tracking from task control block (tcb) to
thread local storage (tls) to improve memory layout and
cache efficiency. Add helper macros for
conditional mutex implementations and update syscall
interface accordingly.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Use mktemp to create unique path for memfd, so other thread can't find file by path.
If don't do this, error will ocurr in this case:
thread 1: thread2:
open() -- refs = 1
open() -- refs = 2
unlink()
unlink()
thread1 and thread2 will map one buffer by using file path but not fd or address of buffer.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
Zero-initialize posix_spawnattr_t in posix_spawnattr_init().
Prevent use of uninitialized fields reported by Coverity.
Preserve existing default flag initialization.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
Change TLS_ALIGNED default configuration to enable when either BUILD_KERNEL
or BUILD_PROTECTED is selected. Protected mode requires stack alignment to
properly handle TLS data structure at stack base.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Add pid field to task_info_s and move getpid() implementation to user
space TLS access. Remove getpid from syscall interface as it now returns
cached PID from thread local storage instead of kernel lookup.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
When _LIBCPP_HAS_NO_CONTENTION_TABLE is defined, libcxx will not
allocate the contention table used for semaphore implementation,
which can save significant RAM on memory-constrained embedded systems.
This optimization is particularly useful for NuttX targets where
every byte of RAM matters.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
nuttx/libs/libm/openlibm/openlibm/src/k_rem_pio2.c:421:24: error: 'fq' may be used uninitialized [-Werror=maybe-uninitialized]
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
Building C object libs/libm/openlibm/CMakeFiles/m.dir/openlibm/src/s_clog.c.obj
In file included from /work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/src/math_private.h:22,
from /work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/src/s_clog.c:61:
/work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/src/s_clog.c:78:33: warning: ‘clogl’ alias between functions of incompatible types ‘_Complex long double(_Complex long double)’ and ‘_Complex double(_Complex double)’ [-Wattribute-alias=]
78 | openlibm_strong_reference(clog, clogl);
| ^~~~~
/work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/src/cdefs-compat.h:24:50: note: in definition of macro ‘openlibm_strong_reference’
24 | OLM_DLLEXPORT extern __typeof (aliassym) aliassym __attribute__ ((__alias__ (#sym)));
| ^~~~~~~~
/work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/src/s_clog.c:64:1: note: aliased declaration here
64 | clog(double complex z)
Building C object libs/libm/openlibm/CMakeFiles/m.dir/openlibm/amd64/fenv.c.obj
In file included from /work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/include/openlibm_fenv.h:8,
from /work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/amd64/fenv.c:35:
/work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/include/openlibm_fenv_amd64.h:99:1: warning: declaration of ‘feclearexcept’ shadows a built-in function [-Wshadow]
99 | feclearexcept(int __excepts)
| ^~~~~~~~~~~~~
/work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/include/openlibm_fenv_amd64.h:117:1: warning: declaration of ‘fegetexceptflag’ shadows a built-in function [-Wshadow]
117 | fegetexceptflag(fexcept_t *__flagp, int __excepts)
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
1.add application link dependencies for all elf
2.add a global custom target to hold proptry in the toolchain file
3.add startup obj target
4.fix cpp lds error with kernel mod link elf lds
usage:
./build.sh qemu-armv7a:knsh --cmake
elf install in ${CMAKE_BINARY_DIR}/bin
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
Signals in NuttX serve two primary purposes:
1. Synchronization and wake-up:
Signals can be used to block threads on specific signal sets and later
wake them up by delivering the corresponding signals to those threads.
2. Asynchronous notification:
Signals can also be used to install callback handlers for specific signals, allowing threads to
asynchronously invoke those handlers when the signals are delivered.
This change introduces the ability to disable all signal functionality to reduce footprint for NuttX.
Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
Signals in NuttX serve two primary purposes:
1. Synchronization and wake-up:
Signals can be used to block threads on specific signal sets and later
wake them up by delivering the corresponding signals to those threads.
2. Asynchronous notification:
Signals can also be used to install callback handlers for specific signals, allowing threads to
asynchronously invoke those handlers when the signals are delivered.
This change introduces the ability to partially disable signal functionality: to disable only signal functions for
Asynchronous notification, keeping functions for Synchronization and wake-up.
This enables finer-grained control over signal usage while preserving existing behavior for supported use cases.
Co-authored-by: Guo Shichao guoshichao@xiaomi.com
Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
Replace global enter_critical_section() with lightweight spinlock in
gethostname() and sethostname() to reduce interrupt latency while protecting
access to the shared hostname string.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Fix arm64_backtrace to access TCB register context directly instead of using
running_regs(), which may not reflect the actual context being backtraced.
Add CONFIG_ARCH_HAVE_DEBUG guard to prevent undefined references in non-debug builds.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Replace synchronous nxsched_smp_call with asynchronous nxsched_smp_call_async
in gdb debugpoint operations to prevent deadlocks when called from IRQ handlers.
Use static smp_call_data_s for async communication between SMP cores safely.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Add three POSIX‑required pthread‑related constants to limits.h:
- _POSIX_THREAD_DESTRUCTOR_ITERATIONS
- _POSIX_THREAD_KEYS_MAX
- _POSIX_THREAD_THREADS_MAX
These constants are needed for full POSIX pthread compatibility and are
required by certain PSE52 test suites and applications.
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
Initialize the rlim_max field in the rlp structure when handling
UL_SETFSIZE command in ulimit(), resolving an uninitialized variable
warning from Coverity static analysis.
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
implement the ulimit() based on getrlimit/setrlimit function.
the ulimit() function is requiredd by vsx testset
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
This commit contains changes:
1) define new C++ locale macros CXX_MINI_LOCALIZATION & CXX_NO_LOCALIZATION
2) define a new C++ macro _LIBCPP_HAS_MINI_LOCALIZATION for CXX_MINI_LOCALIZATION
3) update libxx/libcxx/CMakeLists.txt & Make.defs
Signed-off-by: v-zhangxiaomeng5 <v-zhangxiaomeng5@xiaomi.com>
when we build with greenhills compiler, if the exception_common function
is put into a separate section: ".text.exception_common", then the
address of exception_common function is an even number, for example "0x16a6c",
in this case, it will trigger the UsageFaults:INVSTATE error.
The reason for this error is that in the GHS compiler, a section declared
through the ".section" directive must specify at least the "a" attribute.
Otherwise, this section will not be linked into the final file, and this
is why the address of exception_common function is invalid.
The following is the official explanation in the GHS compiler documentation:
"The reason for this error is that in the GHS compiler, a section
declared through the .section directive must specify at least the "a"
attribute. Otherwise, this section will not be linked into the final
file. The following is the official explanation in the documentation:
"Sections that are intended be part of the final linked output should
have at least the `a` attribute"
and for GHS compiler, the .text section is recommended specify the
attribute of `ax`.
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
If the nameserver already exists, return directly without calling dns_notify_nameserver to prevent cyclic notifications and high CPU usage.
Signed-off-by: daichuan <daichuan@xiaomi.com>
Without this fix, values of x where x * x + 1 are rounded
down could make asin() argument to be out of range.
Signed-off-by: Carlos Sanchez <carlossanchez@geotab.com>