dongjiuzhu1
14f8a6c2dd
fs: support openat/fchmodat/mkfifoat/fstatat/...at api
...
Refs to:
https://linux.die.net/man/2/openat
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-02-07 03:45:38 +08:00
lilei19
de21025702
fix a bug of strtold
...
if input is -1e308,The output should be -100000000......
but the output is -inf
2023-02-06 20:26:45 +08:00
chao an
02a9e76f73
misc/mutex: fix assertion if nxmutex_reset() before nxmutex_unlock()
...
sim/rpserver
NuttShell (NSH) NuttX-12.0.0
server> cu
_assert: Current Version: NuttX server 12.0.0 3ead669e7a-dirty Feb 2 2023 23:53:48 sim
_assert: Assertion failed : at file: libs/libc/misc/lib_mutex.c:303 task: cu 0x5662fff4
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-04 02:13:15 +08:00
chao an
7625126c91
Remove the remain MIN/MAX like macro
...
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-03 23:22:41 +08:00
yinshengkai
35ae47788b
libc: Keep printf("%pS", p) behavior consistent
...
When ALLSYMS is not turned on, %pS will be treated as %p
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-02-03 09:19:06 +02:00
chao an
4c8d244fae
sched/getpid: replace syscall getpid/tid/ppid() to kernel version
...
NuttX kernel should not use the syscall functions, especially after
enabling CONFIG_SCHED_INSTRUMENTATION_SYSCALL, all system functions
will be traced to backend, which will impact system performance.
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-02 10:33:01 +08:00
chao an
c9981036a5
nuttx/mutex: move mutex implement to libc
...
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-02 10:33:01 +08:00
Gustavo Henrique Nihei
e6b204f438
nuttx: Use MIN/MAX definitions from "sys/param.h"
...
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2023-02-01 23:47:44 +08:00
Huang Qi
4caf24a00c
libc/stdio: Minor comments fix
...
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-02-01 21:47:30 +08:00
yinshengkai
ab2b09e557
Revert "Makefile: fix redundant delimiters when using make V=1"
...
This reverts commit 64d39a8b7b
.
2023-02-01 20:39:52 +08:00
Nathan Hartman
c65a632788
libc/termios: Fix comment in cfmakeraw docstring.
2023-02-01 09:47:55 +08:00
yinshengkai
64d39a8b7b
Makefile: fix redundant delimiters when using make V=1
...
rm-none-eabi-ar rcs libc.a bin//lib_assert.o bin//lib_builtin_getname.o
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-01-31 15:12:36 -03:00
Zhe Weng
8819eeaf15
net: Implement shutdown() interface and tcp shutdown
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-01-31 11:15:01 +08:00
lilei19
1d8af7e105
add holder for mutex
...
Signed-off-by: lilei19 <lilei19@xiaomi.com>
2023-01-31 12:08:05 +09:00
Nathan Hartman
6b89b6f945
Remove executable permissions from source files
...
* arch/arm/src/sama5/sam_flexcom_spi.h,
arch/risc-v/src/mpfs/mpfs_ihc_sbi.c,
drivers/usbdev/adb.c,
libs/libc/math/lib_scalbn.c,
libs/libc/math/lib_scalbnf.c,
net/ipfrag/Make.defs,
net/ipfrag/ipfrag.c,
net/ipfrag/ipfrag.h,
net/ipfrag/ipv4_frag.c,
net/ipfrag/ipv6_frag.c: Remove executable permission.
2023-01-30 20:34:51 -03:00
wangxuedong
ba016eb5eb
libc/stdio: fix rounding errors for fractional values less than 1
...
Signed-off-by: wangxuedong <wangxuedong@xiaomi.com>
2023-01-30 23:39:56 +08:00
chao an
fa63da22ae
libs/netdb: add sanity check to avoid null pointer reference
...
Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-30 23:37:29 +08:00
yinshengkai
2466c07aa3
libc/stream: fix syslogstream_addstring length error
...
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-01-30 14:27:04 +01:00
Xiang Xiao
631a8da1e2
sched: Map SCHED_OTHER to SCHED_FIFO or SCHED_RR
...
this behaviour is explicitly specified here:
https://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_08.html
and map SCHED_NORMAL to SCHED_OTHER like Linux:
https://man7.org/linux/man-pages/man7/sched.7.html
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-30 03:01:03 +02:00
zhanghongyu
4de0e626d0
Revert "netdb: fix access within misaligned address error"
...
This reverts commit 3f94828f6b
.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-29 14:35:01 +08:00
liangchaozhong
d8777fa77d
invalid dns cache entry after ttl expires
...
Log ttl after receive dns query and invalid dns cache entry when ttl expires.
Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2023-01-29 14:32:33 +08:00
anjiahao
fcdc7afcb5
libc:lib_psfa_dddup2,add return check
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-01-28 23:23:47 +02:00
ligd
367fa640c1
asctime_r: add param check to asctime_r()
2023-01-28 23:23:12 +02:00
Xiang Xiao
7d66a16c53
Minor style clean up
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-28 19:53:20 +02:00
anjiahao
287467b81b
netdb: Add return check in rexec_af
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-01-27 15:31:28 -03:00
Xiang Xiao
819fbd22cc
sched: Implement tkill/tgkill
...
https://linux.die.net/man/2/tgkill
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-26 08:11:56 +02:00
Petro Karashchenko
f952b8456c
assert: switch from ASSERT(0/false) to PANIC
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-01-26 10:15:34 +08:00
Xiang Xiao
c05cdd6598
libc: Move on_exit and __cxa_atexit in lib_atexit.c
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-25 14:31:37 +02:00
Xiang Xiao
5333c30d45
libc: abort should always call exit not pthread_exit
...
since pthread_exit just exit the calling thread not the whole process
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-25 14:31:37 +02:00
Xiang Xiao
bcd1ebf260
libc: Implement quick_exit and at_quick_exit
...
Defined by c11:
https://en.cppreference.com/w/c/program/quick_exit
https://en.cppreference.com/w/c/program/at_quick_exit
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-25 14:31:37 +02:00
Xiang Xiao
43e7b13697
assert: Log the assertion expression in case of fail
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-24 15:00:19 -03:00
Xiang Xiao
8bf693b362
libc/pthread: Implement pthread_condattr_[set|get]pshared
...
https://pubs.opengroup.org/onlinepubs/009696799/functions/pthread_condattr_getpshared.html
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-24 13:53:02 -03:00
Xiang Xiao
c11cd7f103
libc/pthread: Implement pthread_attr_[set|get]stackaddr
...
https://pubs.opengroup.org/onlinepubs/009696799/functions/pthread_attr_getstackaddr.html
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-24 13:53:02 -03:00
Xiang Xiao
36b74bab02
libc/pthread: Implement pthread_rwlockattr API
...
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlockattr_getpshared.html
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-24 13:53:02 -03:00
Xiang Xiao
82550887c2
c++: Change the default value of CXX_STANDARD from c++17 to gnu++17
...
since many 3rd party code use some gnu c++ extension
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-19 08:21:48 +01:00
Masayuki Ishikawa
dc454765fb
Revert "add holder for mutex"
...
This reverts commit fc176addeb
.
2023-01-19 06:04:48 +09:00
lilei19
fc176addeb
add holder for mutex
...
Signed-off-by: lilei19 <lilei19@xiaomi.com>
2023-01-18 17:40:58 +08:00
zhangyuan21
acd108a5ed
pthread: fixed pthread_cancel and pthread_exit crash in SMP mode
...
1. When pthread exit, set the default cancellability state to NONCANCELABLE state.
2. Make sure modify tcb->flags is atomic operations.
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-01-18 11:57:40 +08:00
Xiang Xiao
f64da13e9b
libxx: Add CXX_STANDARD to select -std=c++??
...
and default to "c++17"
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-16 15:41:57 +02:00
lilei19
04f15d9dc1
fix the bug of strtold
2023-01-15 19:57:56 +08:00
Xiang Xiao
ee9787a254
libc: Let _SC_PAGESIZE return 4096 when CONFIG_MM_PGSIZE isn't defined
...
since most application doesn't expect the page size equals one
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-15 08:39:19 +02:00
dongjiuzhu1
28027d0bee
libc/versionsort: support versionsort and strverscmp
...
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-01-15 11:24:40 +08:00
lilei19
1f95cfdde8
fix the some else bug of strtold
...
I accidentally changed it when I was optimizing the code
Signed-off-by: lilei19 <lilei19@xiaomi.com>
2023-01-13 15:11:20 +02:00
Xiang Xiao
695f42f8d2
net: Move accept to libc after https://github.com/apache/nuttx/pull/8083
...
since accept can simply forward to kernel accept4 function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-13 11:23:42 +02:00
lilei19
120594079a
add function for strtof
2023-01-12 23:46:23 +08:00
zhanghongyu
4de3387eb2
getaddrinfo: add AI_NUMERICHOST flag handle
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-12 01:40:11 +08:00
Xuxingliang
431e31b6b2
libc/math: add simple implementation for sincos API
...
Signed-off-by: Xuxingliang <xuxingliang@xiaomi.com>
2023-01-12 00:07:44 +08:00
Xiang Xiao
ef65d443ad
sem: Remove PRIOINHERIT_FLAGS_ENABLE and use SEM_PRIO_INHERIT instead
...
and refine the code to prepare the support of new flags
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-11 17:35:28 +02:00
zhangyuan21
e34f79aa28
libc: don't redefined __ARM_ARCH_XXX when __ARM_ARCH defined
...
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-01-10 14:58:35 +02:00
zhangyuan21
fae5aef4fe
libc: add arm64 libc function
...
Porting memory and string optimize functions from newlib and bionic
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-01-10 11:31:26 +08:00
zhangyuan21
f8f29c8147
libc: add risc-v libc function
...
Porting memory and string optimize functions from newlib and bionic
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-01-10 11:31:26 +08:00
zhangyuan21
fc9aeb8c70
libc: add armv7-r libc function
...
Porting memory and string optimize functions from newlib and bionic
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-01-10 11:31:26 +08:00
zhangyuan21
650f17169a
libc: add armv7-a armv7-m armv8-m libc function
...
Porting memory and string optimize functions from newlib and bionic
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-01-10 11:31:26 +08:00
zhanghongyu
e019b0d0b8
libc/net: add inet_network function
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-06 22:20:19 +08:00
yinshengkai
05f8c588fd
libc/syslog: improve streamsyslog, add puts funtions
...
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-01-05 02:00:43 +08:00
Jiuzhu Dong
c623ee20f1
stdlib: generate uniformly distributed pseudo-random numbers
...
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-01-04 20:53:05 +08:00
yinshengkai
275b2e70a4
syslog: fix extra line breaks in syslog when SYSLOG_COLOR_OUTPUT is enabled
...
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-01-02 21:22:46 +08:00
dongjiuzhu1
5826e8eeb1
libc/passwd: add pw_gecos field(userinfo)
...
The pw_gecos field is not specified in POSIX, but is
present on most implementations.
passwd file format:
name:uid:gid:gecos:dir:shell
ex: gdm❌ 127:133:Gnome Display Manager:/var/lib/gdm3:/bin/false
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-12-30 00:21:15 +08:00
dongjiuzhu1
8f05661a53
syslog: A trailing newline is added if none is present.
...
refs:
https://www.manpagez.com/man/3/syslog/
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-12-30 00:20:33 +08:00
YAMAMOTO Takashi
bf7db14feb
Suppress -Wsign-compare warning on a few places
2022-12-26 18:23:41 +08:00
Ville Juven
172b209f2d
sched/assert: Re-implement assert() into user space
...
_assert is a kernel procedure, entered via system call to make the core
dump in privileged mode.
Running exit() from this context is not OK as it runs the registered
exit functions and flushes streams, which must not be done
from privileged mode as it is a security hole.
Thus, implement assert() into user space (again) and remove the exit()
call from the kernel procedure.
2022-12-22 21:07:47 +08:00
Ville Juven
3be81e649f
libc/stdio: Flush streams in userspace when process exits
...
This fixes a long standing issue, where the kernel does flushing of file
streams, although it should not handle such streams at all.
2022-12-22 20:16:11 +08:00
Ville Juven
2ed51d026c
fs/streams: Move the file streams from the group structure into TLS
...
This is preparation for flushing streams from user space, like it should
be done.
- Move tg_streamlist (group, kernel space) ->
ta_streamlist (TLS, user space)
- Access stream list via tg_info in kernel
- Access stream list via TLS in user space
- Remove / rename nxsched_get_streams -> lib_getstreams
- Remove system call for nxsched_get_streams
2022-12-22 20:16:11 +08:00
flyingfish89
035656661e
1
2022-12-22 11:52:00 +08:00
Petro Karashchenko
7f564e0d86
nuttx: add some missing FAR
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-12-21 10:56:45 +08:00
Petro Karashchenko
b107e4f417
nuttx: unify MIN, MAX and ABS macro definition across the code
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-12-21 09:31:28 +08:00
Xiang Xiao
fd0d6a9bf5
compiler.h: Add _ between format|printf|syslog|scanf|strftime and like
...
align with other macro naming style
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-21 01:05:19 +02:00
chao an
01eb4d586b
mm/iob: iob members are initialized after allocate
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-16 09:51:53 +08:00
chao an
0c21bc4e53
netdb/dns: add support of send timeout
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-16 09:51:15 +08:00
Lee Lup Yuen
b895207489
arm64/a64: Add driver for MIPI DSI
...
This PR adds the driver for Allwinner A64's MIPI Display Serial Interface (DSI) and MIPI Display Physical Layer (D-PHY).
This driver will be used by the upcoming Display Driver for PINE64 PinePhone.
- `include/nuttx/crc16.h`: Added 16-bit CRC-CCITT
- `libs/libc/misc/Make.defs`: Added 16-bit CRC-CCITT to Makefile
- `arch/arm64/src/a64/Kconfig`: Added the Kconfig option for "A64 Peripheral Selection > MIPI DSI" (`CONFIG_A64_MIPI_DSI`), which enables the MIPI DSI Driver
- `arch/arm64/src/a64/hardware/a64_memorymap.h`: Added the Base Address for MIPI DSI
- `arch/arm64/src/a64/Make.defs`: Added the MIPI DSI Driver to the Makefile
- `libs/libc/misc/lib_crc16ccitt.c`: Compute 16-bit CRC-CCITT
- `arch/arm64/src/a64/mipi_dsi.c`, `mipi_dsi.h`: Compose MIPI DSI Packets (Long, Short, Short with Parameter)
- `arch/arm64/src/a64/a64_mipi_dsi.c`, `a64_mipi_dsi.h`: MIPI DSI Driver for Allwinner A64
- `arch/arm64/src/a64/a64_mipi_dphy.c`, `a64_mipi_dphy.h`: MIPI D-PHY Driver for Allwinner A64
- `platforms/arm/a64/boards/pinephone/index.rst`: Added MIPI DSI as supported peripheral for PinePhone
Co-Authored-By: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-12-14 22:37:32 +08:00
Xu Xingliang
252c6a1844
libc/netdb: add proto.c
...
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
2022-12-10 02:36:24 +08:00
田昕
2719869ab2
Move _assert to kernel space.
...
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
2022-12-06 18:33:21 +08:00
Xiang Xiao
055f1f33eb
libc/stream: Rename [lib_stream_](put|get) to [lib_stream_](putc|getc)
...
to make the naming style consistent with each other
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-05 14:27:55 +01:00
Xiang Xiao
4be9ec774b
Don't download tarballs if a local git repo found
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-05 10:47:36 +01:00
chao an
d12ddf56df
arm/arm: sync ARM_THUMB support from cortex-a
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-05 01:09:31 +08:00
chao an
4b70e4ff77
arm/cortex-r: sync ARM_THUMB support from cortex-a
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-04 20:12:31 +08:00
jihandong
965566d2e8
libc/stdio: add total_len back
...
"The number of characters written if successful or negative value if an error occurred.
If the resulting string gets truncated due to buf_size limit, function returns the total
number of characters (not including the terminating null-byte) which would have been written,
if the limit was not imposed." --- https://en.cppreference.com/w/c/io/vfprintf
Signed-off-by: jihandong <jihandong@xiaomi.com>
2022-12-04 17:27:49 +08:00
zouboan
eaea38e0f2
libc and mm/Makefile:Fix an error caused by backslash in Windows native build
...
libc and mm/Makefile:Fix an error caused by backslash in Windows native build
2022-12-01 01:47:46 +08:00
flyingfish89
fa59db8cea
Add Hexadecimal parsing for strtof
...
solve:
almost the Hexadecimal string string->float
such as:
code:float num;
const char *s= "0x123p32lala";
char *p;
num=strtof(s,&p);
printf("num is %f\n",num);
printf("str is %s\n",p);
output:num is 1249835483136.000000
str is lala
but if the input number is much big;
like:
code:const char *s2= "0x999999p100";
num=strtof(s2,&p);
printf("num is %f\n",num);
printf("str is %s\n",p);
corrent : num is 12760587998944832242938906880669384704.000000
real: num is 12760587998944800000000000000000000000.000000
it didn't have enough precision
2022-11-30 19:03:07 +08:00
flyingfish89
bb040befee
optimize the code of the printf
2022-11-29 17:27:02 +08:00
ligd
f243e4f268
localtime: fix deadlock when print syslog in romfs
...
thread1:
romfs_seek -> take romfslock -> syslog -> tzset
thread2:
sylsog -> tzset -> tz_load -> romfs_open -> deadlock
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-11-28 18:04:38 +08:00
田昕
9d48d86606
libc/stream:add putc interface for mtd/blk stream.
...
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
2022-11-28 16:37:01 +08:00
ligd
092c78d636
signal: correct signal() return value & errno
...
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-11-28 14:15:21 +08:00
ligd
eef619fc46
signal: correct sigset() return value & errno
...
ref:
https://man7.org/linux/man-pages/man3/sigset.3.html
The dispositions for SIGKILL and SIGSTOP cannot be changed.
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-11-28 14:15:21 +08:00
Xiang Xiao
7c7ab96b53
libc/stdio: Remove putc macro from lib_libvsprintf.c
...
call lib_stream_put directly instead
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-27 22:59:21 +01:00
Xiang Xiao
7568a0df22
libc/stdio: Don't count the output length repeatly in vsprintf_internal
...
let's reuse the counting from lib_outstream_s::nput instead
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-27 22:59:21 +01:00
Xiang Xiao
33e35c6ce3
libc/stdio: Don't set FL_[LONG|SHORT] repeatly in vsprintf_internal
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-27 22:59:21 +01:00
Xiang Xiao
df6666ab5e
libc/stream: Rename lib_stream_[put|get]c to lib_stream_[put|get]
...
keep the macro consistent with the callback name
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-27 22:59:21 +01:00
Xiang Xiao
6d30726a1b
Remove the unnecessary "return;" at the end of function
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-27 22:23:50 +01:00
yinshengkai
377bf97613
stream: replace the stream function pointer with a macro
...
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2022-11-25 21:41:51 +08:00
Xiang Xiao
9bfc91e6f1
libc/stream: Remove \n special handle from syslogstream_putc
...
since \r\n process is already done in up_putc or serial driver level
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-25 09:10:05 +01:00
Xiang Xiao
5fd1379d3f
syslog: Move syslog stream to libc like other stream implementation
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-25 01:46:31 +08:00
flyingfish89
4b87a8b079
lib_libvsprintf: fix the float point print bug
...
such as code: double value = +0x1.000000000000080000000000p-600;
printf("Hello, World!! %.7g:f64\n", value);
expected output : Hello, World!! 2.40992e-181:f64
but real output : Hello, World!! 2.40992e-B1:f64
the reason: we want printf "18", but the flag of character is 'B'
and 'B' is '0'+18,so printf 'B';
2022-11-24 12:02:03 -03:00
田昕
28739b8b8a
libc/stream:Add mtd backend stream.
...
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
2022-11-24 12:07:10 +08:00
Ville Juven
4781379ee2
obstack/obstack_free: Fix incorrect usage of void* for arithmetics
...
Using void* for arithmetics is a GCC extension, and thus should not be
used for portable code.
2022-11-23 23:22:06 +08:00
Tiago Medicci Serrano
d3ffeb40a7
libc/machine/xtensa: make longjmp safe against context switch
...
In order to turn longjmp context-switch safe, it's necessary
to disable interrupts before modifying windowbase and windowstart.
Otherwise, after a context switch, windowstart and windowbase
would be different, leading to a wrongly set windowstart bit due to
longjmp writing it based on the windowbase before the context switch.
This corrupts the registers at the next window overflow reaching
that wrongly set bit.
*Background:*
This PR is related to an issue first observed on ESP-IDF
https://github.com/espressif/esp-idf/issues/5229 and it was, then,
checked on NuttX using a test application.
*The test application:*
To check if the problem affects ESP32, ESP32-S2 and ESP32-S3 on
NuttX, it was created an application based on:
https://en.cppreference.com/w/c/program/longjmp
The application creates 16 tasks (`#define NUMBER_OF_TASKS 16`)
that implements the following daemon:
```
static int setjmp_longjmp_daemon(int argc, char *argv[])
{
for (int i = 0; i < NUMBER_OF_TASKS * 2; i++)
{
jmp_buf env;
volatile int count = 0;
if (setjmp(env) != UINT16_MAX)
{
foo(&env, ++count);
}
}
sem_post(&g_sem);
return EXIT_SUCCESS;
}
```
The main function also initializes a semaphore to avoid application
exiting before tasks return successfully:
```
sem_init(&g_sem, 0, -NUMBER_OF_TASKS);
```
Finally, the round-robin interval was lowered to 1ms to raise the
chances of the longjmp being interrupted by a context switch
(`CONFIG_RR_INTERVAL=1).
This setup was able to reproduce the problem prior to this patch
being applied.
2022-11-22 19:34:44 +01:00
Xiang Xiao
af2aa13873
phtread: Change stacksize type from long to size_t
...
follow the standard prototype:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getstack.html
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-22 08:23:37 +09:00
qinwei1
8021dfece6
sched/task/task_getpid: getpid should return process id not thread id
...
Summary:
implement the right semantics:
1. getpid should return the main thread id
2. gettid should return the current thread id
Refer to:
https://github.com/apache/incubator-nuttx/issues/2499
https://github.com/apache/incubator-nuttx/pull/2518
Signed-off-by: qinwei1 <qinwei1@xiaomi.com>
2022-11-17 17:58:08 +08:00
anjiahao
d07792a343
Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-14 09:34:04 +09:00
zhanghongyu
db4840564d
dns: Reduce the dns_lock granularity
...
When a7 curl calls dns_query via usrsock, it will wait a usrsock
response with the dns lock held. If a7 rptun recv a dns_addnameserver
event from another core at this time, rptun waits the lock held by
curl in callback. Then curl will never get its usrsock response with
rptun blocked, so the deadlock occurs.
This change will break lock when do usrsock request.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-11-11 20:07:05 +08:00
anjiahao
634bdeaa5c
pthread_barrier:don't destory when barrier used
...
this is fix a ltp test case and update
the error code of pthread_barrierdestroy
ltptcase is : apps/testing/ltp/ltp/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrier_destroy/2-1.c
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-11-11 08:56:48 +08:00
ligd
a9c647d418
semaphore: move param check to sem_xx level
...
for the speed improve
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-11-10 22:36:21 +08:00
Xiang Xiao
36abcda0d2
lib/netdb: Rename dns_sem[take|give] with dns_[lock|unlock]
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-09 21:38:10 +01:00
Xiang Xiao
898093a822
libc/stdio: Remove the one line mutex wrapper
...
and call nxmutex api directly
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-09 21:38:10 +01:00
chao an
80a2d058b8
lib/atexit: correct return value of exitfunc lock
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-07 18:14:30 +08:00
yinshengkai
85f727f232
tools: replace INCDIR to Makefile variable
...
In the past, header file paths were generated by the incdir command
Now they are generated by concatenating environment variables
In this way, when executing makefile, no shell command will be executed,
it will improve the speed of executing makfile
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2022-11-03 19:59:55 +08:00
yinshengkai
95d9abcf58
tools: replace DEFINE script to Makefile variable
...
In the past, predefined macros were generated by define.sh scripts
Now they are generated by concatenating environment variables
In this way, when executing makefile, no shell command will be executed,
it will improve the speed of executing makfile
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2022-11-03 19:59:55 +08:00
Xiang Xiao
9e72fe9fab
libc/spawn: Always build lib_psa_[get|set]stacksize.c
...
instead of lib_psa_[get|set]stackaddr.c since the later doesn't exist in kernel mode
regression by:
commit b9b032af72
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
Date: Thu Oct 20 03:10:23 2022 +0800
sched/spawn: Support task_spawnattr_[set|get]stacksize in kernel mode
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-01 21:03:52 +01:00
Xiang Xiao
28947517ca
sched/spawn: Rename task_spawnattr_[get|set]stack[size|addr] to posix_spawnattr_[get|set]stack[size|addr]
...
since they can be not only used in task_spawn but also in posix_spawn
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-01 09:51:18 +09:00
chao an
1550747400
sched/getprioritymax: handle invaild policy as posix style
...
modify the return value according to posix standard
------------
SCHED_GET_PRIORITY_MAX(2)
NAME
sched_get_priority_max, sched_get_priority_min - get static priority range
RETURN VALUE
On success, sched_get_priority_max() and sched_get_priority_min() return the
maximum/minimum priority value for the named scheduling policy.
On error, -1 is returned, and errno is set appropriately.
ERRORS
EINVAL The argument policy does not identify a defined scheduling policy.
Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-01 03:33:58 +08:00
Xiang Xiao
3e3364d1a9
Fix the format string mismatch warning
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-31 11:20:56 +01:00
Xiang Xiao
64e7833cbc
sched/spawn: Support task_spawnattr_[set|get]stackaddr
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-31 12:46:58 +09:00
Xiang Xiao
b9b032af72
sched/spawn: Support task_spawnattr_[set|get]stacksize in kernel mode
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Signed-off-by: chao an <anchao@xiaomi.com>
2022-10-31 12:46:58 +09:00
Xiang Xiao
f8d97aea9e
libnx: Remove the unnecessary invocation of _SEM_SETPROTOCOL
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-29 21:12:40 +02:00
Petro Karashchenko
6908b6823c
libs/libc/time: fix regression in clock_calendar2utc
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-10-28 10:21:05 +08:00
Xiang Xiao
19bded4738
fs: Remove the unused nx_pipe to prefer file_pipe for kernel
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-27 23:14:25 +02:00
Minh Nguyen
153060d34d
Update errno to match asm-generic
...
Modify some comment.
2022-10-28 02:19:26 +08:00
Petro Karashchenko
fdff92fd19
libs/libc/time: mktime normalize struct tm
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-10-27 21:22:08 +08:00
Karel Kočí
61b1791584
libs/libc: add obstack
2022-10-26 09:11:52 +08:00
Xavier Del Campo
8684814e09
strftime: Add support for the %T specifier
2022-10-26 00:54:59 +08:00
Xavier Del Campo
097faac22f
strftime: Add support for the %R specifier
2022-10-26 00:54:59 +08:00
Miguel Herranz
819ebe7356
libc/stdio: Add stdio file locking functions
...
Add flockfile(), ftrylockfile() and funlockfile() functions [1].
[1] POSIX.1-2008 / System Interfaces / flockfile
https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/functions/flockfile.html
Signed-off-by: Miguel Herranz <miguel@midokura.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-22 23:34:45 +08:00
anjiahao
577e550698
libc/semaphore:sem_init change defult protocol
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-10-22 14:50:48 +08:00
YAMAMOTO Takashi
f100a4bb92
Implement fdopendir
2022-10-19 21:20:35 +08:00
Fotis Panagiotopoulos
ec93385dfa
strftime: Added support for the %w format specifier.
2022-10-19 12:43:28 +08:00
Fotis Panagiotopoulos
f9fd53cda1
gmtimer: Fixed range of tm_yday.
2022-10-19 12:39:04 +08:00
dongjiuzhu1
55106685fa
libc/localtime: Update to consistent with mainline
...
https://github.com/eggert/tz
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-10-19 10:27:52 +08:00
dongjiuzhu1
7b2371f0ed
libc/localtime: fix timegm return error when tz with isdst
...
testcase:
set TZ CEST
time_t t = time(NULL);
struct tm *ts = localtime(&t);
t = timegm(ts);
t will return (time_t)-1;
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-10-19 10:27:52 +08:00
Jiuzhu Dong
1b9ed5725b
libc/time: Return failed when lock is already held to avoid deadlock
...
when enable LIBC_LOCALTIME and SYSLOG_TIMESTAMP_LOCALTIME
and zoneinfo/posixrulesi isn't exist
[ EMERG] [ap] backtrace:
[ EMERG] [ap] [20] [<0xc1cc3c4>] arm_switchcontext+0xc/0x10
[ EMERG] [ap] [20] [<0xc1ac67a>] sem_wait+0x5a/0xc0
[ EMERG] [ap] [20] [<0xc1c4588>] tzset.part.0+0x8/0x160
[ EMERG] [ap] [20] [<0xc1c58de>] localtime_r+0xc6/0x114
[ EMERG] [ap] [20] [<0xc1a910a>] clock_gettime+0x16/0xa8
[ EMERG] [ap] [20] [<0xc1b7622>] nx_vsyslog+0x9e/0xc0
[ EMERG] [ap] [20] [<0xc4ba7e0>] romfs_stat+0xa4/0xf4
[ EMERG] [ap] [20] [<0xc4b47bc>] inode_semtake+0x24/0x5c
[ EMERG] [ap] [20] [<0xc1c0102>] bsearch+0x26/0x6c
[ EMERG] [ap] [20] [<0xc1c265a>] vsyslog+0x16/0x24
[ EMERG] [ap] [20] [<0xc1c2676>] syslog+0xe/0x1c
[ EMERG] [ap] [20] [<0xc4bae12>] romfs_open+0xee/0x178 <--- err log
[ EMERG] [ap] [20] [<0xc4b68ae>] file_vopen+0x116/0x144
[ EMERG] [ap] [20] [<0xc4b6ac8>] open+0x20/0x60
[ EMERG] [ap] [20] [<0xc1c3df4>] tzload+0x84/0x810
[ EMERG] [ap] [20] [<0xc1c6ef4>] mm_zalloc+0x10/0x18
[ EMERG] [ap] [20] [<0xc4bb426>] romfs_checkmount+0x22/0x58
[ EMERG] [ap] [20] [<0xc4bad74>] romfs_open+0x50/0x178
[ EMERG] [ap] [20] [<0xc1c392c>] tzparse+0x2c/0x470
[ EMERG] [ap] [20] [<0xc1ac5da>] nxsem_wait_uninterruptible+0x8a/0xd0
[ EMERG] [ap] [20] [<0xc1ac690>] sem_wait+0x70/0xc0
[ EMERG] [ap] [20] [<0xc4b47bc>] inode_semtake+0x24/0x5c
[ EMERG] [ap] [20] [<0xc4b481c>] inode_semgive+0x28/0x58
[ EMERG] [ap] [20] [<0xc4b58b4>] file_close+0x18/0x44
[ EMERG] [ap] [20] [<0xc4b4690>] close+0x80/0xb4
[ EMERG] [ap] [20] [<0xc1c43f4>] tzload+0x684/0x810
[ EMERG] [ap] [20] [<0xc1c4616>] tzset.part.0+0x96/0x160
[ EMERG] [ap] [20] [<0xc1c58de>] localtime_r+0xc6/0x114
[ EMERG] [ap] [20] [<0xc1a910a>] clock_gettime+0x16/0xa8
[ EMERG] [ap] [20] [<0xc1ea692>] cmd_date+0x276/0x37c
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-10-19 10:27:52 +08:00
wangbowen6
8b84d19771
lib_localtime: gmtime_r should get right time in OS init process
...
Enable CONFIG_LIBC_LOCALTIME,CONFIG_RTC and CONFIG_SCHED_TICKLESS
In os clock init process, clock_initialize() --> ... -->
sim_rtc_rdtime() --> gmtime_r() --> gmtsub() --> return NULL
get the error rtctime.
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-10-19 10:27:52 +08:00
Jiuzhu Dong
0bff62e3e8
libc/time: don't take semaphore in idle task
...
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-10-19 10:27:52 +08:00
Fotis Panagiotopoulos
ca9aeeec1f
freopen: Added flush of the read buffers.
2022-10-18 23:29:55 +08:00
Fotis Panagiotopoulos
10d6de46e6
libfread: Fixed error flag when reading a write-only file.
2022-10-18 21:29:14 +08:00
Xiang Xiao
6b31918b42
Remove the unnecessary cast for main_t, NULL and argv
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-18 08:51:45 +02:00
anjiahao
d1d46335df
Replace nxsem API when used as a lock with nxmutex API
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-17 15:59:46 +09:00
Petro Karashchenko
ec4a615f6c
libs/libc/stdio: fix ungetc operation
...
Do not modify errno in case of failure
Return EOF if the value of c equals to EOF
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-10-14 23:29:38 +08:00
chao an
36039c8526
newlib/impure: declare thread specific file only if __NEWLIB__ is defined.
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-10-12 17:22:24 +08:00
chao an
83a3fd9780
newlib/impure: sync with newlib(4.2.0) reent update
...
arm-none-eabi-ld: nuttx/staging/libc.a(lib_impure.o):(.data.impure_data+0x4): undefined reference to `__sf'
arm-none-eabi-ld: nuttx/staging/libc.a(lib_impure.o):(.data.impure_data+0x8): undefined reference to `__sf'
arm-none-eabi-ld: nuttx/staging/libc.a(lib_impure.o):(.data.impure_data+0xc): undefined reference to `__sf'
Toolchain:
Version: GNU Arm Embedded Toolchain to Version 11.3.Rel1(August 8, 2022)
Tar: arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz
Break change:
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b0cb9f85ca3626e0e68fd451c3090d253ceb4300
Signed-off-by: chao an <anchao@xiaomi.com>
2022-10-11 18:38:14 +08:00
Xiang Xiao
8c80b3d908
sched: Guard backtrace related code correctly
...
1.Don't include unwind.h when arch specific backtrace is enable
2.Built arch specific backtrace wrapper only when enable
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-11 00:01:35 +02:00
raiden00pl
00aa822546
libs/libc/netdb/Kconfig: allow to enable LIBC_NETDB directly from menuconfig
2022-10-02 22:29:41 +08:00
Xiang Xiao
e38248ee08
Return -EINVAL for the internal API
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-30 17:54:56 +02:00
Xiang Xiao
bdeaea3742
Remove the unnessary empty line after label
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-30 17:54:56 +02:00
zhangyuan21
838309313e
sched: semaphore wait list optimize
2022-09-28 18:08:37 +08:00
Xiang Xiao
40ef5bc6db
libc: Move queue.h from include to include/nuttx
...
to avoid the conflict with libuv's queue.h
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-26 08:04:58 +02:00
chao an
09c006b9c8
libs: fix visual studio Compiler Error C2124
...
D:\code\incubator-nuttx\libs\libc\stdlib\lib_strtod.c: error C2124: divide or mod by zero
Windows MSVC restrictions, MSVC doesn't allow division through a
zero literal, but allows it through non-const variable set to zero
Reference:
https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2124?view=msvc-170
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-26 04:40:09 +08:00
Xiang Xiao
70290b6e38
arch: Change the linker generated symbols from uint32_t to uint8_t *
...
and remove the duplicated declaration
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-24 21:26:56 +02:00
chao an
a3a4e89efc
libs/libc/arm: use builtin routines instead of aliases of __aeabi_mem*
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-24 00:10:36 +08:00
Xiang Xiao
8565882bb5
libc/stdio: Let STDIO_DISABLE_BUFFERING depends on FILE_STREAM
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-22 17:41:05 +02:00
Xiang Xiao
bdcd232c98
libc/netdb: Let LIBC_GAISTRERROR/NETDB_BUFSIZE/NETDB_MAX_IPADDR depends on LIBC_NETDB
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-22 17:41:05 +02:00
Xiang Xiao
4c44c6f709
arch.h: Make _sinit/_einit as an offical interface
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-22 08:29:24 +08:00