Commit graph

629 commits

Author SHA1 Message Date
Huang Qi
7a44b007c7 libc/machine: introduce memchr/memmove/memset/strlen from newlib for armv8-m
N/A

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Change-Id: Ie63c8f23126d9ca415609b4ab935d0a5dcc6f376
2021-03-08 09:43:55 +08:00
chao.an
c2707b2886 libc: fix compile warning
Makefile: 131: target 'bin/lib_strcpy.o' given more than once in the same rule
Makefile: 131: target 'bin/lib_strlen.o' given more than once in the same rule

Change-Id: I45b7640f7986895e4d406a1494616aba65a92453
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-03-06 13:27:14 +08:00
Huang Qi
ab81410372 libc/machine: introduce memchr/memmove/memset/strlen from newlib for armv7-m
N/A

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Change-Id: If901402e3dc4e6776521ac18fcd2c61e06e6493b
2021-03-05 18:34:49 +08:00
Huang Qi
7bb419dae1 libc/machine: Use strcmp from newlib for better performance
N/A

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Change-Id: Idbdea04f748243fb9baf7b39d0ed997f7e9a8e3c
2021-03-04 16:44:13 +08:00
Huang Qi
9fce262860 libc/machine: Use memcpy from newlib for better performance
N/A

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Change-Id: Icf49b938e582e46c68a03852a3364c62e7f83976
2021-03-04 10:15:11 +08:00
dongjiuzhu1
4438681a51 mm/umm_heap: move memory-related api from libc/stdlib to umm
N/A

Change-Id: I4cf7f2586c8b476336e7d32e518b2c774e6ce746
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-03-03 22:24:49 +08:00
Peter Bee
a2a31c735e net/socket: move si_send/recv into sendmsg/recvmsg
MIRTOS-272

Implement si_send/sendto/recvfrom with si_sendmsg/recvmsg, instead of
the other way round.

Change-Id: I7b858556996e0862df22807a6edf6d7cfe6518fc
Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2021-03-02 17:33:01 +08:00
chao.an
9c946e2af6 make/archive: replace the dependency to preprequisite list
Change-Id: Id63f3cd32906461a54cb016ef8078d4d922845e2
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-03-01 21:10:15 +08:00
ligd
a25ad34d82 Revert "mm/umm_heap: move memory-related api from libc/stdlib to umm"
This reverts commit 187b6c0742.
2021-02-26 10:20:08 +08:00
Jiuzhu Dong
187b6c0742 mm/umm_heap: move memory-related api from libc/stdlib to umm
N/A

Change-Id: Ie10393fc8630016dbca27f3c327431fad3b375fb
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-02-25 16:54:05 +08:00
chao.an
2898b4a71a net/sendmsg: workaround to support multi-iov case
Change-Id: I66e538c2f3a13db2f84eec9a3f364cf21902c5d1
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-02-08 10:51:43 +08:00
Jiuzhu Dong
9674f89d56 libc/valloc: support valloc
MIRTOS-424

Change-Id: Ieb425a77b0a8d758956996d201223a0050ae4920
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-02-07 15:03:36 +08:00
Jiuzhu Dong
f9e7a0fc01 builtin: execute app whose filename is longer than NAME_MAX
MIRTOS-360

Change-Id: I0d8ed47c0391e65467cc8a2f4f499b0fbfa8c122
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-02-04 15:58:27 +08:00
chao.an
78f48fff18 libs/libc/time/localtime: fix race condition
fix race condition on create the instance of lcl/gmt

Change-Id: I214cc5c544d680b7206552e3caee2b17a722a0c3
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-02-02 17:27:56 +08:00
Xiang Xiao
5e77dea5af pthread/barrier: call sem_get_value instead of nxsem_get_value
N/A

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I65eef2c23f0b59627730a45577d158877c987b78
2021-01-29 20:01:19 +08:00
Jiuzhu Dong
d8452d22be unistd/getcwd: enhance getcwd when buf is NULL
N/A

Change-Id: I595e1874349f089691dc5291f31fb376cf0e2e2c
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-01-25 16:01:39 +08:00
Peter Bee
d4080a4058 libc/pthread: return EBUSY when barrier is in use
MIRTOS-114

Add check for semcount==0 before barrier destroy and initialization

Change-Id: Ifa0cdb363714ad15eafa5ef49a025520ce836b1f
Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2021-01-25 15:03:54 +08:00
Peter Bee
7a72a80d2a libc/sysconf: Add MONOTONIC_CLOCK for consistency
MIRTOS-107

