Commit graph

2264 commits

Author SHA1 Message Date
Ville Juven
516d1c069a pthread_conddestroy: Fix return value, if sem_getvalue fails
sem_getvalue returns ERROR and sets errno if it fails, we don't want to
return OK in this case, we want to return the non-negated error number.
2025-01-20 23:55:26 +08:00
Xiang Xiao
92e884bee2 libc: Rename LIBC_STRING_OPTIMIZE to LIBC_NEWLIB_OPTSPEED
and correct the dependence

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-01-20 22:27:19 +08:00
lipengfei28
d3e3993682 arch/riscv: use UP_DSB, UP_DMB, UP_ISB as barrier standard API
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2025-01-20 20:13:07 +08:00
lipengfei28
2d1af01d44 mem barrier: use UP_DMP UP_DSP as barriers standard API
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2025-01-20 20:13:07 +08:00
Neo Xu
afe90db5c4 gdbstub: change send buffer to const char
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2025-01-20 20:07:13 +08:00
Yanfeng Liu
1b369544ca modlib/gnu-elf.ld.in: fix regression with armv7a
As armv7-a addrenv layout is not in line with other archs, we need
align it with others by defining ARCH_DATA_RESERVE_SIZE as same as
MM_PGSIZE for now to keep gnu-elf.ld.in unified.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-17 23:16:26 +08:00
Huang Qi
bac2df6bc8 risc-v: replace fence.i with __ISB for instruction sync
Summary:
- Replace direct use of `fence.i` instruction with `__ISB()` macro for instruction synchronization
- This change improves portability while maintaining the same functionality

Impact:
- No functional changes - both `fence.i` and `__ISB()` ensure instruction
synchronization on RISC-V
- Makes the code more maintainable by using the architecture abstraction
layer

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-17 09:04:45 +08:00
Huang Qi
56415a0275 libc/gnssutils: remove C99 standard flag from Make.defs
Summary:
- Removed explicit -std=c99 flag from Make.defs
- The project-wide C standard is already set at a higher level
- Keeps build configuration consistent across the codebase

Impact:
- No functional changes to the code
- Maintains consistency with project-wide C standard settings

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-17 09:03:18 +08:00
wangjianyu3
7cf82fe422 libs/lib_tempbuffer: set errno when fails
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2025-01-17 08:16:14 +08:00
chao an
dedb57cb2d libc/unistd: move NAME_MAX/LINE_MAX/PATH_MAX define to unistd
These options are unistd-specific and should not be filesystem dependent,
and also not suitable for define in the sched directory.

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-01-15 23:17:51 +08:00
anjiahao
cbb5e8fee2 modlib:gen-elf.ld.in DATA section need add CONFIG_MM_PGSIZE
arch/risc-v/src/common/riscv_addrenv.c:418:

{
...
  database = resvbase + MM_PGALIGNUP(resvsize);
...
}

need use MM_PGALIGNUP(resvsize) inside of ARCH_DATA_RESERVE_SIZE
if not add MM_PGALIGNUP(resvsize), will mismatch address load .data
section

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-01-14 20:13:28 +08:00
wangmingrong1
df7d062713 kasan/kconfig: Add config CONFIG_MM_KASAN_INSTRUMENT
It will be used to distinguish between hardware KASan and software KASan. Hardware KASan does not need to use plug-in

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-14 14:01:48 +08:00
wangmingrong1
2149d89336 macro/align: Use ALIGN_UP and ALIGN_DOWN uniformly
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-12 16:48:35 +08:00
Yanfeng Liu
657247bda8 libc/modlib: preprocess gnu-elf.ld
This generates gnu-elf.ld via preprocessing of gnu-elf.ld.in so
that to reduce board specific app linker scripts in kernel mode
when BINFMT_ELF_EXECUTABLE is enabled.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-11 18:54:36 +08:00
Huang Qi
cfd0cc0d1a Remove duplicate includes across multiple files
This commit cleans up redundant header file includes throughout the codebase.
 The changes include:

 - Removing duplicate #include directives that were present in the same file
 - Consolidating includes that were split across multiple lines unnecessarily
 - Removing unused includes that were no longer needed
 - Fixing some formatting issues with includes

 The changes improve code organization and maintainability by:
 - Reducing unnecessary dependencies
 - Making include dependencies more explicit
 - Following consistent include patterns
 - Removing dead code

 No functional changes are made - this is purely a code cleanup commit.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-09 23:30:23 +08:00
zhangshoukui
aef24f5f3c rename lib_pathbuffer to lib_tempbuffer
Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2025-01-07 21:54:33 +08:00
Gao Feng
f64a48f4e5 cxx: size and un-size functions should be defined in one file
fix error when "-Werror=sized-deallocation" is enabled.

