Commit Graph

621 Commits

Author SHA1 Message Date
Xiang Xiao
a4c6b179bb mqueue: Add _MQ_OPEN, _MQ_CLOSE and _MQ_UNLINK macro
and replace mq_open, mq_close and mq_unlink with these in libnx

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-02-19 09:59:39 +00:00
hotislandn
d9a1b67120 libs:machine:rv64:add missing logic for elf relocation type: R_RISCV_LO12_S.
Signed-off-by: hotislandn <hotislandn@hotmail.com>
2021-02-15 06:57:30 -08:00
hotislandn
256b83ef8a arch:risc-v:bl602:add support for elf file apps.
Signed-off-by: hotislandn <hotislandn@hotmail.com>
2021-02-13 10:29:12 -08:00
hotislandn
07792a696b RV64: handle relocation type R_RISCV_CALL_PLT in PIC build.
Signed-off-by: hotislandn <hotislandn@hotmail.com>
2021-02-03 02:27:03 -08:00
hotislandn
de8e3a130c RV64: add R_RISCV_HI20 and R_RISCV_LO12_I to elf relocateadd for absolute address loading.
Signed-off-by: hotislandn <hotislandn@hotmail.com>
2021-02-01 21:35:48 -08:00
Pavel Pisa
17c3118b85 libs/libc: libc.csv fill in calloc, gethostbyname and signal.
Signed-off-by: Pavel Pisa <ppisa@pikron.com>
2021-01-29 10:40:03 -08:00
Pavel Pisa
0a5e7bd3ef libs/libc: libc.csv "mkfifo" and "pipe" has to be conditionalized same as in the sources.
The CONFIG_PIPES, CONFIG_DEV_FIFO_SIZE and CONFIG_DEV_PIPE_SIZE setting
has to be considered.

Signed-off-by: Pavel Pisa <ppisa@pikron.com>
2021-01-29 10:40:03 -08:00
Xiang Xiao
8e6cdd0375 pthread: Return get_errno instead the hardcode value
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I1830a473da179d3a1280d3482b0f000ce72de107
2021-01-28 11:31:40 -03:00
YAMAMOTO Takashi
6b48f8b397 netdb: A few build fixes 2021-01-27 11:04:58 +00:00
Jiuzhu Dong
bdd2c96f08 unistd/fpathconf: enhance fpathconf
Change-Id: Id780d7b56b9790206d572d22aa210a8e0222108c
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-01-26 03:25:47 -08:00
Jiuzhu Dong
28167c14a3 pthread/cond: enhance pthread_cond_destroy
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-25 09:55:25 -03:00
chao.an
bd3a843ffe libc/machine/arch: fix build break if enable armv8 ELF
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-01-16 11:17:02 -08:00
chao.an
37b5b7137f 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

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-01-16 11:15:01 -08:00
Masayuki Ishikawa
6626420e46 libs: libxx: Fix compile errors with CONFIG_DEBUG_ERROR=y
Summary:
- This commit fixes compile errors in libxx_new.cxx and libxx_newa.cxx

Impact:
- None

Testing:
- Build with spresense:nsh with CONFIG_DEBUG_ERROR=y

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-01-14 20:14:40 -06:00
dingxintong
c618d0447b Add placement new and new[] function.
Signed-off-by: dingxintong <dingddding@163.com>
2021-01-14 08:35:32 -06:00
Xiang Xiao
4d4cba41f6 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:03:19 +08:00
chao.an
c8784faf3c 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.

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-01-05 01:34:36 -06:00
danguanghua
7d33f73e27 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>
2021-01-03 20:56:27 -06:00
chao.an
d7b004e179 libc/dumpvbuffer: update the vector ptr correctly
fix a bug that the vector pointer is not updated correctly.

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-29 15:42:33 -08:00
Xiang Xiao
10adf76209 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-28 13:53:20 -03:00
YAMAMOTO Takashi
b41524f0e6 libcxx: -Wno-shadow for files including filesystem_common.h
This might be specific to gcc or Linux
as I didn't see it with clang + macOS.
2020-12-24 21:57:39 -06:00
YAMAMOTO Takashi
6481b774e4 libcxx: Disable -Wshadow for locale.cpp
This might be specific to gcc or Linux
as I didn't see it with clang + macOS.

