Commit graph

2124 commits

Author SHA1 Message Date
YAMAMOTO Takashi
1f65af208a libxx: Make LIBCXXABI default for sim/macOS
Fix build errors like:
https://github.com/apache/nuttx/issues/14774
2024-12-17 09:25:24 +08:00
chao an
2ccdd947a1 libc/chdir: replace heap alloc to path buffer to improve performance
realloc path buffer to avoid alloc from realpath()

Signed-off-by: chao an <anchao@lixiang.com>
2024-12-12 22:00:45 +08:00
chao an
32ab151712 libc/chdir: chdir/fchdir should not depend on environment variables
This PR will still allow basic shell operations such as cd/ls/pwd to be used even when the environment is disabled.

Signed-off-by: chao an <anchao@lixiang.com>
2024-12-11 20:35:00 +08:00
Xiang Xiao
60fb917eda Remove FAR from 32/64bit arch
since these arch doesn't distinguish between near and far pointers

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-12-05 22:55:39 +08:00
cuiziwei
ae5c7a7fd8 libcxxabi: Soft link the libcxxabi header file to nuttx/include.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-12-05 21:56:23 +08:00
zhangyuan29
dcea1b90e7 arch_atomic: only support atomic_xx and atomic64_xx function
Modify the kernel to use only atomic_xx and atomic64_xx interfaces,
avoiding the use of sizeof or typeof to determine the type of
atomic operations, thereby simplifying the kernel's atomic
interface operations.

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
2024-12-04 14:03:14 +01:00
Tiago Medicci Serrano
5456668ae8 libm/newlib: Add arch-specific source code first to CSRCS
Source code under `newlib/newlib/newlib/libm/machine/$(ARCH)/*.c`
should be added before common source code from `../../common/*.c`.
Take `newlib/newlib/newlib/libm/machine/riscv/s_fma.c` as an
example:

```

double
fma (double x, double y, double z)
{
        double result;
        asm ("fmadd.d %0, %1, %2, %3" : "=f" (result) : "f" (x), "f" (y), "f" (z));
        return result;
}

```

Note that the common `s_fma.c` will be included by the source file
directly. The order of adding the files to CSRCS matters here.

Although the CMake-based build system does not have the same build
problem of including the a source-file with the same in the wrong
order, this commit also changes the order of inclusion for CMake
too to keep it consistent.
2024-12-04 02:10:41 +08:00
wangmingrong1
893e67745b gcc/gcov: Add instrumentation function
Some functions will insert these functions:
void __gcov_execve(void)
{
}
void __gcov_execv(void)
{
}
void __gcov_fork(void)
{
}

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-12-03 23:51:12 +08:00
cuiziwei
7bc4671a76 libcxx/CMakeLists.txt: Remove unnecessary flags.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-12-02 22:44:41 +08:00
liamHowatt
0bdc9d24ab libc/puts: newline was omitted for empty string
`puts("");` did not print a newline. The standard
behavior is to print a newline even if the string
is empty.

Signed-off-by: liamHowatt <liamjmh0@gmail.com>
2024-12-01 17:58:06 +08:00
buxiasen
eca83c4a73 blk/mtdoutstream: use lib_sostream_s to support seek
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-30 03:08:35 +08:00
wangmingrong1
cdbf5c6ebe Fix compilation errors
CC:  gcov.c gcov.c: In function 'gcov_stdout_dump':
gcov.c:146:50: error: passing argument 3 of '__gcov_info_to_gcda' from incompatible pointer type [-Werror=incompatible-pointer-types]
  146 |       __gcov_info_to_gcda(info, stdout_filename, stdout_dump, NULL, &arg);
      |                                                  ^~~~~~~~~~~
      |                                                  |
      |                                                  void (*)(const void *, size_t,  void *) {aka void (*)(const void *, long unsigned int,  void *)}
