Commit graph

2152 commits

Author SHA1 Message Date
cuiziwei
58f226d2b5 libcxxmini: Add missing runtime related classes.
reference:https://github.com/libcxxrt/libcxxrt/tree/master/src

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-11-21 20:03:15 +08:00
hujun5
12cd59b3e6 arch_atomic: use small lock in libs/libc/machine/arch_atomic.c
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-21 16:35:29 +08:00
simbit18
7df0e945ad Fix Kconfig style
Remove spaces from Kconfig files
Add TABs
Replace help => ---help---
Remove extra TABs
Add comments
2024-11-20 16:45:40 -03:00
haopengxiang
8c4e88fd4b add dir ignored since we changed libxx layout
Signed-off-by: haopengxiang <haopengxiang@xiaomi.com>
2024-11-17 08:31:08 -03:00
chenrun1
f9647b4e2f lib_pathbuffer: change nxmutex -> spinlock
Summary:
_assert
|
 ->dump_fatal_info
   |
    ->dump_tasks
      |
       ->dump_filelist
         |
          ->files_dumplist
            |
             ->lib_get_pathbuffer
               |
                ->nxmutex_lock      <-- hold mutex on assert will trigger an nested exception

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-11-16 01:55:45 +08:00
hujun5
dcc75048be Revert "system: pthread_barrierwait should be moved to kernel space"
reason:
new implementation does not requires the use of enter_critical_section,
so the source code needs to be moved to user space

This reverts commit d189a86a35.
2024-11-15 22:07:25 +08:00
chao an
238cddde3a drivers/syslog: remove implement of syslog_putc()
syslog_putc() have a lot of duplicate logic with syslog_write().
remove syslog_putc() and reuse syslog_write() to simplify syslog printing.

Signed-off-by: chao an <anchao@lixiang.com>
2024-11-15 19:46:36 +08:00
hujun5
19b4911d7f arch: remove up_current_regs in common code
reason:

When entering an exception or interrupt, there are two sets of registers:
one is the "running regs", which we need to save,
and the other is the "ready to running regs", which we may soon use.
For consistency in logic, we can always store the "running regs" in the regs field of g_running_tasks,
otherwise it may lead to errors in the storage location of the "running regs."

When we need to access the "running regs," we should uniformly retrieve them from the regs field of g_running_tasks.

As the next step, we will rename the set_current_regs/up_current_regs functions
for each architecture to more appropriate names, solely for the purpose of identifying interrupts.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-15 18:25:35 +08:00
hujun5
7ba0f11d70 pthread: remove enter_critical_section in pthread_barrier_wait
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-15 14:03:03 +08:00
xuxingliang
370eefb491 libc/misc: do not sanitize backtrace_format
We could call backtrace from mm module and access to kasan protected mm_node.backtrace field. Disable kasan check for backtrace_format.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-15 14:02:33 +08:00
Takuya Miyasita
2275138dcf arch_atomic : Introduce CONFIG_LIBC_ARCH_ATOMIC
Some armv7-m-based SoCs do not work with atomic instructions,
even though armv7-m supports them.

To avoid using atomic instructions generated by gcc,
CONFIG_LIBC_ARCH_ATOMIC is newly introduced with which
arch_atomic.c is linked explicitly.

However, the function names need to be changed to avoid
build errors, since the functions described in stdatomic.h
are gcc built-in and inlined when the code is compiled.

About libcxx with CONFIG_LIBC_ARCH_ATOMIC, it still
does not work. It is also needed to call nx_atomic_ ver
instead of __atomic ver in
libcxx/include/__atomic/cxx_atomic_lmpl.h.

Signed-off-by: Takuya Miyasita <Takuya.Miyashita@sony.com>
2024-11-15 14:01:56 +08:00
wangmingrong1
17ce9b86c1 gcov: Correct existing gcov configuration
1. add CONFIG_COVERAGE_ALL to replace CONFIG_SCHED_GCOV_ALL
2. Correct all SCHED_GCOV, SCHED_GCOV_ALL

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-15 01:05:16 +08:00
wangmingrong1
181f461145 libbuiltin/kconfig: Modify coverage function dependencies
Currently, there are four code coverage statistics implementations:
1. GCC native implementation
2. CLANG native implementation
3. GCC coverage nuttx mini version
4. CLANG coverage nuttx mini version
Coverage Support:
                                               GCC native implementation  CLANG native implementation  GCC coverage nuttx mini version  CLANG coverage nuttx mini version
