Commit Graph

2026 Commits

Author SHA1 Message Date
buxiasen cb720024b6 Revert "libc/lib_bzero:Add bzero prototype."
This reverts commit 908814a575.

In macos, memset will be automatic optmize to bzero, caused dead loop, as we not using bzero, macro re-define should ablt to cover the requirements.

Signed-off-by: buxiasen <buxiasen@gmail.com>
2024-10-23 10:08:23 +08:00
yangguangcai f07aba5c1e libc string:Separate code.
Separate the code that follows the BSD license into independent files.

Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-10-23 09:49:19 +08:00
ligd cdccce48ac libcxx: fix compile error
from ServiceManager.cpp:17:
/home/ligd/platform/dev/apps/external/android/frameworks/native/libs/binder/ndk/include_cpp/android/binder_to_string.h:71:24: error: expected nested-name-specifier before numeric constant
   71 |     template <typename _U>
      |                        ^~
/home/ligd/platform/dev/apps/external/android/frameworks/native/libs/binder/ndk/include_cpp/android/binder_to_string.h:71:24: error: expected ‘>’ before numeric constant
In file included from /home/ligd/platform/dev/apps/external/android/frameworks/native/libs/binder/aidl/android/os/ConnectionInfo.h:3,
                 from /home/ligd/platform/dev/apps/external/android/frameworks/native/libs/binder/aidl/android/os/IServiceManager.h:3,
                 from /home/ligd/platform/dev/apps/external/android/frameworks/native/libs/binder/aidl/android/os/BnServiceManager.h:4:
/home/ligd/platform/dev/apps/external/android/frameworks/native/libs/binder/ndk/include_cpp/android/binder_to_string.h:72:56: error: no matching function for call to ‘declval<1>()’
   72 |     static auto _test(int) -> decltype(std::declval<_U>().toString(), std::true_type());
      |                                        ~~~~~~~~~~~~~~~~^~
In file included from /home/ligd/platform/dev/nuttx/include/libcxx/__type_traits/is_convertible.h:18,

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-23 09:42:57 +08:00
cuiziwei 35c278b716 libcxx: Ignore compile warnings.
nuttx/libs/libxx/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp:17:4: warning: #warning exception_ptr not yet implemented [-Wcpp]
17 | #  warning exception_ptr not yet implemented
   |    ^~~~~~~

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-10-21 15:06:42 +02:00
jihandong 444ba4caa4 libcxx: optional localization.
Signed-off-by: jihandong <jihandong@xiaomi.com>
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-10-19 14:34:38 +08:00
jihandong 100c43c8c3 libcxx: optional wide characters support.
Disable wchar can reduce approximately 1/3 of the libcxx.
mainly from locale, string and streams.

Platform: sim
Figures: bin size in bytes.

   Size   | Description
----------+------------------------------------------------
 10045336 | Base, enable libcxx whithout any cxx programs.
 42067224 | Add cxxtest.
 29997304 | Disable libcxx wchar support.

Signed-off-by: jihandong <jihandong@xiaomi.com>
2024-10-19 14:34:38 +08:00
zhangbo56 0496984338 libc: Add debug assert to prevent tls allocation failure
So It's easy to find TASK_TLS_ELEM not enough error.

Signed-off-by: zhangbo56 <zhangbo56@xiaomi.com>
2024-10-18 21:34:18 +08:00
chao an 91cb625f9d memory_region: add static/const for read only instance
Signed-off-by: chao an <anchao@lixiang.com>
2024-10-18 21:32:48 +08:00
chao an d49db03e04 libs/misc/memoryregion: remove unused memory_region
memory region will no longer be used

Signed-off-by: chao an <anchao@lixiang.com>
2024-10-18 21:32:48 +08:00
Tomasz 'CeDeROM' CEDRO 8cc2fbfd00 libc: Fix typo in libc/string/Kconfig.
This typo prevented initial ./tools/configure.sh.

