During the build of PSE52 VSX testcases, the pthread_equal() is accessed
in the form of a function pointer. Therefore, we have changed the
implementation of pthread_equal() from a macro to an actual function.
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
Updated freopen function in libc stdio to close the old file descriptor before reopening the file.
Signed-off-by: pengyinjie <pengyinjie@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
Change the 'pos' parameter of fsetpos() from 'fpos_t *' to 'const fpos_t *'
in both the prototype and implementation, aligning with POSIX specification
which requires the position parameter to be const-qualified.
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
This fix forces libcxxabi to parse typeinfo ptr in absolute relocation instead of GOT-REL.
Signed-off-by: v-zhangxiaomeng5 <v-zhangxiaomeng5@xiaomi.com>
Fix typo in CMakeLists.txt: CONFIG_LIB_USRWORK → CONFIG_LIBC_USRWORK.
This ensures work_usrthread.c, work_queue.c, and work_cancel.c are compiled
when the user work queue feature is enabled.
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
Introduce CONFIG_LIBC_DISABLE_HEXSTR_TO_FLOAT to remove support for
parsing hexadecimal floating-point constants (C99 %a) in strtod(),
strtof(), strtold(), and sscanf("%a"). This feature is rarely used in
embedded systems and its removal saves significant flash space. Decimal
float parsing remains unaffected.
Signed-off-by: Peter van der Perk <peter.vanderperk@nxp.com>
for output to avoid log disorder.
If no newline character is found, and the buffer is full, forced output
is required; if the buffer is not full, output is performed according to
the newline character to prevent log disorder.
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This patch extends CLOCKFD support to clock_getres(), allowing
applications to query the resolution of PTP clocks through file
descriptors using the standard POSIX clock API.
Key changes include:
1. Move clock_getres() from libc to kernel:
- Relocated from libs/libc/sched/clock_getres.c to sched/clock/
- Enables direct kernel-level file descriptor handling
- Maintains POSIX compliance while adding CLOCKFD support
2. CLOCKFD support in clock_getres():
- Detects CLOCKFD-encoded clockids using CLOCKFD_TO_FD() check
- Extracts file descriptor from clockid parameter
- Validates file descriptor through fs_getfilep()
- Issues PTP_CLOCK_GETRES ioctl to query clock resolution
3. PTP clock resolution query:
- Retrieves resolution from PTP clock device via ioctl
- Returns nanosecond-precision timing resolution
- Enables applications to determine clock accuracy capabilities
- Falls back to standard clock resolution for non-CLOCKFD clockids
4. Error handling:
- Returns EINVAL for invalid CLOCKFD file descriptors
- Properly manages file reference counting with fs_putfilep()
- Maintains backward compatibility with existing clock types
5. Build system updates:
- Updated libs/libc/sched/CMakeLists.txt and Make.defs
- Updated sched/clock/CMakeLists.txt to include clock_getres.c
- Ensures proper compilation in kernel context
Usage example:
int fd = open("/dev/ptp0", O_RDONLY);
struct timespec res;
clock_getres(CLOCKFD(fd), &res); /* Query PTP clock resolution */
printf("Resolution: %ld.%09ld sec\n", res.tv_sec, res.tv_nsec);
close(fd);
This completes the basic POSIX clock API support for dynamic PTP clocks,
providing applications with comprehensive clock information access.
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This allows the compiler to automatically identify which string functions
can be compiled into libraries, and the compiler's internal implementation
is faster than libc functions.
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Causing kernel build report undefined reference 'g_nx_initstate'
Also protect build, as user elf have no access of kernel objects.
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
(gdb) bt
at /home/mi/ssd/dev-system/nuttx/include/string.h:321
ppcmd=<synthetic pointer>, vtbl=0x80069498) at nsh_parse.c:1909
param=0x800692b8) at nsh_parse.c:2593
cmdline=cmdline@entry=0x80069750 "hello") at nsh_parse.c:3028
argc=argc@entry=1, argv=argv@entry=0x80068870) at nsh_session.c:246
at nsh_consolemain.c:75
at nsh_main.c:74
...
Signed-off-by: yangao1 <yangao1@xiaomi.com>
riscv-none-elf-ld: /home/ligd/platform/dev-system/nuttx/staging/libc.a(arch_libc.o): in function `memcpy':
/home/ligd/platform/dev-system/nuttx/libs/libc/machine/arch_libc.c:131:(.text.memcpy+0x4e): undefined reference to `arch_memcpy'
Signed-off-by: ligd <liguiding1@xiaomi.com>
Currently the code for strtof, strtod and strtold is in the list
of files to compile unconditionally, but when trying to compile
kernel with toolchain without libm support (LIBM_NONE=y) compilation
fails because code refers math.h
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
The original condition incorrectly used &h->chunk instead of
h->chunk in the calculation whether the object is in the chunk. This
could lead to the wrong behavior as the first branch gave incorrect
result and thus sometimes the entire obstack was freed even though
object was not NULL.
The commit also simplifies the logic, we can use pointer arithmetic
here and just do h->chunk + 1 as it gives the same result as
(FAR char *)h->chunk + sizeof(struct _obstack_chunk). This saves
unnecessary cast and sizeof.
The second branch should be less than or equal, not just less than.
This ensures the object is correctly located in the chunk even after
previous obstack_finish was called.
Signed-off-by: Michal Lenc <michallenc@seznam.cz>
Co-authored-by: Karel Kočí <kkoci@elektroline.cz>
newlib/libm/fenv/*.c are the non-functional implementation that should
be overridden by an architecture specific implementation in newlib/libm/machine/ARCH.
Make the architecture check for including shared x86 sys headers for x86 and x86_64.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
Implement filename-based filtering to exclude duplicate files
from source lists, ensuring ARCH-specific files (ARCH_CSRCS)
take precedence over files in common or other dirs
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
Add back these functions since clang will use them.
This reverts "libs/libc/arm: use builtin routines instead of aliases of __aeabi_mem*"
and adds source files to cmake.
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
Replace the pipe() macro definition with a proper function implementation
to improve POSIX compliance and debugging capabilities. The new pipe()
function serves as a wrapper around pipe2() with flags set to 0.
Changes include:
- Convert pipe() from macro to function declaration in unistd.h
- Add lib_pipe.c implementation file with proper function documentation
- Update build system files (CMakeLists.txt and Make.defs) to include
the new source file when CONFIG_PIPES is enabled
- Add pipe() entry to libc.csv for symbol tracking
This change allows for better debugging, proper symbol resolution,
and follows NuttX coding standards for library function implementations.
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
nxsig_ismember() has a return type of int, but the current
implementation returns a boolean value, which is incorrect.
All callers should determine membership by checking whether
the return value is 1 or 0, which is also consistent with the POSIX sigismember() API.
Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
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>
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>
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>
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>
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>
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>
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>
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>
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>