Compiler version requirements                              ALL                       ALL                         GCC 13.2 and below             CLANG 17.0 and below
Program coverage statistics support   Main program          √                         √                                  √                               √
Program coverage statistics support   Interrupt program     X                         √                                  √                               √
Configuration options                         CONFIG_COVERAGE_TOOLCHAIN    CONFIG_COVERAGE_COMPILER_RT          CONFIG_COVERAGE_MINI            CONFIG_COVERAGE_MINI
Platform Support            ARM                             √                         √                                  √                               √
                            ARM64                           √                                                            √
                                                                                                            (Coming soon, not yet merged)

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-15 01:05:16 +08:00
buxiasen
a5459cdaca stream: reduce int use, handle FS_LARGEFILE correctly.
offset int -> offset, len int -> size_t, ret int -> ssize_t

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-15 01:05:04 +08:00
buxiasen
2433094ebd blk/mtdoutstream: remove mtd bytewrite support, readback before update
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-15 01:05:04 +08:00
buxiasen
d6c746e88d blk/mtdoutstream: flush before close
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-15 01:05:04 +08:00
hujun5
ea20ae588a pthread_cond_broadcast use wait_count for judement
This commit fixes the comment from https://github.com/apache/nuttx/pull/14581

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-14 23:22:52 +08:00
anjiahao
5aac6684f4 gdbstub:typo fix
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-14 22:48:55 +08:00
haopengxiang
5ffdf5b264 cmake(bugfix):fix libcxxabi layout build error
/home/data/vela/github/nuttx/libs/libxx/libcxxabi/libcxxabi/src/cxa_exception.h:47:10: error: 'unexpected_handler' in namespace 'std' does not name a type
   47 |     std::unexpected_handler unexpectedHandler;
      |          ^~~~~~~~~~~~~~~~~~
/home/data/vela/github/nuttx/libs/libxx/libcxxabi/libcxxabi/src/cxa_exception.h:85:10: error: 'unexpected_handler' in namespace 'std' does not name a type
   85 |     std::unexpected_handler unexpectedHandler;
      |          ^~~~~~~~~~~~~~~~~~
/home/data/vela/github/nuttx/libs/libxx/libcxxabi/libcxxabi/src/cxa_exception.h:121:65: error: static assertion failed: propagationCount has wrong negative offset
  121 |                       sizeof(_Unwind_Exception) + sizeof(void*) ==
      |                                                                 ^
/home/data/vela/github/nuttx/libs/libxx/libcxxabi/libcxxabi/src/cxa_exception.h:121:65: note: the comparison reduces to '(124 == 128)'
/home/data/vela/github/nuttx/libs/libxx/libcxxabi/libcxxabi/src/cxa_exception.h:125:65: error: static assertion failed: propagationCount has wrong negative offset
  125 |                       sizeof(_Unwind_Exception) + sizeof(void*) ==
      |

