Commit Graph

2272 Commits

Author SHA1 Message Date
chao an
8847389886 style/FAR: remove FAR qualifier
N/A, remove FAR qualifier from non-pointer types

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-11-10 10:56:29 +01:00
nuttxs
65e318421d netdb/lib_dnsdelserver.c: support delete the DNS server address
Some checks failed
Build Documentation / build-html (push) Has been cancelled
by index or address

 - dns_del_nameserver()
 - dns_del_nameserver_by_index()

Update the "DNS function" section in 11_network.rst, and create
the netlib API documentation in netlib/index.rst

Signed-off-by: nuttxs <zhaoqing.zhang@sony.com>
2025-11-08 16:17:40 -03:00
wangchengdong
f82f71d180 libs/libc: Fix Kconfig issue for memcpy and memset
Fix an issue on ARMv8-R where NEON is not supported.
    When NEON is disabled, the assembly-optimized implementations
    of memset and memcpy should not be used.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2025-11-07 13:04:20 +01:00
raiden00pl
3e6acfaf17 libs: remove not related comments from cmake files
remove not related comments from libs/libbuiltin/CMakeLists.txt and
libs/libxx/CMakeLists.txt. These are a copy paste from a Makefile
which doesn't make sense for these files.

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-10-11 17:07:51 -04:00
raiden00pl
13ab107d67 libc: remove reference to non-existent readme
remove reference to non-existent readme in libc.

Pointing to the documentation page doesn't make sense in this case,
because it doesn't explain the use of `#undef XXX` for this case anyway.

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-10-11 17:07:51 -04:00
p-szafonimateusz
c54bee0295 libc/pthread/pthread_keydelete.c: reset key value
When key is deleted, its value should also be reset.

This fixes the pthread_getspecific.c test case from
PSE52 Open Group Threads Test Suite.

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-10-01 12:00:43 +08:00
Halysson
9014af9ae7 libc/crc: Add crc8rohcincr for incremental CRC8 ROHC calculation
Add crc8rohcincr() function to support byte-by-byte CRC8 calculation
using the ROHC polynomial (0x07) without XOR inversions. This is
useful for protocols that require incremental CRC accumulation,
such as GSM 07.10 (CMUX), where the CRC must be computed as frames
are parsed from circular buffers.

Changes include:
- New crc8rohcincr() function for single-byte incremental CRC
- Function takes current CRC value and returns updated CRC
- Uses same g_crc8_tab table as other ROHC functions
- No XOR inversions applied for proper accumulation

This allows protocols like CMUX to replace local CRC table
implementations with standard libc CRC functions while maintaining
correct incremental calculation behavior.

Signed-off-by: Halysson <halysson1007@gmail.com>
2025-09-30 17:30:46 -03:00
Jukka Laitinen
c9776bf8a6 libc/fclose: Validate the user provided stream pointer
Check that the provided stream pointer is really opened for the group before
closing & freeing it.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2025-09-09 23:51:35 +08:00
wangchengdong
7d0fb9d34f sched/semaphore: add support to customize semaphore max allowed value
Some checks failed
Build Documentation / build-html (push) Has been cancelled
Curernt implementation default semaphore max allowed value to SEM_VALUE_MAX.
  In some cases, user may want to change this, so provide a function to do this: sem_setmaxvalue

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2025-09-04 09:48:34 +08:00
wangchengdong
8cfb9d7053 libs/libc/semaphore: allow nxsem_init to negative value
Allow user to init semaphore value to negative value, this is needed in some use cases
2025-08-31 18:38:03 +08:00
p-szafonimateusz
9fd1478a99 pthread: add pthread_{get|set}concurrency support
Add support for pthread_{get|set}concurrency support.

NuttX uses 1:1 threading model (every pthread is a kernel-managed thread),
so this function has no real effect on the scheduling behavior.

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-08-22 20:50:13 +08:00
p-szafonimateusz
396f5b40ce unistd: add support for confstr()
add support for POSIX defined confstr()

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-08-22 20:50:13 +08:00
p-szafonimateusz
8108aad1a4 pthread: add pthread_attr_{get|set}guardsize support
This commit adds simple implementation of guardsize for pthreads.
At this moment this option simply increases the size of allocated pthread stack.

At default pthread guard size is set to 0.

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-08-22 20:50:13 +08:00
Tiago Medicci Serrano
d250808c1c esp32s3/elf: Fix ELF loader on ESP32-S3 when using external PSRAM
Prior to this commit, it wasn't possible to load ELF modules from
the external PSRAM. There were two main issues about it: 1) copying
data using the instruction bus was being used instead of the data
bus (this, per si, isn't a problem, but requires special attention
regarding data alignment), and 2) the cache was not being properly
cleaned and flushed to properly access the loaded data using the
instruction bus.