refer to https://timsong-cpp.github.io/cppwp/n4861/new.delete,
displace the default versions defined by the C++ standard library.
2025-01-07 21:45:59 +08:00
wangmingrong1
66e074ed97 gcov: add reboot gcov storage coverage info
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-03 21:15:04 +08:00
p-szafonimateusz
9f93621b90 libs/libc/gdbstub/lib_gdbstub.c: fix warning
libs/libc/gdbstub/lib_gdbstub.c: fix warning

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-01-03 08:52:32 +08:00
p-szafonimateusz
6f9d0c97d2 libs/libc/gdbstub/lib_gdbstub.c: fix format for trap response
fix gdb crash after a few step breakpoints because trap is not correctly reported

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-01-03 08:52:32 +08:00
chao an
dc82a296f7 libc/semaphore: remove unused hander file
Signed-off-by: chao an <anchao@lixiang.com>
2024-12-30 12:02:34 +08:00
chenxiaoyi
aa426d1edb xtensa: change write intset register to syscall instruction
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-12-27 00:25:55 +08:00
zhangshoukui
ebf1ab5392 lib_get_pathbuffer: Modify size to the maximum value of PATH_MAX and CONFIG_LINE_MAX
Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2024-12-26 13:25:19 +08:00
YAMAMOTO Takashi
958e30b3e2 Add some clarification comments on the mutex api 2024-12-25 11:11:41 +08:00
Javier Alonso
4ada30b8f7 Revert "[POSIX][Bug] syslog: Add support for %m modifier"
This reverts commit badb5c5ac6.
2024-12-24 11:02:04 -05:00
wangmingrong1
e3a733ae96 libc/machine: fix config error
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-12-24 21:18:12 +08:00
Javier Alonso
badb5c5ac6 [POSIX][Bug] syslog: Add support for %m modifier
The POSIX standard states that the `syslog()` function generates
the body from the message and arguments the same way as `printf()`,

> except that the additional conversion specification `%m` shall be
> recognized;

*https://pubs.opengroup.org/onlinepubs/009695399/functions/syslog.html*

What most of the implementations do is to leverage the processing to
`vsprintf` internals, to reduce code duplicity. This means the `%m`
modifier is present on almost all `printf` implementations. Take
the following code snippet as an example: https://onlinegdb.com/YdR9pU6KS.

