Commit Graph

1686 Commits

Author SHA1 Message Date
zhanghongyu
fb5c9975cc libcxx: fix build error.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-12-06 07:56:17 -08:00
Zhang Yang
4f9d014994 Fix -nan issue with f32 2023-12-01 18:49:46 -08:00
chao an
3d57055057 libc/arm: add support of PACBTI
Reference:
https://developer.arm.com/documentation/100748/0617/Security-features-supported-in-Arm-Compiler-for-Embedded/PACBTI-M-extension-mitigations-against-ROP-and-JOP-style-attacks
https://developer.arm.com/documentation/101754/0619/armclang-Reference/armclang-Command-line-Options/-mbranch-protection

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-30 01:12:24 -08:00
chao an
29bda7cf27 libc/machine/arm: align related implementations of armv7 architecture
1. sync arch elf changes
2. fix cmake compilation break
3. remove the definition of related math files

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-29 19:04:30 -08:00
Michal Lenc
eea7db24f3 libc: add support for open_memstream
Adds support for POSIX interface open_memstream() that allows writing
to dynamic memory buffer stream. The stream is dynamically reallocated
as the buffer grows with initial size set to zero.

The caller has to free the buffer after the stream is closed.

The implementation uses fopencookie() for custom stream operations and
callbacks.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2023-11-29 02:13:19 -08:00
Ville Juven
e39ef8563e semaphore/_SEM_XX: Remove the _SEM redirection macros as unnecessary 2023-11-27 04:52:54 -08:00
Ville Juven
5f36a43609 sched/semaphore: Move named semaphores to user space 2023-11-27 04:52:54 -08:00
Ville Juven
c9bdadd541 sched/semaphore: Move cancel point and errno handling to libc / user-space
This moves all the public POSIX semaphore functions into libc and with
this most of the user-space logic is also moved; namely cancel point and
errno handling.

This also removes the need for the _SEM_XX macros used to differentiate
which API is used per user-/kernel mode. Such macros are henceforth
unnecessary.
2023-11-27 04:52:54 -08:00
SPRESENSE
6ba30033b3 libm: Fix an issue that public header files are not exported
Fix an issue that math library header files are not exported by make export.
Create symbolic links of libmcs, newlib and openlibm header to nuttx/include.
2023-11-23 16:32:53 +01:00
Ville Juven
57de6484e9 task/pthread_cancelpt: Fix task_delete from another task group
PR #11165 causes an unnecessary regression; task_delete no longer works,
if the deleted task is from another group.

The logic that prevents this comes from:

nxnotify_cancellation() ->
tls_get_info_pid() ->
nxsched_get_stackinfo()

Which checks for permissions, which does not make sense in this case since
it is the kernel asking for the stack information.

Fix this by partially reverting 11165 and implementing a direct path for
the kernel to query for any tasks TLS.
2023-11-22 08:05:58 -08:00
anjiahao
749655d785 tcbinfo:remove total_num form tcbinfo.
total_num is not required
test:

make -f tools/Makefile.host
cp tools/jlink-nuttx /opt/SEGGER/JLink_V786a/libnuttxplugin.so
JLinkGDBServer -if SWD -speed 5000 -device STM32F429ZI -NoGui 1 -rtos libnuttxplugin

can run normally

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-11-21 21:52:24 -08:00
chenrun1
f12c4fb887 Revert "libc/lib_bzero:Add bzero prototype." 2023-11-21 07:56:52 -08:00
PwnVerse
e2627d4558 Fix improper handling of 64 bit types for libvsprintf 2023-11-15 18:37:43 -08:00
Ville Juven
0dedbcd4ae task/pthread_cancelpt: Move cancel point handling to libc, data to TLS
This moves task / thread cancel point logic from the NuttX kernel into
libc, while the data needed by the cancel point logic is moved to TLS.