Signed-off-by: Tiago Medicci Serrano <tiago.medicci@espressif.com>
2025-08-20 02:23:03 +08:00
nuttxs
7b3913da60 libs/libc/netdb: Optimize the timeout calculation logic:
1. Adopt an exponential backoff strategy () to dynamically adjust the timeout
   duration, which is suitable for retry scenarios.
2. Optimize the default configuration to set the initial timeout to 5 seconds.
3. Support dynamic modification of the maximum timeout limit to adapt
   to different scenarios.
Reference: RFC 1536 (section on retransmission implementation recommendations)

Signed-off-by: nuttxs <zhaoqing.zhang@sony.com>
2025-08-06 01:58:05 +08:00
Shanmin Zhang
73cf02d63a Revert "libs/libc/stdlib/lib_exit.c: fix multiple definition of __dso_handle in msys2"
This reverts commit 8f96e59aee.

The implementation of __dso_handle is independent of the HOST OS but dependent on the specific compiler.
Therefore, this patch will cause compilation failures for other cross-compilers on the Windows platform, such as arm-none-eabi-gcc and aarch64-none-elf-gcc.
Constraints should be applied to compiler target rather than compiler host.
2025-07-31 22:10:36 +08:00
wangmingrong1
5f5eeda55a compiler-rt/cmake: Fix compilation error
The target is wrong

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-07-18 22:37:36 +08:00
George Poulios
c4541a4d4c libc/idr: Remove nodes from RB trees during destroy
Some checks failed
Build Documentation / build-html (push) Has been cancelled
idr_destroy() would loop over the removed and alloced
RB tree nodes freeing them but not removing them from
the trees. From the perspective of the RB tree those
nodes would remain valid, while in fact, they were free
memory, potentially reallocated for other purposes, or
otherwise overwritten by the allocator with metadata.
This would cause (seemingly random) memory corruption
crashes triggered by the RB tree code trying to access
link fields from the free'd nodes.

Fix that by removing the nodes before freeing them.