libcxx/src/locale.cpp: In member function 'void std::__1::locale::__install_ctor(const std::__1::locale&, std::__1::locale::facet*, long int)':
libcxx/src/locale.cpp:576:62: warning: declaration of 'id' shadows a member of 'std::__1::locale' [-Wshadow]
  576 | locale::__install_ctor(const locale& other, facet* f, long id)
      |                                                              ^
In file included from /Users/yamamoto/git/nuttx/nuttx/include/libcxx/locale:181,
                 from libcxx/src/locale.cpp:16:
/Users/yamamoto/git/nuttx/nuttx/include/libcxx/__locale:203:32: note: shadowed declaration is here
  203 | class _LIBCPP_TYPE_VIS locale::id
      |                                ^~
2020-12-24 21:57:39 -06:00
YAMAMOTO Takashi
884882501c libcxx: Disable -Wshadow for barrier.cpp
This might be specific to gcc or Linux
as I didn't see it with clang + macOS.

libcxx/src/barrier.cpp: In constructor 'std::__1::__barrier_algorithm_base::__barrier_algorithm_base(ptrdiff_t&)':
libcxx/src/barrier.cpp:35:9: warning: declaration of '__expected' shadows a member of 'std::__1::__barrier_algorithm_base' [-Wshadow]
   35 |         : __expected(__expected)
      |         ^
libcxx/src/barrier.cpp:29:24: note: shadowed declaration is here
   29 |     ptrdiff_t&         __expected;
      |                        ^~~~~~~~~~
libcxx/src/barrier.cpp: In constructor 'std::__1::__barrier_algorithm_base::__barrier_algorithm_base(ptrdiff_t&)':
libcxx/src/barrier.cpp:44:5: warning: declaration of '__expected' shadows a member of 'std::__1::__barrier_algorithm_base' [-Wshadow]
   44 |     }
      |     ^
libcxx/src/barrier.cpp:29:24: note: shadowed declaration is here
   29 |     ptrdiff_t&         __expected;
      |                        ^~~~~~~~~~
libcxx/src/barrier.cpp: In constructor 'std::__1::__barrier_algorithm_base::__barrier_algorithm_base(ptrdiff_t&)':
libcxx/src/barrier.cpp:44:5: warning: declaration of '__expected' shadows a member of 'std::__1::__barrier_algorithm_base' [-Wshadow]
   44 |     }
      |     ^
libcxx/src/barrier.cpp:29:24: note: shadowed declaration is here
   29 |     ptrdiff_t&         __expected;
      |                        ^~~~~~~~~~
CXX:  libcxx/src/new.cpp
In file included from libcxx/src/new.cpp:19:
/usr/include/c++/9/cxxabi.h: In member function 'virtual bool __cxxabiv1::__pbase_type_info::__pointer_catch(const __cxxabiv1::__pbase_type_info*, void**, unsigned int) const':
/usr/include/c++/9/cxxabi.h:308:23: error: 'const class std::type_info' has no member named '__do_catch'
  308 |     return __pointee->__do_catch (thrown_type->__pointee, thr_obj, outer + 2);
      |                       ^~~~~~~~~~
2020-12-24 21:57:39 -06:00
chao.an
2980792efd 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                             .......

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-23 00:11:38 -08:00
chao.an
826e74a13d libs/libc/dumpbuffer: remove the unnecessary printable characters traversal
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-23 00:11:38 -08:00
chao.an
48db71aa24 libs/libc/dumpbuffer: fix nxstyle warning
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-23 00:11:38 -08:00
chao.an
e32e341886 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                                ......

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-23 00:11:38 -08:00
Xiang Xiao
922cf0612b 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 10:40:22 -03:00
Huang Qi
073912e232 Replace all wget with curl
wget is missing from some system (like macOS and Windows native),
it's better to use curl to simplify build environment.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2020-12-22 03:36:10 -06:00
YAMAMOTO Takashi
b1878fe099 libcxx: Don't remove the downloaded file eagerly
It's convenient during development.
Also, it can be useful for offline builds.
2020-12-20 23:16:11 -06:00
YAMAMOTO Takashi
dfa2949b69 libcxx: Make download+patch a separate target
So that it doesn't need to be done on every sethost.sh.
2020-12-20 23:16:11 -06:00
Xiang Xiao
98be50a9bc 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 09:20:15 +01:00
Juha Niskanen
eaa75b11f8 libs/libc: fix typos in comments
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-12-13 09:06:28 -06:00
chao.an
859e1ce63a crypto/arc4random: rename getrandom to arc4random_buf
Change-Id: I5c9f0c9acf5af71f01beceaf06ebe0a2c87676bc
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-13 08:49:51 -06:00
chao.an
866bb35d2d libs/libc/net: implement ether_aton/ether_aton_r
Reference here:
https://www.unix.com/man-page/linux/3/ether_aton

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-10 20:37:32 -06:00
Juha Niskanen
21271c44b7 libs/libc/string/lib_strcspn.c: fix function name in comment
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-12-08 12:58:40 -06:00
YAMAMOTO Takashi
f0fc385232 libs/libc/machine/risc-v/rv64/arch_elf.c: Don't assume binfo expansion 2020-12-06 09:03:09 -06:00
YAMAMOTO Takashi
c7a2ee11ca libs/libc/machine/arm/armv6-m/arch_elf.c: Appease nxstyle
The following errors are intentionally left.
They are a part of tables which are not trivial to fix.