Add _SC_MONOTONIC_CLOCK to sysconf when CONFIG_CLOCK_MONOTONIC is set

Change-Id: I0ae57798ebe89247a10ccb517e128866d1f907de
Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2021-01-20 18:06:14 +08:00
Jiuzhu Dong
68855c212f unistd/fpathconf: enhance fpathconf
MIRTOS-293

Change-Id: Id780d7b56b9790206d572d22aa210a8e0222108c
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-01-19 21:48:53 +08:00
Jiuzhu Dong
8775bd3c3b pthread/cond: fix compile break
N/A

Change-Id: Ia22d7c2039cc7b5e93646037d6072248eabcbe36
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-01-19 11:11:43 +08:00
Jiuzhu Dong
3a4e465bc3 pthread/cond: enhance pthread_cond_destroy
MIRTOS-115

follow: https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_cond_destroy.html

Change-Id: If645120cbac72975671768159d03f211c4940cca
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-01-19 10:43:52 +08:00
chao.an
05fdb2cf49 libs/libxx: use built-in __aeabi_atexit() if LIBSUPCXX is enabled
ld error caused by multiple definition:

ld: arm-none-eabi/lib/thumb/v8-m.main+fp/hard/libsupc++.a(atexit_arm.o): in function `__aeabi_atexit':
atexit_arm.cc:(.text.__aeabi_atexit+0x0): multiple definition of `__aeabi_atexit';
nuttx/staging/libxx.a(libxx_eabi_atexit.o):nuttx/libs/libxx/libxx_eabi_atexit.cxx:75: first defined here

Change-Id: If90419093de73b184a21f755c6ea7ba577d6665a
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-01-13 21:03:06 +08:00
丁欣童
c1de1c563e Add placement new and new[] function.
N/A

Change-Id: I9f16f9c0c36f2619218a65d178100d54ced5f71b
Signed-off-by: 丁欣童 <dingxintong@xiaomi.com>
2021-01-13 17:51:58 +08:00
chao.an
999768e6f3 libc/machine/arch: fix build break if enable armv8 ELF
Change-Id: Icc213b5b5986c83b5a38f0ffd2e451ffa29386a2
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-01-12 00:10:33 +08:00
Xiang Xiao
085543a156 Move the declaration of nx_mkfifo/nx_pipe to nuttx/fs/fs.h
the new location is better than nuttx/drivers/drivers.h
since they are part of the file system api.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-01-08 11:16:03 +08:00
chao.an
cf988ebad3 ctype/iscntrl: correct the control character function
all the characters placed before the space on the ASCII table
and the 0x7F character (DEL) are control characters.

Change-Id: Id187b39ce50b80e9ebee85a7242716eb017575d7
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-01-04 17:17:15 +08:00
danguanghua
b71d5f0e84 bs/libc/net: implement socketpair (3)
N/A

Reference here:
https://www.freebsd.org/cgi/man.cgi?apropos=0&sektion=2&query=socketpair&manpath=FreeBSD+7.0-current&format=html

Change-Id: I2d09f5148b2a720d1e7f380503deb8910c951599
Signed-off-by: danguanghua <danguanghua@xiaomi.com>
2021-01-04 10:55:16 +08:00
danguanghua
0c0e24992d libs/libc/net: implement socketpair (2)
N/A

Reference here:
https://www.freebsd.org/cgi/man.cgi?apropos=0&sektion=2&query=socketpair&manpath=FreeBSD+7.0-current&format=html

Change-Id: I784615bcf6d19c0deb4dbe2b81067ec9f59314a1
Signed-off-by: danguanghua <danguanghua@xiaomi.com>
2020-12-31 18:31:40 +08:00
danguanghua
d226e8fb49 libs/libc/net: implement socketpair
N/A

Reference here:
https://www.freebsd.org/cgi/man.cgi?apropos=0&sektion=2&query=socketpair&manpath=FreeBSD+7.0-current&format=html