The change is an enabler to move user-space APIs to libc as well, for
a coherent user/kernel separation.
2023-11-15 08:52:04 -08:00
Ville Juven
1e31ec8003 sched/tls_info: Add tl_ prefix to pthread cleanup stack / tos 2023-11-15 08:52:04 -08:00
fengxuesong
bb14e45ec9 the bug of sscanf exception output in arm64 platform
Signed-off-by: fengxuesong <fengxuesong@xiaomi.com>
2023-11-15 03:45:32 -08:00
SPRESENSE
63182d43b9 libm/newlib: Change the download site to https
Change newlib download site from ftp to more secure https.
2023-11-10 16:28:13 +08:00
zhanghongyu
234dd95e0b libc_atomic: add file to cmake script
resolves an error where atomic related symbols cannot be found at cmake compile time.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-11-07 17:39:03 +01:00
zhanghongyu
c831c8cc56 cmake: add needed file to cmake script for build sim
nuttx/crypto/chachapoly.c:232: undefined reference to `timingsafe_bcmp'

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-11-07 17:39:03 +01:00
zhanghongyu
766e4a4154 libs/libc: adapt the cmake script from the makefile
fix the cmake build error.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-11-07 17:39:03 +01:00
chao an
d410a6e1a6 libc/realpath: allocate link buffer of pseudofs to save stack
The link buffer of pseudofs will occupy too much of stack, allocate from
the heap to save the stack usage.

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-07 09:05:50 +08:00
Stuart Ianna
c1db9732c5 libs/libc/spawn: Add minimal implementation for posix_spawnattr_destory.
Add a minimal implementation to suppress warnings when building
application code shared with other operating systems.

For example:

When building with a c++ compiler and GCC 12.2.0, the following warning is emitted:

nuttx/include/spawn.h:178:40: warning: statement has no effect [-Wunused-value]
  178 | #define posix_spawnattr_destroy(attr) (0)
2023-10-31 13:42:00 +08:00
dongjiuzhu1
489bd15271 arch/arm64: support relocate for aarch64
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-10-30 18:20:22 +08:00
raiden00pl
5b87fdfb9d Documentation: remove all migrated READMEs 2023-10-29 21:03:54 -03:00
Xiang Xiao
7aad7eebff libc: Change errno to set_errno and get_errno
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-29 17:16:09 +02:00
Xiang Xiao
f911d3a1c3 stdio: Implement [clearerr|putc|fflush]_unlocked
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-29 17:09:18 +02:00
Xiang Xiao
2c9511e655 libc/stdio: Remove bforce from lib_fflush[_unlocked]
since all callers set bforce to true

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-29 17:09:18 +02:00
Xiang Xiao
c3be772441 libc/stdio: lib_fwrite_unlocked must call lib_fflush_unlocked with true
otherwise the following file i/o mess up the output

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-29 17:09:18 +02:00
dongjiuzhu1
5c98649a7a libs/lib_psfa_adddup2.c: remove workaround aboud dup2
Because popen no longer needs to rely on intermediate
tasks to start command tasks.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-10-27 21:15:07 +08:00
Michal Lenc
65ae8a545c libc: add support for memory buffer stream with fmemopen()
Add support for POSIX interface fmemopen(). This interface open a memory
buffer as a stream and permits access to this buffer specified by mode.
This allows I/O operations to be performed on the memory buffer.

The implementation uses fopencookie() for custom stream operations and
callbacks.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2023-10-27 08:55:24 +08:00
simbit18
8f96e59aee libs/libc/stdlib/lib_exit.c: fix multiple definition of __dso_handle in msys2
CPP:  nuttx-names.in-> nuttx-names.dat
LD:  nuttx
/usr/lib/gcc/x86_64-pc-msys/13.2.0/../../../../x86_64-pc-msys/bin/ld: nuttx.rel:/d/a/nuttx_windows/nuttx_windows/nuttxspace/nuttx/libs/libc/stdlib/lib_exit.c:48: multiple definition of `__dso_handle'; /usr/lib/gcc/x86_64-pc-msys/13.2.0/crtbegin.o:cygming-crtbeg:(.data+0x0): first defined here
2023-10-27 01:21:10 +08:00
xuxin19
e3003f691b cmake:init RISC-V cmake qemu-rv build
cmake currently does not support non-FlatBuild,
need disable ELF and LOADABLE when compiling other defconfigs

```
 cmake -B build -DBOARD_CONFIG=rv-virt/smp64 -GNinja # for rv32:rv-virt/smp
 cmake --build build -t menuconfig
 cmake --build build
 qemu-system-riscv64 -semihosting -M virt,aclint=on -cpu rv64 -smp 8 -bios none -kernel nuttx -nographic
```

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2023-10-26 21:01:46 +08:00
Stuart Ianna
ad9f6b79e0 libs/libcxx: Silence warnings when building libcxx.
Silence two warnings when building libcxx with GCC 12.2.0 and std=c++2b:

libcxx/src/charconv.cpp_CXXFLAGS += -Wno-attributes
 - Results from libcxx fallback to use __always_inline__ when exclude_from_explicit_instantiation isn't available.

libcxx/src/locale.cpp_CXXFLAGS += -Wno-attributes
 - Results from the expansion of _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS. Should be fine to ignore.
2023-10-26 09:07:17 +02:00
dongjiuzhu1
a7e448c57e modlib/modlib_load: fix compile warning
CC:  icmp/icmp_input.c modlib/modlib_load.c: In function 'modlib_elfsize':
modlib/modlib_load.c:87:30: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
   87 |                   textaddr = (FAR void *)phdr->p_vaddr;
      |                              ^
cc1: all warnings being treated as errors

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-10-26 01:53:38 +08:00
dongjiuzhu1
db13ff2dd5 libs/libc: fix compile warning about modlib_depend when CONFIG_MODLIB_MAXDEPEND = 0
modlib/modlib_symbols.c: In function ‘modlib_symcallback’:
modlib/modlib_symbols.c:215:13: warning: implicit declaration of function ‘modlib_depend’; did you mean ‘modlib_read’? [-Wimplicit-function-declaration]
  215 |       ret = modlib_depend(exportinfo->modp, modp);
      |             ^~~~~~~~~~~~~
      |             modlib_read

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-10-26 01:53:38 +08:00
dongjiuzhu1
e88a36fa92 libs/modlib: Adding architecture-specific memory allocator for dynamic data loading
Arch can specific the memory allocator for data to optimize access speed.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-10-26 01:53:38 +08:00
dongjiuzhu1
81717a59ea libs/modlib: remove dupliate define about modlib_dumpbuffer
CP:  nuttx/include/nuttx/config.h
modlib/modlib_init.c:53: warning: "modlib_dumpbuffer" redefined
   53 | #  define modlib_dumpbuffer(m,b,n) binfodumpbuffer(m,b,n)
      |
