Commit Graph

1393 Commits

Author SHA1 Message Date
zhangyuan21
f132edbf35 libc/sched: Return EINVAL when type incorrect at task_setcanceltype
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_setcancelstate.html

The pthread_setcancelstate() function may fail if:

[EINVAL]
The specified state is not PTHREAD_CANCEL_ENABLE or PTHREAD_CANCEL_DISABLE.
The pthread_setcanceltype() function may fail if:

[EINVAL]
The specified type is not PTHREAD_CANCEL_DEFERRED or PTHREAD_CANCEL_ASYNCHRONOUS.

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-05-12 01:06:23 +08:00
zhangyuan21
962dfaf651 libc/pthread: Return EINVAL when input parameter incorrect at pthread_once
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_once.html

If an implementation detects that the value specified by the once_control
argument to pthread_once() does not refer to a pthread_once_t object
initialized by PTHREAD_ONCE_INIT, it is recommended that the function
should fail and report an [EINVAL] error.

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-05-12 01:06:23 +08:00
simbit18
eedca9d7c6 libs/libc/pthread: Fix nxstyle errors
error: Long line found
2023-05-10 13:04:35 +02:00
chao an
3403b983ec libc/qsort: fix invalid-pointer-pair if enable detect_invalid_pointer_pairs=2
=================================================================
==2920138==ERROR: AddressSanitizer: invalid-pointer-pair: 0x603000000130 0x000000000000
    #0 0x5602d3c6a89d in qsort stdlib/lib_qsort.c:180
    #1 0x5602d3c28928 in romfs_cachenode romfs/fs_romfsutil.c:503
    #2 0x5602d3c2854d in romfs_cachenode romfs/fs_romfsutil.c:486
    #3 0x5602d3c2b056 in romfs_fsconfigure romfs/fs_romfsutil.c:777
    #4 0x5602d3c24856 in romfs_bind romfs/fs_romfs.c:1111
    #5 0x5602d3bf5179 in nx_mount mount/fs_mount.c:427
    #6 0x5602d3bf5796 in mount mount/fs_mount.c:539
    #7 0x5602d3bc1154 in nsh_romfsetc apps/nshlib/nsh_romfsetc.c:110
    #8 0x5602d3b8f38d in nsh_initialize apps/nshlib/nsh_init.c:127
    #9 0x5602d3b8f2b7 in nsh_main apps/system/nsh/nsh_main.c:69
    #10 0x5602d3b7a3a6 in nxtask_startup sched/task_startup.c:70
    #11 0x5602d3b5de89 in nxtask_start task/task_start.c:134

0x603000000130 is located 0 bytes inside of 32-byte region [0x603000000130,0x603000000150)
allocated by thread T0 here:
    #0 0x7fcdac74793c in __interceptor_posix_memalign ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:226
    #1 0x5602d3c9024e in host_memalign sim/posix/sim_hostmemory.c:180
    #2 0x5602d3c907d2 in host_realloc sim/posix/sim_hostmemory.c:222
    #3 0x5602d3b8aaff in mm_realloc sim/sim_heap.c:262
    #4 0x5602d3b87a6a in realloc umm_heap/umm_realloc.c:91
    #5 0x5602d3c280c4 in romfs_cachenode romfs/fs_romfsutil.c:466
    #6 0x5602d3c2854d in romfs_cachenode romfs/fs_romfsutil.c:486
    #7 0x5602d3c2b056 in romfs_fsconfigure romfs/fs_romfsutil.c:777
    #8 0x5602d3c24856 in romfs_bind romfs/fs_romfs.c:1111
    #9 0x5602d3bf5179 in nx_mount mount/fs_mount.c:427
    #10 0x5602d3bf5796 in mount mount/fs_mount.c:539
    #11 0x5602d3bc1154 in nsh_romfsetc apps/nshlib/nsh_romfsetc.c:110
    #12 0x5602d3b8f38d in nsh_initialize apps/nshlib/nsh_init.c:127
    #13 0x5602d3b8f2b7 in nsh_main apps/system/nsh/nsh_main.c:69
    #14 0x5602d3b7a3a6 in nxtask_startup sched/task_startup.c:70
    #15 0x5602d3b5de89 in nxtask_start task/task_start.c:134