Change-Id: I959b4d661cd436f5d5050baf9e821db84139d482
Signed-off-by: danguanghua <danguanghua@xiaomi.com>
2020-12-30 18:26:50 +08:00
chao.an
7b82ddd4a8 libc/dumpvbuffer: fix a bug that the iov ptr is not updated
Change-Id: I6060dd296eed14308893554d254715a7a9908655
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-29 16:03:15 +08:00
Xiang Xiao
ca2ec9b137 libc: Add b64_ntop and b64_pton implementation
implemented by many libc(e.g. freebsd, glibc, newlib)

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-12-29 11:22:13 +08:00
Xiang Xiao
8add509608 libc/netdb: Move hostbuffer out of the stack
The length of hostbuffer come from Kconfig, it isn't safe to
allocate this variable on the stack.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I75213688153a1cba738544de2a51fa3247626dd3
2020-12-22 21:44:25 +08:00
chao.an
39e9a0a498 libs/libc/dump: reduce the code size
Change-Id: I95562cbaec7ab4d9274658add1967da8bc97fcdb
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-22 17:38:40 +08:00
chao.an
c9dcce4f30 Revert "libs/libc/dumpbuffer: add support to dump the buffer to file descriptor."
This reverts commit 080b380955.
2020-12-22 16:25:38 +08:00
chao.an
080b380955 libs/libc/dumpbuffer: add support to dump the buffer to file descriptor.
Change-Id: I5742a69a75faf288df36da12ee5138f27a4f1532
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-21 17:18:26 +08:00
chao.an
776a2ca8cc libs/libc: add lib_dumpvbuffer support
e.g: Encapsulation Type: Bluetooth H4: add packet type dump support

From:

lib_dumpvbuffer(NULL, data, len);