Signed-off-by: George Poulios <gpoulios@census-labs.com>
2025-07-12 14:24:32 +08:00
yinshengkai
156ef05205 libc/mcount: compatible with armv6m mcount implementation
mcount.S: Assembler messages:
mcount.S:33: Error: cannot honor width suffix -- `bic r1,lr,#1'
mcount.S:35: Error: cannot honor width suffix -- `bic r0,r0,#1'
mcount.S:37: Error: cannot honor width suffix -- `pop {r0,r1,r2,r3,ip,lr}

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2025-07-10 18:06:03 +08:00
Xiang Xiao
4c7366045c libc/semaphore: Go the fast path even arch doesn't support atomic
since the simulated atomic operation is still fast than the slow path

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-07-08 09:47:44 -03:00
Xiang Xiao
fb14b54b83 libc/semaphore: Use the while loop to handle the inerrupt correctly
If atomic_try_cmpxchg_xxxx runs on LL/SC architectures (e.g.ARMv7,
ARMv8, RISC-V), the weak CAS expands to a single LDREX/STREX pair.

If the CPU takes an IRQ/FIQ/SVC between the two instructions,
hardware performs an implicit CLREX and the following STREX returns
1, therefore atomic_try_cmpxchg_xxxx return failure even though
*addr* still holds the expected value.

So let's retry atomic_try_cmpxchg_xxxx in this case.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-07-08 09:47:44 -03:00
wangmingrong1
10a13b98ee compiler-rt: distclean delete error
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-07-03 00:17:58 +08:00
chenxiaoyi
46504837ca clang/gcov: fix the open flags and mode
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2025-07-03 00:17:58 +08:00
wangmingrong1
a87170681d libbuitin: Fixed the issue of not creating bin directory when the file exists
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-07-03 00:17:58 +08:00
buxiasen
8c93783fee gcov: fix link undefined error
undefined reference to `__gcov_execle'

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2025-07-03 00:17:58 +08:00
wangmingrong1
82a4b21863 gcov: Output mode judgment is implemented in the kernel layer
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-07-03 00:17:58 +08:00
wangmingrong1
062ac70470 CMake: Fix compile error
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-07-03 00:17:58 +08:00
wangmingrong1
3648e5db3f gcov: Refactoring the implementation framework of gcov
All implementations of gcov are sunk to the kernel implementation
1. Support three dump modes: serial port output, single file output, standard output

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-07-03 00:17:58 +08:00
wangmingrong1
1cb5077bc1 gcov: default strip 0 path
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-07-03 00:17:58 +08:00
wangmingrong1
f2bc226d26 gcov: use lib_get_tempbuffer instead of using stack
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-07-03 00:17:58 +08:00
wangmingrong1
7bbb96205b CMake: Fix link error
Bringing the code coverage option when linking may cause gcc or g++ to automatically link the libgcov.a that comes with the toolchain.

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-07-03 00:17:58 +08:00
wangmingrong1
a5cb084c1f CMake: fix add compile options
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-07-03 00:17:58 +08:00
wangmingrong1
c6da553788 kasan: kasan_reset_tag rename kasan_clear_tag
The clear tag is more explicit than the reset tag.

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-06-30 18:19:38 +08:00
Xiang Xiao
2b360c826c arch/arm: Move lib_dummy.c from arch/arm/src/common/ghs to libs/libc/machine/arm
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-06-30 09:56:27 +08:00
Xiang Xiao
5758364f10 libc/machine/arm: Move all source files out of gnu folder
and unify the file prefix to arch_xxx.c

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-06-30 09:56:27 +08:00
yangao1
0b6188bfa2 armv8-m: Optimize cfi instructions to debug
Signed-off-by: yangao1 <yangao1@xiaomi.com>
2025-06-30 09:56:27 +08:00
Xiang Xiao
c1a37ec1fb libc/machine/arm64: Move all source files out of gnu folder
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-06-30 09:56:27 +08:00
Xiang Xiao
378f8a5c0f libc/machine/renesas: Move all source files out of gnu folder
and remove the empty CMakeLists.txt in the subdirectories.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-06-30 09:56:27 +08:00
Xiang Xiao
ae071920b4 libc/machine/riscv: Move all source files out of gnu folder
and remove the empty CMakeLists.txt in the subdirectories.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-06-30 09:56:27 +08:00
Xiang Xiao
1177ac8ee4 libc/machine/x86_64: Move all source files out of gnu folder
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-06-30 09:56:27 +08:00
nuttxs
26e02700dd netdb/lib_dnsquery.c: In the IPv6 or IPv4 dns_query_callback() block,
if dns_recv_response() fails, dns_bind() is called again at try_stream to
create a new socket. However, the original socket descriptor sd isn't closed

Signed-off-by: nuttxs <zhaoqing.zhang@sony.com>
2025-06-23 11:56:15 -03:00
Xiang Xiao
bc4041db60 libc: Move stdio/README to Documentation/components/libs/libc/stream.rst
Some checks failed
Build Documentation / build-html (push) Has been cancelled
follow up this change:
commit 84dc88730c
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
Date:   Mon Jun 9 14:39:03 2025 +0800

    libc: Move stream printf/scanf from libc/stdio to libc/stream

    to keep all related code in one place

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-06-22 17:07:41 -03:00
Xiang Xiao
d266bfaca1 libc: lib_bsprintf reuse var instead value for string
to simplify the code logic

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-06-20 09:48:39 +08:00
Xiang Xiao
4b8a738141 libc/stream: Add support for lib_scanf
This commit adds support for the `lib_scanf` function, which
is a stream-oriented version of the `scanf` function.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-06-20 09:48:39 +08:00
Xiang Xiao
025af9d281 libc: Merge lib_vsprintf from lib_libsprintf.c into lib_libvsprintf.c
since all other printf variants in lib_libvsprintf.c

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-06-18 09:24:38 +08:00
Xiang Xiao
84dc88730c libc: Move stream printf/scanf from libc/stdio to libc/stream
to keep all related code in one place

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-06-18 09:24:38 +08:00
Xiang Xiao
99bd3d0f73 libc/stream: Fix the typo error
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-06-17 20:58:13 +08:00
yangao1
c560db04a6 stream/fileoutstream: Add open interface for coredump
Signed-off-by: yangao1 <yangao1@xiaomi.com>
2025-06-17 20:58:13 +08:00
yangao1
47dd21c3c1 stream: Add fileinstream support
This commit introduces a new fileinstream implementation
in the NuttX stream library.

Signed-off-by: yangao1 <yangao1@xiaomi.com>
2025-06-17 20:58:13 +08:00
buxiasen
0b9bd22e19 mtdoutstream: fix missing Make & cmake file
to fix the build break

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2025-06-17 20:58:13 +08:00