Commit Graph

1106 Commits

Author SHA1 Message Date
Juha Niskanen
449cf4d076 getrandom: fix comment contradicting code
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2022-06-15 11:18:04 -03:00
Petro Karashchenko
02682af759 getrandom: use _NX_XXXX interface to remove cancelation point for kernel
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-06-13 22:27:19 +08:00
chao.an
644283c8ff libc/ipc: add ftok(3) support
https://man.openbsd.org/ftok.3

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-06-09 18:19:48 +03:00
Xiang Xiao
11c8f3125d sched/tls: Wrap up_info_size into tls_info_size
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-08 19:07:33 +09:00
Xiang Xiao
2707ba58d2 sched/tls: Shouldn't get tls info directly from sp in kernel space
since the stack may switch to the kernel or interrupt stack

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-08 08:56:04 +09:00
Xiang Xiao
f1236da21c fs: Make the binary(no process) mode as the default
POSIX require file system shouldn't enable the \r and \n conversion by default
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-07 20:22:26 +03:00
Xiang Xiao
df0e9da1ba libc/stdio: Support 'e'(O_CLOEXEC) in lib_mode2oflags
follow BSD and Linux convention:
https://man.openbsd.org/fopen
https://www.man7.org/linux/man-pages/man3/fopen.3.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-07 20:22:26 +03:00
Xiang Xiao
d8aa41de7b libc/stdio: Add FLAG_KEEP to avoid the duplication of (O_BINARY | O_EXCL)
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-07 20:22:26 +03:00
Xiang Xiao
49834c9151 libc/stdio: Check 'x' instead 'X' in lib_mode2oflags
follow BSD and Linux convention:
https://man.openbsd.org/fopen
https://www.man7.org/linux/man-pages/man3/fopen.3.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-07 20:22:26 +03:00
Xiang Xiao
3357b0b15f libc/stdio: Remove the unused flags(MODE_[PLUS|B|X|T) in lib_mode2oflags
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-07 20:22:26 +03:00
Xiang Xiao
5b165a2294 libc/stdio: Generate the dummy atexit and on_exit
since the compiler may generate the code call atexit automatically

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-07 20:14:34 +03:00
anjiahao
e0c3bf64a0 libc:Optimize the behavior of fwrite
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-06-07 22:28:00 +08:00
zhuyanlin
3455002ffd libc:xtensa:arch_memmove: fix warning
warning: 'SIM_CHECKS_ALIGNMENT' macro redefined
[-Wmacro-redefined] #define SIM_CHECKS_ALIGNMENT 1

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-06-07 11:09:57 +03:00
Xiang Xiao
3e32b605fe libc/tls: Make tls_get_info as the pulibc function instead up_tls_info
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-03 23:56:50 +03:00
Xiang Xiao
bd76e69f8d tls: Merge tls_xxx into pthread_keyxxx
it's always better to provide the standard api directly

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-03 23:56:50 +03:00
Xiang Xiao
c19d37adf0 libc/wchar: Call mbsnrtowcs in mbrtowc to handle the partial sequence correctly
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-03 22:25:49 +03:00
Xiang Xiao
4c34075d10 libc/wchar: Remove the unnecessary cast
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-03 22:25:49 +03:00
Xiang Xiao
406e1effed libc: Always compile ___cxa_atexit
since libsupc++ depends on it unconditionally

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-02 10:54:23 +03:00
Xiang Xiao
1a3e57fe86 libc: Remove weak_function from __aeabi_atexit
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-02 10:54:23 +03:00
Xiang Xiao
88fd6210f6 libc/wchar: Fix the minor style issue
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-31 07:59:34 +09:00
anjiahao
b88a8cf39f use rmutex inside of all repeated implementation
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-05-30 19:43:48 +08:00
Ville Juven
a54c3d13f9 sched: Remove SCHED_ATEXIT / SCHED_ONEXIT
Remove the kernel side implementations altogether. These will be
replaced by user land implementations.
2022-05-25 15:28:43 +08:00
Ville Juven
622677d4a1 libc: Implement exit, atexit, on_exit and cxa_exit on the user side
For CONFIG_BUILD_KERNEL using the sched/task/task_exithook implementation
will just not work. It calls user code with kernel privileges which is
a bit of a security issue.
2022-05-25 15:28:43 +08:00
Abdelatif Guettouche
4896623be2 build: Fix dependencies of kernel targets.
Targets build during the kernel phase did not have their dependencies
specified and thus they were not rebuilt after their dependencies have
changed, for example by changing options in menuconfig.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2022-05-24 10:45:39 +08:00
Xiang Xiao
ba6ee2a407 pthread/spinlock: Call up_testsest directly in the flat build
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-20 09:51:53 -03:00
Xiang Xiao
b39d70fe25 libxxmini: Fix error: use of undeclared identifier 'nullptr'
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-19 23:23:01 +03:00
zhuyanlin
1c977e97d2 pthread_mutexinit: fix deadcode in pthread_mutexinit
Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-05-16 10:20:52 +03:00
Xiang Xiao
51cf7ba05a Remove FAR from arm/risc-v/xtensa/sim/x86
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-15 13:55:58 +03:00
Xiang Xiao
f7f8a21486 libs: Move aeabi_atexit from libxx/ to libc/machine/arm/
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-13 00:13:03 +03:00
Ville Juven
fb1c1bfe6c libc: Rename lib_Exit lib__Exit
Naming collision with lib_exit on some systems
2022-05-12 14:24:18 +03:00
Masayuki Ishikawa
5c3d6bba6d libs: risc-v: Add R_RISCV_JAL support to arch_elf.c
Summary:
- This commit adds R_RISCV_JAL support to arch_elf.c
- The code only checks the immediate value but does not relocate it
  because it is done by the compiler.

Impact:
- None

Testing:
- Tested with rv-virt:knsh64 (not merged yet)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-05-12 10:36:03 +08:00
zhuyanlin
38f8032e31 libc:xtensa: move syscall to swint call
Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-05-11 10:48:53 +02:00
Juha Niskanen
a17bfec43d libc/string: simplify strrchr
Do not call strlen() here. Old implementation iterated
over string twice, if searched for position was at the
beginning. This commit changes strrchr() to scan string
only once, regardless of input.

Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2022-05-10 23:29:23 +08:00
Xiang Xiao
4ae7f4c1f6 libs: Move libxx_impure.cxx from libs/libxx/ to libs/libc/misc/
to fix the gcov link error:
arm-none-eabi-ld: /home/xiaoxiang/vela/prebuilts/gcc/linux/arm/bin/../lib/gcc/arm-none-eabi/10.3.1/thumb/v7e-m/nofp/libgcov.a(_gcov.o): in function `gcov_error_exit':
libgcov-driver.c:(.text+0x7c): undefined reference to `_impure_ptr'
arm-none-eabi-ld: /home/xiaoxiang/vela/prebuilts/gcc/linux/arm/bin/../lib/gcc/arm-none-eabi/10.3.1/thumb/v7e-m/nofp/libgcov.a(_gcov.o): in function `get_gcov_error_file':
libgcov-driver.c:(.text+0x1e0): undefined reference to `_impure_ptr'
arm-none-eabi-ld: /home/xiaoxiang/vela/prebuilts/gcc/linux/arm/bin/../lib/gcc/arm-none-eabi/10.3.1/thumb/v7e-m/nofp/libgcov.a(_gcov.o): in function `gcov_exit_open_gcda_file.isra.0':
libgcov-driver.c:(.text+0x660): undefined reference to `_impure_ptr'

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-06 14:43:57 -03:00
Xiang Xiao
1e0f3ba4da libc: Remove C99_BOOL8 from libs/libxx/Kconfig
since it can be detected automatically by __STDC_VERSION__

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-05 16:23:32 -03:00
Xiang Xiao
577f301a2c libc: Move cxx_initialize.c from libc/sched/ to libc/misc
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-04 08:58:43 +02:00
Xiang Xiao
b9eff677fe libc: Simplify the c++ initialization
1.Remove CXX_INITIALIZE_MACHO and CXX_INITIALIZE_SINIT
2.Merge cxx_initialize_sinit.c and cxx_initialize_macho.c into cxx_initialize.c

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-04 08:58:43 +02:00
Xiang Xiao
c1082f04d3 libxx: Make HAVE_CXXINITIALIZE workable even HAVE_CXX isn't enabled
since this infrastructure is also used in no c++ case(e.g. gcov)

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-04 08:58:43 +02:00
Xiang Xiao
4a03cab6f9 libc: Remove the redundant seek in writev
since the file position isn't changed if write return fail

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-01 10:07:36 +03:00
Xiang Xiao
c1e5ba4602 libxx: Always build libcxx with -std=c++17
since the implementation of barrier require
the aligned new which is defined in C++ 17

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-29 21:08:14 -03:00
wangbowen6
dcb440a4d9 libc/arch_atomic: add FAR to pointers.
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-04-29 15:06:11 +08:00
wangbowen6
ea164f28b8 libc/arch_atomic: add gcc legacy __sync buitins support.
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-04-29 15:06:11 +08:00
YAMAMOTO Takashi
ded4fd33c1 Implement preadv and pwritev 2022-04-28 13:40:25 +08:00
YAMAMOTO Takashi
d832df88a5 libc.csv: sort 2022-04-28 13:40:25 +08:00
wangbowen6
cbab540169 arm/arch_setjmp.S: armv6m support setjmp, longjmp
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-04-27 23:21:03 +08:00
Xiang Xiao
f4d5a23571 libc/fixedmatch: Avoid "divide by zero" error
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-23 20:15:31 +03:00
Petro Karashchenko
8f7af29d74 libs/libc/string: unify implementation across the functions
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-04-23 23:58:54 +08:00
Oki Minabe
185b1cb1b7 libc/string: strcmp/strncmp cast unsigned char
Summary:
- Cast to unsigned char for strcmp and strncmp
- strcmp and strncmp are described following by opengroup.org

  The sign of a non-zero return value shall be determined by the sign
  of the difference between the values of the first pair of bytes
  (both interpreted as type unsigned char) that differ in the strings
  being compared.

  https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcmp.html
  https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncmp.html

Impact:
- strcmp and strncmp return value

Testing:
- ostest on sabre-6quad:smp w/ qemu

Signed-off-by: Oki Minabe <minabe.oki@gmail.com>
2022-04-23 16:11:00 +03:00
Xiang Xiao
69b5799b74 libc: Fix typo error in execle
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-22 12:23:09 +03:00
Xiang Xiao
55b5561fdb sched/task: Implement execle and execve
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-22 10:40:31 +03:00