Signed-off-by: Tomasz 'CeDeROM' CEDRO <tomek@cedro.info>
2024-10-18 10:25:07 +02:00
Ville Juven 17c102c10c modlib/modlib_symbols.c: Fix usage of void* arithmetics
In file included from modlib/modlib_symbols.c:34:
modlib/modlib_symbols.c: In function 'modlib_symvalue':
modlib/modlib_symbols.c:432:41: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
  432 |               (uintptr_t)(sym->st_value + symbol->sym_value));
      |                                         ^
cc1: all warnings being treated as errors
make[1]: *** [Makefile:156: bin/modlib_symbols.o] Error 1
2024-10-17 22:54:33 +08:00
yangguangcai fba3967f2f strcpy:skip ubsan check.
string/lib_strcpy.c:87:15: runtime error: signed integer overflow: -2132367969 - 16843009 cannot be represented in type 'long int'
    #0 0x48e77096 in strcpy string/lib_strcpy.c:87
    #1 0x535b6ea4 in libconfig_strbuf_append_string libconfig/lib/strbuf.c:60
    #2 0x53ad7f52 in libconfig_yyparse /home/ygc/ssd/x4b-sim/external/libconfig/grammar.y:186
    #3 0x5358d281 in __config_read libconfig/lib/libconfig.c:561
    #4 0x5358dea0 in config_read_file libconfig/lib/libconfig.c:677
    #5 0x52cdd0a5 in tts_vendor_list_get src/vendor.c:114
    #6 0x52cde739 in default_tts_vendor_get src/vendor.c:356
    #7 0x52a07e1d in vendorswitch_init src/vendorswitch/vendorswitch.c:501
    #8 0x52444fb9 in mico_misc_main /home/ygc/ssd/x4b-sim/vendor/xiaomi/miai/mico_misc/instance/main.c:72
    #9 0x48bee720 in nxtask_startup sched/task_startup.c:70
    #10 0x48b41eb4 in nxtask_start task/task_start.c:112
    #11 0x48c1ef3d in pre_start sim/sim_initialstate.c:52

Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-10-17 22:52:42 +08:00
yangguangcai c113a224e8 newlibc:skip asan check.
Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-10-17 22:52:42 +08:00
yangguangcai 6e87f11083 Merge the newlibc string into NuttX.
Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-10-17 22:52:42 +08:00
YAMAMOTO Takashi 4bfde8858d Discourage the use of LIBC_PRINT_EXTENSION
See the discussion in https://github.com/apache/nuttx/pull/13536
2024-10-17 18:08:23 +08:00
Ville Juven e384a6a625 libs/modlib.c: Set VMA for empty and unallocated sections
This fixes issue where empty and unallocated sections are left without
a VMA. Some relocations depend on the section VMA being set even if there
is no data there, as the binary can refer to the symbols. Linker defined
symbols do not contain data -> they can produce empty sections.

This issue is seen when building a loadable file which declares _sctors /
_sdtors linker defined symbols for ctor/dtor sections which are empty.
crt0 references these symbols, so they need to be relocated, but the
section VMA is not set -> they go outside of the addressable range of the
user binary causing a potential crash.
2024-10-17 13:38:01 +08:00
Xiang Xiao 67ed036227 libc: Make getcwd() work even CONFIG_DISABLE_ENVIRON is enabled
since getcwd() can be implemented correctly without using environ

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-16 23:59:07 +08:00
cuiziwei 499de61ec3 libxx: Globally reference the header file of libcxxabi and remove duplication code.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-10-16 20:05:17 +08:00
yangguangcai 5de562347d libc/memmem:porting open source memmem to Nuttx.
Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-10-16 18:41:50 +08:00
anjiahao a72e9e5621 modlib:if elf in romfs/tmpfs, try use xipbase
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-16 18:40:06 +08:00
anjiahao 112b6fd9a5 modlib:support modlib can load PIC elf
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-16 18:40:06 +08:00
yinshengkai 6fbe16f40f libs: remove lib_libbsprintf automatic line wrapping
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-16 17:26:14 +08:00
chenjiahua1 c1fb6974ac strptime.c:len is not defined.
Bring all code that uses the variable len under the CONFIG_LIBC_LOCALE