In file included from gcov.c:25:
/mnt/vela/github/NX/nuttx/include/gcov.h:139:44: note: expected 'void (*)(const void *, unsigned int,  void *)' but argument is of type 'void (*)(const void *, size_t,  void *)' {aka 'void (*)(const void *, long unsigned int,  void *)'}
  139 |                                 FAR void (*dump)(FAR const void *,
      |                                     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
  140 |                                                  unsigned int, FAR void *),
      |                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~

libgcc/gcov.c: In function 'gcov_process_path.constprop':
libgcc/gcov.c:235:29: error: 'filename' may be used uninitialized [-Werror=maybe-uninitialized]
  235 |       tokens[token_count++] = filename;
      |       ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
libgcc/gcov.c:189:13: note: 'filename' was declared here
  189 |   FAR char *filename;

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-26 19:25:24 +08:00
buxiasen
3e24aab208 stream_getc: use lib_stream_eof instead of EOF
Will case scanftest break #14778, at " %4c%n" case.
scanf use INT_MAX cause EOF break.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-26 10:25:36 +08:00
Jinliang Li
f3213efc7f armv8-r/libc: optimize libc string apis with asm
Optimize libc string apis(memcpy/memset/memmove/memchr/strcmp/strlen)
with arm32 assembly instruction including vfp and neon.
Add arch releated elf parsing

Signed-off-by: Jinliang Li <lijinliang1@lixiang.com>
2024-11-26 10:22:12 +08:00
hujun5
34e79f9618 spinlock: use spin_lock_init replace spin_initialize
reason:
1: spin_lock_init and spin_initialize have similar functionalities.
2: spin_lock and spin_unlock should be called in matching pairs.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-26 00:02:44 +08:00
wangmingrong1
47e33c6433 clang/gcov: Add a way to directly dump memory address
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-25 18:03:19 +08:00
wangmingrong1
a73217d1d6 Clang/gcov: Supports gcc standard output interface "__gcov_dump"
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-25 18:03:19 +08:00
yinshengkai
0413d74f31 libs: add gcov framework support
In devices without storage media, you can export data to the
command line and then generate the corresponding gcda file

It can save the result output by calling __gcov_info_to_gcda
The usage is similar to:
https://gcc.gnu.org/onlinedocs/gcc/Freestanding-Environments.html#Profiling-and-Test-Coverage-in-Freestanding-Environments

Usage:
 ./tools/configure.sh qemu-armv7a:nsh
Modify the configuration
+CONFIG_COVERAGE_ALL=y
+CONFIG_COVERAGE_MINI=y
+CONFIG_SYSTEM_GCOV=y
Run:
qemu-system-arm -cpu cortex-a7 -nographic -smp 4 \
     -machine virt,virtualization=off,gic-version=2 \
     -net none -chardev stdio,id=con,mux=on -serial chardev:con \
     -mon chardev=con,mode=readline -kernel ./nuttx/nuttx -semihosting -s | tee gcov.txt
./nuttx/tools/gcov_convert.py -i ./gcov.txt
./nuttx/tools/gcov.sh -t arm-none-eabi-gcov

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-11-22 19:08:08 +08:00
wangmingrong1
1d04884812 gcov: Add toolchain gcov dependency option
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-21 21:32:06 +08:00
wangchen
b58eaf7bc8 lib_getifaddrs.c:set the last multi ipv6addr next pointer to be NULL
If the pointer is not set to zero, it will erroneously point to itself, resulting in an erroneous loop pointing

Signed-off-by: wangchen <wangchen41@xiaomi.com>
2024-11-21 21:31:28 +08:00
meijian
4e7f323633 net/getifaddrs: fix coverity bug
Signed-off-by: meijian <meijian@xiaomi.com>
2024-11-21 21:31:28 +08:00
meijian
884a6803d6 net/getifaddrs: Support multiple IPv6 addresses for getifaddrs
Signed-off-by: meijian <meijian@xiaomi.com>
2024-11-21 21:31:28 +08:00
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