[    1.567100] 0000  03 0c 00                                         ...
[    1.890100] 0000  0e 04 01 03 0c 00                                ......
[    1.890100] 0000  03 10 00                                         ...
[    1.892900] 0000  0e 0c 01 03 10 00 ff ff 8f fe db ff 5b 87        ............[.
[    1.892900] 0000  01 10 00                                         ...
[    1.894900] 0000  0e 0c 01 01 10 00 06 bb 22 06 0a 00 bb 22        ........"...."
[    1.894900] 0000  02 10 00                                         ...
[    1.901900] 0000  0e 44 01 02 10 00 ff ff ff 03 fe ff ff ff ff ff  .D..............
[    1.901900] 0010  ff ff f3 0f e8 fe 3f f7 83 ff 1c 00 00 00 61 f7  ......?.......a.
[    1.901900] 0020  ff ff 7f 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
[    1.901900] 0030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
[    1.901900] 0040  00 00 00 00 00 00                                ......

To:

struct iovec bufs[2];

bufs[0].iov_base = &type;
bufs[0].iov_len = 1;
bufs[1].iov_base = data;
bufs[1].iov_len = len;

lib_dumpvbuffer(NULL, bufs, 2);

[    3.711400] 0000  01 03 0c 00                                      ....
[    4.035400] 0000  04 0e 04 01 03 0c 00                             .......
[    4.035400] 0000  01 03 10 00                                      ....
[    4.037400] 0000  04 0e 0c 01 03 10 00 ff ff 8f fe db ff 5b 87     .............[.
[    4.037400] 0000  01 01 10 00                                      ....
[    4.039400] 0000  04 0e 0c 01 01 10 00 06 bb 22 06 0a 00 bb 22     ........."...."
[    4.039400] 0000  01 02 10 00                                      ....
[    4.046400] 0000  04 0e 44 01 02 10 00 ff ff ff 03 fe ff ff ff ff  ..D.............
[    4.046400] 0010  ff ff ff f3 0f e8 fe 3f f7 83 ff 1c 00 00 00 61  .......?.......a
[    4.046400] 0020  f7 ff ff 7f 00 00 00 00 00 00 00 00 00 00 00 00  ................
[    4.046400] 0030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
[    4.046400] 0040  00 00 00 00 00 00 00                             .......

Change-Id: I51716014dedb6a3b9fb10ea84779f1d82487e9b0
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-21 17:17:48 +08:00
chao.an
0248643f80 libs/libc/dumpbuffer: remove the unnecessary printable characters traversal
Change-Id: I0114a7074ccf760d5e22ca643e1ad71e4c445fa0
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-21 16:00:05 +08:00
chao.an
07dc013b60 libs/libc/dumpbuffer: fix nxstyle warning
Change-Id: I0f397ea5b210d2c4325ef87afb880e98072414d6
2020-12-21 15:52:38 +08:00
chao.an
f6c7e13f7f libs/libc/dumpbuffer: add support to recognizable from wireshark
e.g: Encapsulation Type: Bluetooth H4

From:

[    2.196000] 0000: 030c00                                                            ...
[    2.514600] 0000: 0e0401030c00                                                      ......
[    2.514600] 0000: 031000                                                            ...
[    2.517600] 0000: 0e0c01031000ffff8ffedbff5b87                                      ............[.
[    2.517600] 0000: 011000                                                            ...
[    2.520600] 0000: 0e0c0101100006bb22060a00bb22                                      ........"...."
[    2.520600] 0000: 021000                                                            ...
[    2.527600] 0000: 0e4401021000ffffff03feffffffffff fffff30fe8fe3ff783ff1c00000061f7 .D.............. ......?.......a.
[    2.527600] 0020: ffff7f00000000000000000000000000 00000000000000000000000000000000 ................ ................
[    2.527600] 0040: 000000000000                                                      ......

To:

[    1.567100] 0000  03 0c 00                                         ...
[    1.890100] 0000  0e 04 01 03 0c 00                                ......
[    1.890100] 0000  03 10 00                                         ...
[    1.892900] 0000  0e 0c 01 03 10 00 ff ff 8f fe db ff 5b 87        ............[.
[    1.892900] 0000  01 10 00                                         ...
[    1.894900] 0000  0e 0c 01 01 10 00 06 bb 22 06 0a 00 bb 22        ........"...."
[    1.894900] 0000  02 10 00                                         ...
[    1.901900] 0000  0e 44 01 02 10 00 ff ff ff 03 fe ff ff ff ff ff  .D..............
[    1.901900] 0010  ff ff f3 0f e8 fe 3f f7 83 ff 1c 00 00 00 61 f7  ......?.......a.
[    1.901900] 0020  ff ff 7f 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
[    1.901900] 0030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
[    1.901900] 0040  00 00 00 00 00 00                                ......

Change-Id: I788df074679af510e020fe0937123129aa42b190
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-21 15:52:32 +08:00
Xiang Xiao
984defadd0 libc: Implement posix_fallocate
as specified here:
https://pubs.opengroup.org/onlinepubs/007904875/functions/posix_fallocate.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-12-14 18:21:35 +08:00
chao.an
093e8b994f crypto/arc4random: rename getrandom to arc4random_buf
Change-Id: I5c9f0c9acf5af71f01beceaf06ebe0a2c87676bc
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-12 14:38:19 +08:00
chao.an
a44376ad2d Revert "libs/libc: correct the getrandom(2) prototype"
This reverts commit 8411ef1873.

Signed-off-by: chao.an <anchao@xiaomi.com>
Change-Id: I29e90e01f3b8a0460ee53831d38d96edf7d12ef2
2020-12-12 12:13:42 +08:00
chao.an
e0f23b0c02 libs/libc/net: implement etheraton/ether_aton_r
Reference here:
https://www.freebsd.org/cgi/man.cgi?apropos=0&sektion=3&query=ether_aton&manpath=FreeBSD+7.0-current&format=html

Change-Id: I3e70c985836600837dd61810ba290be59b6e8e6f
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-10 01:30:47 +08:00
chao.an
511d65392a libs/libc: correct the getrandom(2) prototype
Reference here:
https://man7.org/linux/man-pages/man2/getrandom.2.html

Change-Id: I25b913c4b6533b3888cb2b9c62bb71505a0815c9
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-07 14:44:25 +08:00
dongjiuzhu
93b3c7a34d unistd/getopt: remove count of arguments
N/A

For commands without "-" arguments, ex:"ls", we should always let
optind = 1 after getopt is called in order to get what follows
correctly.

Signed-off-by: dongjiuzhu <dongjiuzhu1@xiaomi.com>
Change-Id: Iac3cfbadd27fb96e47070c4e3198229306299b6b
2020-12-01 11:20:54 +08:00
dongjiuzhu
4a0f96fd4f pthread_mutexattr_getprotocol: modify prototype
MIRTOS-116

modify the return value according to posix standard
Change-Id: I6e32a8f7a5cac85fe7a395a8115710fdff61d985
Signed-off-by: dongjiuzhu <dongjiuzhu1@xiaomi.com>
2020-12-01 10:44:16 +08:00
Matias N
2860069883 build system: add missing --obj-path to MKDEP 2020-11-30 11:20:15 +08:00
chao.an
90dc86655c style/Makefile: remove unnecessary trailing whitespace
N/A

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-30 11:20:05 +08:00
Xiang Xiao
463457b001 Fix nxstyle warning
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-11-27 11:48:16 +08:00
Xiang Xiao
b1d85d4978 libc/machine/arch: Support armv8-m relocation
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-11-27 11:48:16 +08:00