Signed-off-by: chenjiahua1 <chenjiahua1@xiaomi.com>
2024-10-16 17:02:51 +08:00
chenjiahua1 64eecbfede libc/time: add lib_strptime
The community deleted strptime due to license reasons, and we replaced it with musl.

Signed-off-by: chenjiahua1 <chenjiahua1@xiaomi.com>
2024-10-16 17:02:51 +08:00
Bowen Wang 8cfe8a0f3e circbuf: fix circbuf_get_read/writeptr return *size = 0 when circbuf full
In circbuf_get_read/writeptr, when circbuf is full, off == pos, and
*size = off - pos = 0. So add circbuf_is_full() condition to return
correct *size.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-10-16 16:59:51 +08:00
wangmingrong1 bf70cd2bce bug/fix: Makefile expression error caused
expr: syntax error: unexpected argument "12"
expr: syntax error: unexpected argument "12"

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-16 15:35:04 +08:00
Yongrong Wang 4baec5a248 libs/xxx/CMakeLists.txt: add cmake compile support
Add the lib_bzero.c files to the build use it's API
Add the floating point math C files to the build to use it's API

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
2024-10-16 12:33:54 +08:00
chenzhijia b63cffe000 libs/libc/unistd:Fix errcode not return normally
Exit the program and return errcode when ioctl fail

Signed-off-by: chenzhijia <chenzhijia@xiaomi.com>
2024-10-16 11:15:25 +08:00
chenzhijia d52074a9cb libs/libc/unistd: add getspnam function
Add getspnam function to pass tlpi example:
https://man7.org/tlpi/code/online/dist/users_groups/check_password.c.html

Signed-off-by: chenzhijia <chenzhijia@xiaomi.com>
2024-10-16 11:15:25 +08:00
chenzhijia 2a328279ca libs/libc/unistd: add crypt function
Add crypt function to pass tlpi example:
https://man7.org/tlpi/code/online/dist/users_groups/check_password.c.html

Signed-off-by: chenzhijia <chenzhijia@xiaomi.com>
2024-10-16 11:15:25 +08:00
chenzhijia ad70ca33c8 libs/libc/unistd: add getpass function
Add getpass function to pass tlpi example:
https://man7.org/tlpi/code/online/dist/users_groups/check_password.c.html

Signed-off-by: chenzhijia <chenzhijia@xiaomi.com>
2024-10-16 11:15:25 +08:00
chenzhijia c0039d6623 libs/libc/pwd: add new member to passwd struct
Add pw_passwd member to pass tlpi example:
https://man7.org/tlpi/code/online/dist/users_groups/check_password.c.html

Signed-off-by: chenzhijia <chenzhijia@xiaomi.com>
2024-10-16 11:15:25 +08:00
Xiang Xiao 5397a58731 libc/modlib: Make modlib selectable from defconfig
since bootloader may call modlib functions directly
to load elf firmware without binfmt, dlfcn or module.

BTW, this patch also remove the duplicated selecttion

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-16 10:11:20 +08:00
liwenxiang1 3fd75efed9 Revert "libs/libc:Openlibm adds exp10 and exp10f function implementations"
This implementation is from glibc, and the license is LGPL

This reverts commit 862244586976b9388f87dc639225d714dd70e4af.

Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
2024-10-16 08:03:31 +08:00
raiden00pl c393416580 libs/libxx: uClibc depends on CONFIG_ALLOW_GPL_COMPONENTS=y
uClibc is LGPL so it should depends on CONFIG_ALLOW_GPL_COMPONENTS=y
2024-10-16 07:56:50 +08:00
cuiziwei 9d9857acd2 Change the judgment of GCCVER version to greater equal.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-10-15 23:32:13 +08:00
anjiahao ae126a8065 lib_stdoutstream:need return write size
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-15 23:30:57 +08:00
likun17 9de0465a8a lib_libvsprintf.c:add option in Kconfig to control "%p*" special format specifier.
Signed-off-by: likun17 <likun17@xiaomi.com>
2024-10-15 15:33:13 +08:00
likun17 83914d5b29 lib_libvsprintf.c: Add support for %pB parameter.
Signed-off-by: likun17 <likun17@xiaomi.com>
2024-10-15 15:33:13 +08:00
hujun5 a567148888 sched: add up_this_task and up_change_task macro stub
reason:
We can utilize percpu storage to hold information about the
current running task. If we intend to implement this feature, we would
need to define two macros that help us manage this percpu information
effectively.