/home/data/vela/github/nuttx/libs/libxx/libcxxabi/libcxxabi/src/cxa_default_handlers.cpp:20:10: fatal error: include/atomic_support.h: No such file or directory
   20 | #include "include/atomic_support.h" // from libc++
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-11-14 19:39:38 +08:00
ligd
9026ba6883 libm: fix typo caused compile failed
make[1]: Entering directory '/home/ligd/platform/trunk_merge_all/nuttx/libs/libm'
Makefile:93: *** target file 'context' has both : and :: entries.  Stop.
make[1]: Leaving directory '/home/ligd/platform/trunk_merge_all/nuttx/libs/libm'

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-11-14 19:38:58 +08:00
wangmingrong1
c19d440db0 arm64/mcount.c: Add to nuttx compilation
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-14 13:30:05 +08:00
Huang Qi
064b94bb6d libc/libc.csv: Fix signature of getpass
Add missing parameter type to getpass signature,
and add missing const qualifier to the return value.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-11-13 12:38:14 +08:00
Masayuki Ishikawa
bbf2bbf37d Revert "arch_atomic : Introduce CONFIG_LIBC_ARCH_ATOMIC"
This reverts commit 81e7b13a05.
2024-11-13 10:45:12 +09:00
wangmingrong1
b59e3616f4 gcov: Support for the most streamlined profile of LLVM-embedded-toolchain-for-Arm
1. Excerpted from: https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/blob/main/samples/src/cpp-baremetal-semihosting-prof/proflib.c
2. Since llvm profile supports more than just gcov, and some features have not yet been explored, two clang gcov implementations are supported after this patch
3. Using this lib only supports the gcov compilation options of "-fprofile-instr-generate -fcoverage-mapping"
4. This file is heavily dependent on the compiler clang version, and is currently aligned with ci, supporting 17.0.1 and below. 18 and above are not supported by this library due to different internal implementations of the compiler

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-13 05:33:00 +08:00
wangmingrong1
bf93c7840a gprof: move gprof function from sched to libbuiltin/libgcc
1. Enable interrupt gprof please config CONFIG_PROFILE_MINI
2. Enable instuction gprof please add compile opt "-pg" or config CONFIG_PROFILE_ALL

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-13 02:42:31 +08:00
anjiahao
c62b35a12c modlib:need add ctors to init_array and dtors to fini_array
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-12 18:48:33 +08:00
chenrun1
2b190de9d1 lib_pathbuffer:change ffs to ffsl
Summary:
  Avoid error
riscv-none-elf-ld: /github/workspace/sources/nuttx/staging/libc.a(lib_pathbuffer.o): in function `lib_get_pathbuffer':
/github/workspace/sources/nuttx/libs/libc/misc/lib_pathbuffer.c:89:(.text.lib_get_pathbuffer+0x1c): undefined reference to `ffs'
make[1]: *** [Makefile:189: nuttx] Error 1
make: *** [tools/Unix.mk:551: nuttx] Error 2

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-11-12 17:21:42 +08:00
zhangshoukui
50e89a54cb fix compile warning
libs/libc/locale/lib_catalog.c:197:9: warning: implicit declaration of function ‘lib_get_pathbuffer’ [-Wimplicit-function-declaration]
  197 |   buf = lib_get_pathbuffer();
      |         ^~~~~~~~~~~~~~~~~~
libs/libc/locale/lib_catalog.c:197:7: warning: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  197 |   buf = lib_get_pathbuffer();
      |       ^
libs/libc/locale/lib_catalog.c:294:13: warning: implicit declaration of function ‘lib_put_pathbuffer’ [-Wimplicit-function-declaration]
  294 |             lib_put_pathbuffer(buf);

Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2024-11-12 17:21:42 +08:00
chenrun1
2cf26036a5 Use lib_get_pathbuffer instead of stack variables
Summary:
  Modified the usage logic, mainly introduced lib_get_pathbuffer and lib_put_pathbuffer

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-11-12 17:21:42 +08:00
wangmingrong1
9facfade90 compiler_rt/cmake: Align compiler-rt/Make.defs
1. Remove unnecessary compilation options
2. Use * instead of examples one by one

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-12 16:12:53 +08:00
wangmingrong1
4232a717f2 libbuilin/compiler_rt: Organize make.defs and eliminate compilation warnings
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-12 16:12:53 +08:00
wangmingrong1
e3917e2f09 libbuitin/compiler_rt: Supports separate builtin rt.builtins or rt.profile
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-12 16:12:53 +08:00
Takuya Miyasita
81e7b13a05 arch_atomic : Introduce CONFIG_LIBC_ARCH_ATOMIC
Some armv7-m-based SoCs do not work with atomic instructions,
even though armv7-m supports them.

To avoid using atomic instructions generated by gcc,
CONFIG_LIBC_ARCH_ATOMIC is newly introduced with which
arch_atomic.c is linked explicitly.

However, the function names need to be changed to avoid
build errors, since the functions described in stdatomic.h
are gcc built-in and inlined when the code is compiled.