Address 0x000000000000 is a wild pointer.
SUMMARY: AddressSanitizer: invalid-pointer-pair stdlib/lib_qsort.c:180 in qsort
==2920138==ABORTING
Aborted (core dumped)

Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-08 13:43:28 +02:00
Xiang Xiao
325f395300 Replace all strncpy with strlcpy
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-05-08 09:57:01 +02:00
Xiang Xiao
6f6fce95a2 Replace all sprintf with snprintf
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-05-08 09:57:01 +02:00
Xiang Xiao
6354a742f1 libc: Add a new argument(size_t fulllen) to lib_getfullpath
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-05-08 09:57:01 +02:00
chao an
d6747dd6ad libc/armv8-m: fix build break if MVE is disabled
machine/arm/armv8-m/gnu/arch_memcpy.S: Assembler messages:
machine/arm/armv8-m/gnu/arch_memcpy.S:105: Error: bad instruction `prologue push_ip=HAVE_PAC_LEAF'
machine/arm/armv8-m/gnu/arch_memcpy.S:121: Error: bad instruction `epilogue push_ip=HAVE_PAC_LEAF'
make[1]: *** [Makefile:143: bin/arch_memcpy.o] Error

Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-05 08:07:08 +02:00
zhangyuan21
73257eeda0 libs/libc: fixed armv7-m strcmp build issue
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-05-04 11:59:41 -04:00
fangxinyong
f1e37a4987 libs/libxx: remove redundant code
Follow the change: https://github.com/apache/nuttx/pull/9151,
that is no need to deal with zero size in C++ allocator.

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-05-03 19:54:19 +08:00
zhangyuan21
884be2bdb9 assert: Distinguish between assert and exception
CURRENT_REGS may change during assert handling, so pass
in the 'regs' parameter at the entry point of _assert.

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-05-03 14:49:32 +08:00
Stuart Ianna
4e2a8d4492 libc: Add setbuffer to stdio.
The setbuffer() function is a wrapper around setvbuf() which
enables full buffering on a buffer allocated by the caller, assuming
buffer is not a null pointer.
2023-05-01 11:24:41 +03:00
yanghuatao
e9dfa0094f libm/libmcs: add math library libmcs support
add math library libmcs support
(1)open menuconfig  (2)close math.h:build setup->Customize Header Files->math.h (3) select libmcs:Library Rountines->Select math library->Math Library fram LibmCS (4)build

Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
2023-04-29 13:47:28 +08:00
chao an
9fa097ab69 newlib: libc: memcpy M-profile PACBTI-enablement
Add function prologue/epilogue to conditionally add BTI landing pads
and/or PAC code generation & authentication instructions depending on
compilation flags.

Signed-off-by: chao an <anchao@xiaomi.com>
2023-04-28 09:51:52 +08:00
chao an
5945f080b9 boars/spawn_proxy: remove all CONFIG_POSIX_SPAWN_PROXY_STACKSIZE
Signed-off-by: chao an <anchao@xiaomi.com>
2023-04-27 17:35:58 +08:00
dongjiuzhu1
68d40d4a98 libc/locale: support iconv_open,iconv,iconv_close
Refs to:https://github.com/bminor/musl

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-04-25 19:12:53 +01:00
Xiang Xiao
28eca64dd5 libc: Cleanup per-thread resource in exit/quick_exit
copy from pthread_exit to avoid the resource leak

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-04-25 16:52:08 +03:00
yanghuatao
6d5f8caf53 libm/openlibm: add math library openlibm support.
add math library openlibm support
(1)open menuconfig  (2)close math.h:build setup->Customize Header Files->math.h (3) select openlibm:Library Rountines->Select math library->Math Library fram openlibm (4)build

Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
2023-04-25 20:37:00 +08:00
hujun5
d189a86a35 system: pthread_barrierwait should be moved to kernel space
The current implementation requires the use of enter_critical_section, so the source code needs to be moved to kernel space

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-04-25 15:34:40 +08:00
hujun5
5a2bc1c015 system: pthread_barrierwait can not be preemption
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-04-25 15:34:40 +08:00
chao an
b8780fe906 arch/arm: relax compiler check for workaround with "GCC 12.2"
1. relax compiler check for workaround with "GCC 12.2"
2. export GCCVER to environment

Signed-off-by: chao an <anchao@xiaomi.com>
2023-04-24 19:00:52 +03:00
chao an
2be18a8b24 makefile: fix libc/mm files can not be compiled incrementally
Use double delim to fix windows native build and give an error:
makefile:132: *** target mode do not include“%”. stop.

In Windows environment DELIM := $(strip \) but \ has two role:
first: \ as directory, and second \ as Escape character, Reference:

https://github.com/apache/nuttx/pull/7572#discussion_r1028219229

Signed-off-by: chao an <anchao@xiaomi.com>
2023-04-24 12:43:10 +03:00
yanghuatao
826dd87f30 libm/newlib: add newlib/libm support
Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
2023-04-24 10:32:53 +08:00
Zhe Weng
d8da8dcc44 libc: Print error code for unknown errors in strerror/gai_strerror
Ref: Linux print unknown errors like "Unknown error nnn"
https://man7.org/linux/man-pages/man3/strerror.3.html#RETURN_VALUE