up_this_task: This macro is designed to read the contents of the percpu
              register to retrieve information about the current
              running task.This allows us to quickly access
              task-specific data without having to disable interrupts,
              access global variables and obtain the current cpu index.

up_update_task: This macro is responsible for updating the contents of
                the percpu register.It is typically called during
                initialization or when a context switch occurs to ensure
                that the percpu register reflects the information of the
                newly running task.

Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make
Running with qemu
$ qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic \
   -machine virt,virtualization=on,gic-version=3 \
   -net none -chardev stdio,id=con,mux=on -serial chardev:con \
   -mon chardev=con,mode=readline -kernel ./nuttx

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-15 15:25:55 +08:00
Bowen Wang 71ee767fe2 vsprintf:fix bug when print int64 0x8000000000000000
stdio/lib_libvsprintf.c:1018:17: runtime error: negation of -9223372036854775808 cannot be
represented in type 'long long int'; cast to an unsigned type to negate this value to itself
    #0 0x3326a86 in vsprintf_internal stdio/lib_libvsprintf.c:1018
    #1 0x332926b in lib_vsprintf stdio/lib_libvsprintf.c:1363
    #2 0x3777978 in vfprintf stdio/lib_vfprintf.c:52
    #3 0x671b3a0 in printf stdio/lib_printf.c:44
    #4 0x37abc0c in hello_main /data/project/code/vela-pt/apps/examples/hello/hello_main.c:38
    #5 0x33201d3 in nxtask_startup sched/task_startup.c:70
    #6 0x3208ecb in nxtask_start task/task_start.c:134
    #7 0x3357a49 in pre_start sim/sim_initialstate.c:52

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-10-15 08:14:59 +02:00
cuiziwei bbf60ec685 gnu++20:fix ld error.
LD: nuttx
arm-none-eabi-ld: warning: net_sendfile.o: missing .note.GNU-stack section implies executable stack
arm-none-eabi-ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
arm-none-eabi-ld: warning: nuttx/nuttx has a LOAD segment with RWX permissions
arm-none-eabi-ld: apps/staging/libfeature.a(feature_framework.cpp.frameworks.base.feature_1.o): in function `std::__1::__throw_length_error[abi:un170006](char const*)':

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-10-15 12:57:52 +08:00
Gao Jiawei 89d6abf3df setjmp: fix setjmp returns 0 when calling longjmp with 0 as the second argument
Signed-off-by: Gao Jiawei <gaojiawei@xiaomi.com>
2024-10-15 12:36:19 +08:00
cuiziwei 036a0674db nuttx/libc:Add _dl_find_object and dl_iterate_phdr function.
Add _dl_find_object() function, because when cxx_exception configuration is enabled, a link error occurs and that function cannot be found.

ld: /usr/lib/gcc/x86_64-linux-gnu/13/libgcc_eh.a(unwind-dw2-fde-dip.o): in function `_Unwind_Find_FDE':
(.text+0x250c): undefined reference to `_dl_find_object'

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-10-15 12:35:54 +08:00
anjiahao 4156eca0c1 modlib:so need export symbol, exec elf not need
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-15 03:20:05 +08:00
anjiahao 19b8fdbad6 modlib:allow 64bit elf load
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-15 03:20:05 +08:00
ligd 7d218f93fa libc: add nx_strdup() & nx_strndup() support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-15 01:16:48 +08:00
chao an 39c1c871a0 Revert "libc/atomic: decoupling atomic and spinlock to avoid recursion"
This reverts commit c37b0de28c.
2024-10-14 17:42:16 +08:00
cuiziwei 7246533aeb Unify the definition of GCCVER and remove duplicate code.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-10-13 11:41:22 +08:00
zhanghu5 f8f6bfff29 use r1-r3 as tmp register
Signed-off-by: zhanghu5 <zhanghu5@xiaomi.com>
2024-10-13 10:12:27 +08:00