Signed-off-by: Takuya Miyasita <Takuya.Miyashita@sony.com>
2024-11-12 14:27:42 +09:00
wangmingrong1
f59edf8645 libbuiltin/Makefile: Modify the libbuiltin makefile to standard
1. bin and kbin folders are dynamically generated
2. Context comes before depend, so the bin and kbin folders are created in the context construction phase. When the depend process comes, each library is downloaded, and a relative bin/xxx and kbin/xxx directory is created for each library to place files. This is to prevent duplicate file names.

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-10 10:19:58 +08:00
wangmingrong1
6dd313939f makefile/build: Delete unnecessary bin and kbin folders
1. Calling CLEAN on these folders did not have any effect
2. bin,kbin will be created during the context construction process

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-10 01:18:26 +08:00
ba2ad819da libs/uClibc++: Fix the Download URL for uClibc++ (CMake)
The SSL Cert for git.busybox.net has just expired today. This PR switches the uClibc++ download to cxx.uclibc.org for CMake.
2024-11-08 15:14:44 -03:00
7db028d095 libs/uClibc++: Fix the Download URL for uClibc++
The SSL Cert for git.busybox.net has just expired today. This PR switches the uClibc++ download to cxx.uclibc.org.
2024-11-08 15:13:34 -03:00
wangmingrong1
db31e56957 libxx: All cxx libraries move down one level
Since there are some patches that need to be loaded manually, the original method is rather confusing. Now these patches that need to be loaded manually are classified into various cxx library folders, and each dynamically downloaded cxx library is moved down one directory to make the directory structure clearer.

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-08 01:50:37 +08:00
wangmingrong1
4ba941e2b0 libbuiltin: Simplify makefile writing
Create a separate bin folder to place the generated .o files

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-07 01:13:25 +08:00
hujun5
c498991ba4 smpcall: add nxsched_smp_call_async and nxsched_smp_call_single_async
reason:
The old implementation of the SMP call, even when using the "no wait" parameter,
could still result in waiting, if invoking it within a critical section
may lead to deadlocks. Therefore, in order to implement a truly asynchronous SMP
call strategy, we have added nxsched_smp_call_async.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-06 09:53:28 +08:00
cuiziwei
f1d180d56e nuttx/sim: Remove math.h in sim.
The reason for removing math.h is that undefining __GLIBC__ does not take effect. By default, sim will use the toolchain's math library and undef __GLIBC__ in the source file.

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-11-06 02:56:24 +08:00
wangmingrong1
f2c46e08c8 Remove all jira and changeid information from the kernel
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-06 02:04:03 +08:00
Tiago Medicci Serrano
f6a72ad0f4 libs/modlib: Load data using up_textheap_data_address
Some chips have different memory addressing spaces for the same
region. This is true, for instance, for ESP32-S3: the same memory
region can be accessed using the data bus or the data bus using
different address ranges. The instruction bus, however, requires
word-aligned access. That being said, it is recommended to use the
data bus while copying sections to the text heap to avoid any
illegal access using the instruction bus address which will be
later used to run the program.
2024-11-05 02:42:03 +08:00
Peter van der Perk
c371afc7f4 net: inet.h match inet_sockif.c definition
Fixes psock_socket: ERROR: socket address family unsupported: 2
When using the minimal CONFIG_NET configuration typically used for
SocketCAN

Update net/inet/inet.h

Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>

Update net/inet/inet.h

Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>
2024-11-05 01:58:45 +08:00
Xiang Xiao
11960fd8e7 libc/mtdoutstream: Fix the in insufficient erase in byte write case
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-11-04 08:37:31 +08:00
Xiang Xiao
cccc413cb9 libc/mtdoutstream: Remove the redundant check and compute
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-11-04 08:37:31 +08:00
Xiang Xiao
1e343a884b libc/mtdoutstream: Replace stream->geo.erasesize with erasesize
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-11-04 08:37:31 +08:00
Xiang Xiao
fa57289d68 libc/blkoutstream: Zero the cache to avoid random data
and skip zero cache in lib_mtdoutstream_open since it's aleady done ih mtdoutstream_puts

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-11-04 08:37:31 +08:00
Xiang Xiao
00529f1626 libc/blkoutstream: Remove the redundant check and compute
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-11-04 08:37:31 +08:00
Xiang Xiao
9f1af300cb libc/blkoutstream: Replace stream->geo.geo_sectorsize with sectorsize
and sblock with sector to make the code more readable.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-11-04 08:37:31 +08:00
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