Commit Graph

2052 Commits

Author SHA1 Message Date
xuxin19 299ef6234f cmake(bugfix):add xtensa libc machine function build
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-11-03 09:16:24 +08:00
chenrun1 1fce345481 libc/machine/CMakeLists: should alaways build arch_atomic.c
Summary:
  This issue comes from https://github.com/apache/nuttx/pull/14570. In the previous Atomic implementation https://github.com/apache/nuttx/pull/13044, we have removed the CONFIG_LIBC_ARCH_ATOMIC macro, so arch_atomic.c should always be compiled.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-11-03 02:33:03 +08:00
hujun5 2c0e5e872b pthread_cond remove csection
reason:
We decouple semcount from business logic by using an independent counting variable,
which allows us to remove critical sections in many cases.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-02 09:40:19 -03:00
zhangyuan29 b294fd3c8a libc/unistd: fixed tasking build issue
CC:  pthread/pthread_mutexattr_getrobust.c artc I800: creating archive libsched.a
CC:  unistd/lib_getopterrp.c ctc W505: ["unistd/lib_getoptargp.c" 48/29] implicit declaration of function "getoptvars"
ctc W577: ["unistd/lib_getoptargp.c" 48/39] calling a function without a prototype
ctc W524: ["unistd/lib_getoptargp.c" 48/27] conversion of integer to pointer at assignment
ctc E212: ["unistd/lib_getoptargp.c" 49/13] access to incomplete type
ctc W523: ["unistd/lib_getoptargp.c" 49/13] pointers to different types at return

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
2024-11-01 23:03:23 +08:00
wangmingrong1 d13dc86f16 libxx/patch: Remove jira information and change-id
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-01 23:01:16 +08:00
ouyangxiangzhen 17c51c0667 userspace: Exclude nuttx/arch.h
This patch fixed userspace headers conflict. Architecture-related definition and API should not be exposed to users.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2024-11-01 16:59:37 +08:00
wangmingrong1 fbaace01d0 libc/arch_libc: replace all arch define to ARCH_LIBCFUN(x) style
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-31 18:11:16 +08:00
wangmingrong1 b22e8c7c1c libc: Modify the check length
We should not check the length of both strings at the same time.

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-31 18:11:16 +08:00
wangmingrong1 e466c637fc arch_lib.c: close kasan readcheck no return
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-31 18:11:16 +08:00
anjiahao 22e5c88479 libs/machine:strnlen need check return
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-31 18:11:16 +08:00
anjiahao 603c87977f libc/machine:Add prefixes to libc functions implemented by arch
kasan does not instrument the assembly function,
so it is checked in advance before calling.
If Kasan is not turned on, the speed and space will
be almost unchanged under compiler optimization.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-31 18:11:16 +08:00
xuxin19 6ee73bc199 cmake(bugfix):fix libc sysclog CMake build typo
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-10-31 17:55:13 +08:00
YAMAMOTO Takashi 94a13982eb DNS: Implement TCP fallback
* Implement DNS query over TCP

* Implement TCP fallback on responses with the TC bit set

References:

* https://www.ietf.org/rfc/rfc2181.txt

* http://www.dnsflagday.net/2020/

* https://www.netmeister.org/blog/dns-size.html
2024-10-31 17:18:20 +08:00
Karel Kočí b851916d76 libs/libc/obstack: fix allocated chunk overrun due to invalid limit
This primarily fixes allocated memory overrun due to invalidly
calculated limit of the chunk. The function here allocates chunk of size
that includes required header. The error was that size of the chunk was
invalidly again added when limit was being calculated. This was causing
memory overrun and issues especially with object growing (reallocation).

The secondary fix here is to the algorithm that rounds the required size
to the multiple of chunk size. In short chunk size must be reduced by
one to get the correct mask. The condition that was generating the mask
was also invalid because it must perform shift with at most one less
than number of bits (not bytes).
2024-10-30 11:53:18 -03:00
xuxin19 c60b980968 cmake(bugfix):fix robot openlibm cmake build missing source error
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-10-30 22:14:40 +08:00
wangmingrong1 8461f0ea54 clang: Support compiling rt.profile library
1. Since the implementation of gcov has changed since clang17, versions before clang17 need to use the libunwind.a file

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-30 17:10:23 +08:00
YAMAMOTO Takashi 761ee81956 move readv/writev to the kernel
currently, nuttx implements readv/writev on the top of read/write.
while it might work for the simplest cases, it's broken by design.
for example, it's impossible to make it work correctly for files
which need to preserve data boundaries without allocating a single
contiguous buffer. (udp socket, some character devices, etc)