libs/libc/machine/arm/armv6-m/arch_elf.c:228:94: error: Long line found
libs/libc/machine/arm/armv6-m/arch_elf.c:230:89: error: Long line found
libs/libc/machine/arm/armv6-m/arch_elf.c:238:94: error: Long line found
libs/libc/machine/arm/armv6-m/arch_elf.c:240:89: error: Long line found
libs/libc/machine/arm/armv6-m/arch_elf.c:401:94: error: Long line found
libs/libc/machine/arm/armv6-m/arch_elf.c:403:91: error: Long line found
libs/libc/machine/arm/armv6-m/arch_elf.c:411:94: error: Long line found
libs/libc/machine/arm/armv6-m/arch_elf.c:413:91: error: Long line found
2020-12-06 09:03:09 -06:00
YAMAMOTO Takashi
0117d2b2f6 libs/libc/machine/arm/armv7-a/arch_elf.c: Fix syslog formats 2020-12-06 07:41:37 -06:00
YAMAMOTO Takashi
51b6a3cd1a libs/libc/machine/arm/armv7-a/arch_elf.c: Appease nxstyle 2020-12-06 07:41:37 -06:00
YAMAMOTO Takashi
9579fe1444 libs/libc/spawn/lib_psa_dump.c: Fix a syslog format 2020-12-05 08:13:32 -06:00
dongjiuzhu
11617fe5ab unistd/getopt: remove count of arguments limits
For commands without "-" arguments, ex:"ls", we should always let
optind = 1 after getopt is called in order to get what follows
correctly.

Change-Id: Iac3cfbadd27fb96e47070c4e3198229306299b6b
Signed-off-by: dongjiuzhu <dongjiuzhu1@xiaomi.com>
2020-12-02 02:56:23 -06:00
dongjiuzhu
9315fe21ed pthread_mutexattr_getprotocol: modify prototype
modify the return value according to posix standard

Change-Id: I6e32a8f7a5cac85fe7a395a8115710fdff61d985
Signed-off-by: dongjiuzhu <dongjiuzhu1@xiaomi.com>
2020-12-02 07:52:15 +01:00
Matias N
88f1cdb915 build system: add missing --obj-path to MKDEP 2020-11-28 09:59:56 -06:00
chao.an
b1a042734f style/Document: remove unnecessary trailing whitespace
N/A

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-28 12:20:30 +01:00
chao.an
c56785bd0d style/Makefile: remove unnecessary trailing whitespace
N/A

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-28 12:20:30 +01:00
YAMAMOTO Takashi
a2a30c8813 libs/libnx/nxfonts/nxfonts_cache.c: Fix syslog formats
Note: the width of nxgl_mxpixel_t depends on configuration.
2020-11-27 05:18:57 -06:00
Xiang Xiao
d6c24312aa Fix nxstyle warning
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-11-26 18:42:18 -03:00
Xiang Xiao
afb0e33138 libc/machine/arch: Support armv8-m relocation
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-11-26 18:42:18 -03:00
Xiang Xiao
74ab69af62 libs/libc/machine/arm: Rename armv8 to armv8-m
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-11-26 18:42:18 -03:00