Xiang Xiao
e26d8759d0
libc: Remove CONFIG_LIBC_ERR
...
let linker remove the unused object files from the final image
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-08-08 07:39:59 -04:00
Peter van der Perk
f64677b8c9
Add Embedded Template Library (ETL) support
2022-08-05 09:38:48 +08:00
Nathan Hartman
20bdd44e7b
Remove executable permission from source and build files.
2022-08-04 12:48:18 -03:00
liyi25
1141ee28e9
delay creating DNS bind socket
...
Signed-off-by: liyi <liyi25@xiaomi.com>
2022-08-03 23:43:48 +08:00
Peter van der Perk
013a562478
Net thread-safe ntoa functions
...
Apply suggestions from code review
Co-authored-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-08-02 21:04:19 +08:00
chao.an
ca24efff80
libs/libc: correct config name
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-07-27 20:18:05 +08:00
Xiang Xiao
0f7da4fd75
libc: Remove the unnecessary include from wchar and wctype
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-07-27 10:55:37 +03:00
Jiuzhu Dong
673a2e0136
libc/wchar: support wchar
...
Implemented according to https://en.wikipedia.org/wiki/UTF-8
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-07-27 00:36:49 +08:00
Jiuzhu Dong
035840a770
libc/wchar: remove unnecessary config
...
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-07-27 00:36:49 +08:00
Masayuki Ishikawa
2ce12617a1
libs: spawn: Add forkaround for posix_spawn_file_actions_adddup2()
...
Summary:
- I noticed that adb shell failed when sh is spawned.
- Finally, I found that an error happened when executing dup2() action
if the file descriptor has the O_CLOEXEC option.
- This commit fixes this issue by dropping the option in the API.
Impact:
- posix_spawn_file_actions_adddup2() only
Testing:
- adbd with sabre-6quad:netnsh (will be merged later)
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-07-26 16:04:21 +08:00
Karel Kočí
6c7f99189b
libs/libc/string: add memmem
...
This function is the GNU extension.
2022-07-22 19:04:11 +03:00
Xiang Xiao
4e92e32d7b
libc/impure: Fix the inconsistence from the different toolchain
...
some toolchain provider remove const qualifier from global_impure_ptr
(e.g. Espressif) but other provider keep it(e.g. ARM or Cadence), so
let's define const to empty macro to pass the compile and more safety.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-07-22 11:02:48 +03:00
ligd
3db8c2b6a6
stdio: need also flush stdio when flushall
...
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 01:46:21 +03:00
Xiang Xiao
1d43b4a4eb
libc/stdio: Enable LIBC_FLOATINGPOINT by default if ARCH_FPU is enabled
...
and DEFAULT_SMALL is false
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-07-21 09:53:09 -04:00
Xiang Xiao
63cb11cc72
libc/stdio: Support "long long" type if CONFIG_HAVE_LONG_LONG is enabled
...
but just format the low 32bits if CONFIG_LIBC_LONG_LONG isn't enabled to
avoid to expand the code space to much.
Note: the size will increase 192 bytes on stm32_tiny:nsh.
Before the change:
text data bss dec hex filename
41444 184 1656 43284 a914 nuttx
After the change:
text data bss dec hex filename
41636 184 1656 43476 a9d4 nuttx
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-07-20 18:06:29 +03:00
Xiang Xiao
f9e3ef3464
Revert "libc/stdio: enable long long formating by CONFIG_HAVE_LONG_LONG"
...
This reverts commit b1c72c023c
.
2022-07-20 18:06:29 +03:00
Xiang Xiao
2166c98809
Add printflike and scanflike to all printf/scanf like functions
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-07-18 14:14:36 +03:00
Gustavo Henrique Nihei
9b0e3ae9d2
libs: Convert DEBUGASSERT(false) into more intuitive DEBUGPANIC()
...
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2022-07-14 12:08:45 +08:00
Xiang Xiao
b1c72c023c
libc/stdio: enable long long formating by CONFIG_HAVE_LONG_LONG
...
and remove CONFIG_LIBC_LONG_LONG option to simplify the usage.
note: the size will increase 668
before change:
text data bss dec hex filename
168440 348 4480 173268 2a4d4 nuttx
after change:
text data bss dec hex filename
169108 348 4480 173936 2a770 nuttx
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-07-13 09:50:38 -03:00
Nathan Hartman
1867bc2210
Fix compiler warnings (-Wunused-parameter) in various functions
...
Fixes the -Wunused-parameter warning in:
* group/group_signal.c: group_signal()
* irq/irq_unexpectedisr.c: irq_unexpected_isr()
* task/task_spawn.c: nxtask_spawn_proxy()
* timer/timer_getoverrun.c: timer_getoverrun()
* misc/dev_null.c: devnull_read(), devnull_write(), devnull_poll()
* misc/dev_zero.c: devzero_read(), devzero_write(), devzero_poll()
* syslog/syslog_channel.c: syslog_default_write()
* syslog/syslog_device.c: syslog_dev_flush()
* grp/lib_initgroups.c: initgroups()
* misc/lib_mknod.c: mknod()
* misc/lib_glob.c: ignore_err()
* pthread/pthread_barrierinit.c: pthread_barrier_init()
* pthread/pthread_atfork.c: pthread_atfork()
* semaphore/sem_init.c: nxsem_init()
* stream/lib_nullinstream.c: nullinstream_getc()
* stream/lib_nulloutstream.c: nulloutstream_putc()
* stream/lib_libnoflush.c: lib_noflush()
* stream/lib_libsnoflush.c: lib_snoflush()
* string/lib_strerror.c: strerror()
* time/lib_gettimeofday.c: gettimeofday()
* time/lib_settimeofday.c: settimeofday()
* unistd/lib_pathconf.c: fpathconf(), pathconf()
* unistd/lib_getrusage.c: getrusage()
* unistd/lib_setrlimit.c: setrlimit()
* unistd/lib_getrlimit.c: getrlimit()
* unistd/lib_setpriority.c: setpriority()
2022-07-12 11:42:34 +08:00
Nathan Hartman
849f760b77
Fix various typos
2022-07-08 02:15:54 +08:00
Nathan Hartman
bf91047f33
libc: Fix getrandom() bug: Didn't propagate read error
...
* libs/libc/misc/lib_getrandom.c, in function getrandom():
We were assigning the return value of _NX_READ() to nbytes, a
variable of the unsigned type size_t. Note that _NX_READ() resolves
to either read() or nx_read(), both of which return the signed type
ssize_t to indicate either the number of bytes read successfully
(>= 0) or an error (< 0). Then we were testing for a negative
size_t value, a condition that can never occur. The end result is
that if an error occured in _NX_READ(), it would never be detected
and getrandom() would return some large positive value. This bug is
corrected by assigning the return value of _NX_READ() to a new local
variable, ret, of size ssize_t.
2022-07-01 11:51:53 +08:00
Gustavo Henrique Nihei
470287fe5c
libs: Remove "0x" prefix preceding "%p" specifier on format string
...
The "p" format specifier already prepends the pointer address with
"0x" when printing.
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2022-06-30 22:08:58 +03:00
Nimish Telang
903a186304
Use builtins for byteswapping
...
Make use of XCHG/BSWAP on x86, REV16 and REV on ARMv6-m and above,
and whatever other optimized instructions on other platforms.
Defines extra CONFIG variables, and removes the unused functions for
endian-swapping. Fixes some oversights in using the macros.
2022-06-29 11:32:59 +08:00
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