Commit Graph

1669 Commits

Author SHA1 Message Date
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
raiden00pl
819bec0888 libdsp/lib_observe: fix typo and use b16sign() 2023-10-07 21:25:56 +08:00
Xiang Xiao
dfa0283d83 spinlock: Rename spin_islocked to spin_is_locked
align with Linux naming style

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-06 20:03:19 -04:00
Xiang Xiao
aa0b3fcdf9 lib/memfd: shm_unlink or unlink anonymous file
https://man7.org/linux/man-pages/man2/memfd_create.2.html:
       The name supplied in name is used as a filename and will be
       displayed as the target of the corresponding symbolic link in the
       directory /proc/self/fd/.  The displayed name is always prefixed
       with memfd: and serves only for debugging purposes.  Names do not
       affect the behavior of the file descriptor, and as such multiple
       files can have the same name without any side effects.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-06 20:02:30 -04:00
SPRESENSE
bf6606f80c libxx: Use gnu++20 option only if using libcxx
Fix an issue that gnu++20 option is always used.
Essentially, when cxx is not used, gnu++17 should be retained.
2023-10-05 13:09:20 +08:00
hujun5
b6693065e7 pthread_once: g_lock may lead deadlock
For programs with the dependencies logic in pthread_once callback , using global locks may cause deadlock:

task A
pthread_once()
|
|-> nxrmutex_lock(&g_lock);
 -> init_routine(); // callback to wait task B
                                                  task B
                                                  pthread_once()
                                                  |
                                                   ->nxrmutex_lock(&g_lock); // Deadlock
                                                   ->init_routine(); // hold resource to wake up task A

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-09-26 10:13:00 +08:00
Xiang Xiao
b172de378d Fix make[1]: *** No rule to make target '.header', needed by 'context'. Stop.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-09-25 23:29:05 +08:00
Xiang Xiao
06619ac6fc lib/netdb: Change the default NETDB_DNSCLIENT_NAMESIZE to PATH_MAX
Domain name has the similar layout as file path, so it's too small
to use 32 bytes as the default value, and better to has the same
default value as PATH_MAX which is 255.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-09-24 19:32:25 -04:00
Xiang Xiao
b383c31089 libc: Add bsearch to libc.csv
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-09-25 01:08:15 +03:00
Xiang Xiao
381c7dd747 Fix error: unknown warning option '-Wno-unqualified-std-cast-call'
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-09-24 08:40:10 +03:00
Stuart Ianna
4f90a6140c libcxx: Remove exiting patches and update libcxx version to 15.0.7
- Add __config_site for NuttX.
   In libcxx 12.0.0. CMake concatenated __config_site with _config,
   which enabled NuttX to build without its inclusion. In 15.0.7, this
   file is configured by CMake and included explicitly in __config.
 - Add additional include directories.
 - Mute always_inline warning.
 - Make the download of libcxx/libcxxabi configurable
2023-09-24 08:40:10 +03:00
Xiang Xiao
d6453cfc3c libxx: Change the default value of CXX_STANDARD to gnu++20
since llvm libcxx 15.0.7 require c++20 feature to pass the build

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-09-24 08:40:10 +03:00
zhanghongyu
a41f68da84 dns: fix dns failed when ipv4/6 dual stack enable
The ipv6 address filled the cache, and the ipv4 address did not have a
place to store it, causing the resolution to fail. so if IPV6 has already
filled the buffer, rewrite ipv4 DNS results from half of the buffer.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-09-23 15:56:05 +08:00
wangyongrong
2d817deecb armv8m/strcpy: add arch optimize version 2023-09-22 08:52:25 +08:00
guoshichao
abfb7da553 libs/libc/libc.csv: add the implemented wchar api declaration
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-22 08:51:07 +08:00
guoshichao
5bd8e56cbe libs/libc/wchar: add fputws implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-22 08:51:07 +08:00
guoshichao
d67090c47e libs/libc/wchar: add putwc implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-22 08:51:07 +08:00
guoshichao
a9b2857754 libs/libc/wchar: add putwchar implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-22 08:51:07 +08:00