this change is a start of the migration to a better design.
that is, implement read/write on the top of readv/writev.

to avoid a single huge change, following things will NOT be done in
this commit:

* fix actual bugs caused by the original readv-based-on-read design.
  (cf. https://github.com/apache/nuttx/pull/12674)

* adapt filesystems/drivers to actually benefit from the new interface.
  (except a few trivial examples)

* eventually retire the old interface.

* retire read/write syscalls. implement them in libc instead.

* pread/pwrite/preadv/pwritev (except the introduction of struct uio,
  which is a preparation to back these variations with the new
  interface.)
2024-10-30 17:07:54 +08:00
wangmingrong1 20e33ed84a libbuitlin: distclean should delete all files
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-28 22:19:58 +08:00
wangmingrong1 e174d73cd9 clang:libclang_rt.builtins-xxx.a supports builtin
1. enable CONFIG_BUILTIN_COMPILER_RT  to built libclang_rt.builtins-xxx.a and no longer use the compiler's built-in
2. Modify clang version acquisition to get two decimal points
3. It has been ported to support four architectures: ARM, ARM64, RISCV, and x86_64, among which ARM has been validated

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-28 16:38:45 +08:00
Xiang Xiao 992c8dded5 libc: Fix lib_arc4random.c:111:(.text.arc4random_buf+0x26): undefined reference to `clock_systime_ticks'
by replacing clock_systime_ticks to clock

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-28 09:23:19 +01:00
Xiang Xiao 32784b0898 libc: Refine the arc4random_buf implementation
fill the buffer with getrandom instead random pool
and move the implementation to from crypto to libc

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-26 18:04:21 -03:00
chao an c6591c0f49 driver/serial: remove return value of up_putc()
modify the prototype of up_putc(): remove the return value

The architecture code does not care about the return value of up_putc(), so removing it saves two statements:

Before:                                                    After:
de4c: e52de004  push  {lr}    @ (str lr, [sp, #-4]!)    |  de4c: e52de004  push  {lr}    @ (str lr, [sp, #-4]!)
de50: e24dd014  sub sp, sp, #20                         |  de50: e24dd014  sub sp, sp, #20
de54: e58d0004  str r0, [sp, #4]                        |  de54: e58d0004  str r0, [sp, #4]
de58: e30030f8  movw  r3, #248  @ 0xf8                  |  de58: e30030f8  movw  r3, #248  @ 0xf8
de5c: e3423000  movt  r3, #8192 @ 0x2000                |  de5c: e3423000  movt  r3, #8192 @ 0x2000
de60: e58d300c  str r3, [sp, #12]                       |  de60: e58d300c  str r3, [sp, #12]
de64: e59d1004  ldr r1, [sp, #4]                        |  de64: e59d1004  ldr r1, [sp, #4]
de68: e59d000c  ldr r0, [sp, #12]                       |  de68: e59d000c  ldr r0, [sp, #12]
de6c: ebfffe66  bl  d80c <pl011_putc>                   |  de6c: ebfffe66  bl  d80c <pl011_putc>
de70: e59d3004  ldr r3, [sp, #4]                        |  de70: e28dd014  add sp, sp, #20
de74: e1a00003  mov r0, r3                              |  de74: e49df004  pop {pc}    @ (ldr pc, [sp], #4)
de78: e28dd014  add sp, sp, #20                         |
de7c: e49df004  pop {pc}    @ (ldr pc, [sp], #4)        |

Signed-off-by: chao an <anchao@lixiang.com>
2024-10-26 13:21:29 +08:00
anjiahao f4d1f56df7 gdbstub:fix typo
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-24 08:45:21 +08:00
cuiziwei 12fd5ec472 nuttx: Add LIBSUPCXX_TOOLCHAIN to link the prebuilt library provide by toolchain.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-10-24 01:38:03 +08:00
buxiasen 5c09516a4b lib_gdbstub: fix container of
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-23 20:10:43 +08:00
cuiziwei 7e925dbeaa libxx: C++ low level library select LIBSUPCXX by default.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-10-23 20:09:16 +08:00
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