Note:
These interfaces are called at low freq, so a static buffer may be enough.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-04-22 01:46:39 +08:00
Stuart Ianna
4cae98674d litex: Support for kernel build with vexriscv-smp. 2023-04-22 01:40:32 +08:00
Petro Karashchenko
733807f635 libs/libc/string: make strsignal() configurable similar to strerror()
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-04-22 01:26:42 +08:00
Fotis Panagiotopoulos
098b7bbfb3 Fixes in asprintf usage. 2023-04-19 02:48:39 +08:00
XinStellaris
57df1ddcbb Add armv7m assembly strcpy.
Signed-off-by: XinStellaris <tianxin7@xiaomi.com>
2023-04-10 18:59:52 +03:00
Petro Karashchenko
3513c53a09 libs/libc/pthread: fix function name in comments
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-04-07 12:28:45 -03:00
chao an
4fbf5f7a4b libs/libc: correct config define of arch functions
Signed-off-by: chao an <anchao@xiaomi.com>
2023-04-04 09:37:46 -03:00
chao an
3c58f5db2b syscall/libc: add more syscall/libc symbols into csv file
Signed-off-by: chao an <anchao@xiaomi.com>
2023-03-31 21:56:50 +09:00
Stuart Ianna
01b0305ab5 risc-v: SV32 MMU support for qemu-rv. 2023-03-29 22:15:19 +09:00
Fotis Panagiotopoulos
0b1ba70ac5 asprintf: Fixed possible memory leak if print fails. 2023-03-28 14:46:07 -03:00
Gregory Nutt
717bb04cb7 Increase the number of real time signals. Two is not enough.
Refer to issue #8867 for details and rational.

Convert sigset_t to an array type so that more than 32 signals can be supported.

Why not use a uin64_t?
- Using a uin32_t is more flexible if we decide to increase the number of signals beyound 64.
- 64-bit accesses are not atomic, at least not on 32-bit ARMv7-M and similar
- Keeping the base type as uint32_t does not introduce additional overhead due to padding to achieve 64-bit alignment of uin64_t
- Some architectures still supported by NuttX do not support uin64_t
  types,

Increased the number of signals to 64. This matches Linux. This will support all xsignals defined by Linux and also 32 real time signals (also like Linux).

This is is a work in progress; a draft PR that you are encouraged to comment on.
2023-03-27 16:59:04 +03:00
Petro Karashchenko
4309c6693c libc/modlib: fix indentation issue
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-03-26 09:23:50 -06:00
Xiang Xiao
beb38917d1 signal: Replace NuttX special SIGWORK with SIGPAGING(SIGRTMIN)
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-26 08:31:36 -06:00
chao an
3428d15d04 libc/math: rename libc/math.csv to libm/libm.csv
Signed-off-by: chao an <anchao@xiaomi.com>
2023-03-24 14:58:10 -03:00
Petro Karashchenko
5651715486 signal: remove unused SIGCONDTIMEDOUT
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-03-23 17:17:25 -06:00
Petro Karashchenko
a261439b8b libs/libx: relax compiler check for workaround with "GCC 12.2"
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-03-21 21:59:30 -03:00
chao an
c839fc45af libc/settimeofday: correct prototype of settimeofday()
Signed-off-by: chao an <anchao@xiaomi.com>
2023-03-21 11:16:30 -03:00
Xiang Xiao
b63994b7f7 drivers/serial: Always support c_oflag, c_iflag and c_lflag in termios
CONFIG_SERIAL_TERMIOS only decide whether to support c_cflag field since
many terminal application need the first three fields to work correctly.
For more information please reference:
https://www.mail-archive.com/dev@nuttx.apache.org/msg09321.html

before this change(olimexino-stm32:tiny):
   text    data     bss     dec     hex filename
  34884     328    1768   36980    9074 nuttx
after this change:
   text    data     bss     dec     hex filename
  35052     340    1768   37160    9128 nuttx
delta
   text    data     bss     dec     hex filename
    168      12       0     180      b4 nuttx

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-19 14:54:59 -06:00
zhangyuan21
cf56e4113a arch: remove unnecessary sem_setprotocol code
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-03-17 16:53:19 -03:00
yinshengkai
1cc3fd59ed libc/syslogstream: fix nxstyle error
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-03-13 22:24:53 +02:00
yinshengkai
ca290e85ea libc: stream adds length check
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-03-13 22:24:53 +02:00
Karel Kočí
62661600b2 treewide: add DOWNLOAD variable as unification of curl call
This is a followup to the commit
03b164f59c.
2023-03-08 17:05:05 +08:00
yinshengkai
81a4f21f1b libc/libvsprintf: use puts to replace the putc
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-03-08 16:56:17 +08:00
yinshengkai
b8e622ea5d libc/stream: unify stream behavior
Return the error code when all gets occur when an error is wrong
and return immediately when obtaining any valid data

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-03-04 01:48:22 +08:00
yinshengkai
205ca26556 libc/streams: Implement gets/puts for all streams
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-03-03 00:49:04 +08:00
Huang Qi
dfc70b1ddb libc/stdio: Implement lib_get_stream
Use lib_get_stream() to fetch stdin/stdout/stderr,
since is more easy to works with other language by function call
than export native C structure memory layout.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-03-02 09:56:57 +01:00
Huang Qi
b99a96a7d0 stream: Exchange name of lib_rawsostream.c and lib_rawoutstream.c
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-03-01 10:07:36 -03:00