Therefore, for `syslog` to support such a specification, the underlying
library shall be updated to support it too.
2024-12-23 16:54:41 -03:00
guoshichao
ef6723af9e nuttx: add get_current_dir_name implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2024-12-19 20:55:51 +08:00
wangmingrong1
b99ca3f27b gcov: Disable stack checking
When enable CONFIG_STACK_CANARIES, in general, the stack check in the __gcov_fork function is:
" return fork();
18: e59f3020 ldr r3, [pc, #32] @ 40 <__gcov_fork+0x40>
1c: e5932000 ldr r2, [r3]
20: e59d3004 ldr r3, [sp, #4]
24: e0332002 eors r2, r3, r2
28: e3a03000 mov r3, #0
2c: 1a000002 bne 3c <__gcov_fork+0x3c>"
r3 is obtained by taking the value of sp offset. But after opening thumb, the second comparison value in
"8c6: 4a06 ldr r2, [pc, #24] @ (8e0 <__gcov_fork+0x30>)
8c8: 6811 ldr r1, [r2, #0]
8ca: 687a ldr r2, [r7, #4]
8cc: 4051 eors r1, r2"
is obtained through r7. Since r7 stores the stack address at this time, which stores the address of the parent process, the stack out of bounds will occur in the child process

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-12-18 23:05:52 +08:00
wangmingrong1
3d99bae59a gcov: Prevent pile insertion recursion
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-12-18 23:05:52 +08:00
wangmingrong1
ba50378f01 gcov: Fix gcov fork() issue
After code coverage is enabled, fork will be replaced by __gcov_fork

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-12-18 23:05:52 +08:00
chao an
a59f59b9f5 libc/gnu: fix typo adress -> address
fix typo adress -> address

Signed-off-by: chao an <anchao@lixiang.com>
2024-12-17 20:48:07 +08:00
hujun5
8ffc3e3203 fix a typo
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-12-17 16:20:46 +08:00
Alin Jerpelea
382c0302ce libs/libc/stdlib: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-12-17 09:36:46 +08:00
Alin Jerpelea
a4b4da1a16 libs/libc/stdlib: remove BSD-4 clause
remove the advertising clause
3. All advertising materials mentioning features or use of this software must
display the following acknowledgement: This product includes software
developed by the University of California, Berkeley and its contributors.

permitted by Berkley amendment
https://ipira.berkeley.edu/sites/default/files/amendment_of_4-clause_bsd_software_license.pdf

following example from NETBSD and OPENBSD
eb7c1594f1
6580fee329

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-12-17 09:36:46 +08:00
chenrun1
5a5c54c684 lib_pathbuffer.c:Use atomic instead of locks
Summary:
  Use atomic_cmpxchg to ensure that in multithreaded situations, if someone releases the buffer, it can be applied for in time. And use atomic_ulong to save free_bitmap

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-12-17 00:10:52 +08:00
YAMAMOTO Takashi
5db6767f6f libxx: Make LIBCXXABI default for sim/macOS
Fix build errors like:
https://github.com/apache/nuttx/issues/14774
2024-12-16 23:38:46 +08:00
chao an
7c4f7723d7 libc/chdir: replace heap alloc to path buffer to improve performance
realloc path buffer to avoid alloc from realpath()

Signed-off-by: chao an <anchao@lixiang.com>
2024-12-11 20:33:34 +08:00
chao an
abb10a497a libc/chdir: chdir/fchdir should not depend on environment variables
This PR will still allow basic shell operations such as cd/ls/pwd to be used even when the environment is disabled.

Signed-off-by: chao an <anchao@lixiang.com>
2024-12-11 00:34:25 +08:00
zhangyuan29
b74a50775f sem: change sem wait to atomic operation
Add sem_wait fast operations, use atomic to ensure
atomicity of semcount operations, and do not depend
on critical section.

Test with robot:
before modify:
nxmutex_lock cost: 78 ns
nxmutex_unlock cost: 82 ns

after modify:
nxmutex_lock cost: 28 ns
nxmutex_unlock cost: 14 ns

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
2024-12-10 22:00:42 +08:00
wangmingrong1
79d0bfa8cc gcov.c: Add necessary instrumentation functions
(.text.ltp_interfaces_sem_unlink_2_2_main+0xd8): undefined reference to `__gcov_execlk'

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-12-10 19:42:31 +08:00
chao an
2f8d78ef64 libs/libc: rename LIBC_MAX_PATHBUFFER to LIBC_PATHBUFFER_MAX
Unified naming style:

if LIBC_PATHBUFFER
config LIBC_PATHBUFFER_MAX
...
config LIBC_PATHBUFFER_MALLOC
...
endif # LIBC_PATHBUFFER

Signed-off-by: chao an <anchao@lixiang.com>
2024-12-10 16:26:12 +08:00
chao an
face32cd3c libs/libc: add a option to disable path buffer by default
If the current platform does not require a large PATH_MAX size support and toolchain supports alloca(),
we could turn off this option to improve performance.

Signed-off-by: chao an <anchao@lixiang.com>
2024-12-10 16:26:12 +08:00
Xiang Xiao
60fb917eda Remove FAR from 32/64bit arch
since these arch doesn't distinguish between near and far pointers

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-12-05 22:55:39 +08:00
cuiziwei
ae5c7a7fd8 libcxxabi: Soft link the libcxxabi header file to nuttx/include.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-12-05 21:56:23 +08:00
zhangyuan29
dcea1b90e7 arch_atomic: only support atomic_xx and atomic64_xx function
Modify the kernel to use only atomic_xx and atomic64_xx interfaces,
avoiding the use of sizeof or typeof to determine the type of
atomic operations, thereby simplifying the kernel's atomic
interface operations.

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
2024-12-04 14:03:14 +01:00
Tiago Medicci Serrano
5456668ae8 libm/newlib: Add arch-specific source code first to CSRCS
Source code under `newlib/newlib/newlib/libm/machine/$(ARCH)/*.c`
should be added before common source code from `../../common/*.c`.
Take `newlib/newlib/newlib/libm/machine/riscv/s_fma.c` as an
example:

```

double
fma (double x, double y, double z)
{
        double result;
        asm ("fmadd.d %0, %1, %2, %3" : "=f" (result) : "f" (x), "f" (y), "f" (z));
        return result;
}

```

Note that the common `s_fma.c` will be included by the source file
directly. The order of adding the files to CSRCS matters here.

Although the CMake-based build system does not have the same build
problem of including the a source-file with the same in the wrong
order, this commit also changes the order of inclusion for CMake
too to keep it consistent.
2024-12-04 02:10:41 +08:00
wangmingrong1
893e67745b gcc/gcov: Add instrumentation function
Some functions will insert these functions:
void __gcov_execve(void)
{
}
void __gcov_execv(void)
{
}
void __gcov_fork(void)
{
}

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-12-03 23:51:12 +08:00
cuiziwei
7bc4671a76 libcxx/CMakeLists.txt: Remove unnecessary flags.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-12-02 22:44:41 +08:00
liamHowatt
0bdc9d24ab libc/puts: newline was omitted for empty string
`puts("");` did not print a newline. The standard
behavior is to print a newline even if the string
is empty.

Signed-off-by: liamHowatt <liamjmh0@gmail.com>
2024-12-01 17:58:06 +08:00