In file included from modlib/modlib_init.c:36:
nuttx/include/nuttx/lib/modlib.h:64: note: this is the location of the previous definition
   64 | #  define modlib_dumpbuffer(m,b,n) sinfodumpbuffer(m,b,n)
      |

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-10-26 01:53:38 +08:00
dongjiuzhu1
fbd6484532 libc/localtime: fix the timezone error caused by minor error
align: https://github.com/eggert/tz/blob/main/localtime.c

correct timeone in test:

server> timedatectl set-timezone Pacific/Auckland
server> timedatectl
      TimeZone: NZDT, 46800
    Local time: Sat, Oct 21 21:47:34 2023 NZDT
Universal time: Sat, Oct 21 08:47:34 2023 UTC
      RTC time: Sat, Oct 21 08:47:35 2023

error timezone:

server> timedatectl set-timezone Pacific/Auckland
server> timedatectl
      TimeZone: NZST, 43200
    Local time: Sat, Oct 21 20:52:27 2023 NZST
Universal time: Sat, Oct 21 08:52:27 2023 UTC
      RTC time: Sat, Oct 21 08:52:27 2023

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-10-26 00:10:04 +08:00
Xiang Xiao
1883b91e3c libc: Remove the unused lib_libdtoa.c
__dtoa is not used because currently NuttX uses other
function called __dtoa_engine() to do the same thing

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-23 20:06:34 -03:00
Xiang Xiao
66db15437d libc/stdio: Change FILE buffer field from "unsigned char *" to "char *"
to avoid the unnecessary casting

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-22 21:18:46 +03:00
raiden00pl
eed42a12ed libds: add missing observer_b16.c to cmake build 2023-10-19 01:18:40 +08:00
Michal Lenc
0a107ca6d9 libc: add support for custom streams with fopencookie()
This commit adds support for custom stream via fopencookie function.
The function allows the programmer the create his own custom stream
for IO operations and hook his custom functions to it.

This is a non POSIX interface defined in Standard C library and implemented
according to it. The only difference is in usage of off_t instead of
off64_t. Programmer can use 64 bits offset if CONFIG_FS_LARGEFILE is
enabled. In that case off_t is defined as int64_t (int32_t otherwise).

Field fs_fd is removed from file_struct and fs_cookie is used instead
as a shared variable for file descriptor or user defined cookie.

The interface will be useful for future fmemopen implementation.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2023-10-18 21:13:01 +08:00
Xiang Xiao
b1c8c84e81 stdio: Merge fs_fdopen into fdopen to simplify the code logi
since fs_fdopen could avoid call the kernel specific function now

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-17 13:34:00 +08:00
Xiang Xiao
b0d197534f stdio: Move lib_stream_[initialize|release] from libc/stdio to sched/tls
both functions aren't suitable to be put into libc,
because they call the kernel internal functions directly.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-17 13:34:00 +08:00
Xiang Xiao
b892ec5c6e libc/machine: Remove FAR from sparc
since sparc is 32bit arcch, FAR is useless

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-17 13:15:48 +08:00
raiden00pl
8bdb78b446 libdsp/lib_observer.c: use float numbers in all calculations
we want to use FPU instructions in calculations not __aeabi
2023-10-15 10:43:37 -04:00
liqinhui
602c644f4d netdb: When set a dns nameserver, if the nameserver already exists, retrun OK.
We consider the setting successful when the namesaerver we set already exists.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2023-10-12 12:22:16 +08:00
hujun5
99eeaafd07 lib_memfd: turn a runtime error into a linker error
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-10-11 23:39:37 +08:00
Lee Lup Yuen
6cad7e9582 arm, arm64, xtensa, libxx: Change sed -r to sed -E to support macOS
When we build NuttX on macOS, it shows many `sed` messages (and the build still completes successfully):

```text
$ tools/configure.sh pinephone:nsh
$ make
sed: illegal option -- r
```

This is due to the Makefiles executing `sed -r` which is not a valid option on macOS.

This PR proposes to change `sed -r` to `sed -E` because:

- `sed -E` on macOS is equivalent to `sed -r` on Linux

- `sed -E` and `sed -r` are aliases according to the GNU `sed` Manual

- `sed -E` is already used in nuttx_add_romfs.cmake, nuttx_add_symtab.cmake and process_config.sh
2023-10-10 11:36:32 +03:00
raiden00pl
4f8a2b3874 libds/lib_misc: use b16abs() 2023-10-07 21:25:56 +08:00