Commit graph

1818 commits

Author SHA1 Message Date
chenrun1
9138e8af01 lib_pathbuffer.c:Use atomic instead of locks
Summary:
  Use atomic_cmpxchg to ensure that in multithreaded situations, if someone releases the buffer, it can be applied for in time. And use atomic_ulong to save free_bitmap

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-12-17 09:33:50 +08:00
chao an
4c379ecc98 libs/libc: rename LIBC_MAX_PATHBUFFER to LIBC_PATHBUFFER_MAX
Unified naming style:

if LIBC_PATHBUFFER
config LIBC_PATHBUFFER_MAX
...
config LIBC_PATHBUFFER_MALLOC
...
endif # LIBC_PATHBUFFER

Signed-off-by: chao an <anchao@lixiang.com>
2024-12-17 09:33:50 +08:00
chao an
cf060b6bf2 libs/libc: add a option to disable path buffer by default
If the current platform does not require a large PATH_MAX size support and toolchain supports alloca(),
we could turn off this option to improve performance.

Signed-off-by: chao an <anchao@lixiang.com>
2024-12-17 09:33:50 +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
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
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
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
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
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
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
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
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
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
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
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
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
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