Commit Graph

1364 Commits

Author SHA1 Message Date
chao an
4fbf5f7a4b libs/libc: correct config define of arch functions
Signed-off-by: chao an <anchao@xiaomi.com>
2023-04-04 09:37:46 -03:00
chao an
3c58f5db2b syscall/libc: add more syscall/libc symbols into csv file
Signed-off-by: chao an <anchao@xiaomi.com>
2023-03-31 21:56:50 +09:00
Stuart Ianna
01b0305ab5 risc-v: SV32 MMU support for qemu-rv. 2023-03-29 22:15:19 +09:00
Fotis Panagiotopoulos
0b1ba70ac5 asprintf: Fixed possible memory leak if print fails. 2023-03-28 14:46:07 -03:00
Gregory Nutt
717bb04cb7 Increase the number of real time signals. Two is not enough.
Refer to issue #8867 for details and rational.

Convert sigset_t to an array type so that more than 32 signals can be supported.

Why not use a uin64_t?
- Using a uin32_t is more flexible if we decide to increase the number of signals beyound 64.
- 64-bit accesses are not atomic, at least not on 32-bit ARMv7-M and similar
- Keeping the base type as uint32_t does not introduce additional overhead due to padding to achieve 64-bit alignment of uin64_t
- Some architectures still supported by NuttX do not support uin64_t
  types,

Increased the number of signals to 64. This matches Linux. This will support all xsignals defined by Linux and also 32 real time signals (also like Linux).

This is is a work in progress; a draft PR that you are encouraged to comment on.
2023-03-27 16:59:04 +03:00
Petro Karashchenko
4309c6693c libc/modlib: fix indentation issue
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-03-26 09:23:50 -06:00
Xiang Xiao
beb38917d1 signal: Replace NuttX special SIGWORK with SIGPAGING(SIGRTMIN)
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-26 08:31:36 -06:00
chao an
3428d15d04 libc/math: rename libc/math.csv to libm/libm.csv
Signed-off-by: chao an <anchao@xiaomi.com>
2023-03-24 14:58:10 -03:00
Petro Karashchenko
5651715486 signal: remove unused SIGCONDTIMEDOUT
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-03-23 17:17:25 -06:00
Petro Karashchenko
a261439b8b libs/libx: relax compiler check for workaround with "GCC 12.2"
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-03-21 21:59:30 -03:00
chao an
c839fc45af libc/settimeofday: correct prototype of settimeofday()
Signed-off-by: chao an <anchao@xiaomi.com>
2023-03-21 11:16:30 -03:00
Xiang Xiao
b63994b7f7 drivers/serial: Always support c_oflag, c_iflag and c_lflag in termios
CONFIG_SERIAL_TERMIOS only decide whether to support c_cflag field since
many terminal application need the first three fields to work correctly.
For more information please reference:
https://www.mail-archive.com/dev@nuttx.apache.org/msg09321.html

before this change(olimexino-stm32:tiny):
   text    data     bss     dec     hex filename
  34884     328    1768   36980    9074 nuttx
after this change:
   text    data     bss     dec     hex filename
  35052     340    1768   37160    9128 nuttx
delta
   text    data     bss     dec     hex filename
    168      12       0     180      b4 nuttx

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-19 14:54:59 -06:00
zhangyuan21
cf56e4113a arch: remove unnecessary sem_setprotocol code
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-03-17 16:53:19 -03:00
yinshengkai
1cc3fd59ed libc/syslogstream: fix nxstyle error
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-03-13 22:24:53 +02:00
yinshengkai
ca290e85ea libc: stream adds length check
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-03-13 22:24:53 +02:00
Karel Kočí
62661600b2 treewide: add DOWNLOAD variable as unification of curl call
This is a followup to the commit
03b164f59c.
2023-03-08 17:05:05 +08:00
yinshengkai
81a4f21f1b libc/libvsprintf: use puts to replace the putc
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-03-08 16:56:17 +08:00
yinshengkai
b8e622ea5d libc/stream: unify stream behavior
Return the error code when all gets occur when an error is wrong
and return immediately when obtaining any valid data

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-03-04 01:48:22 +08:00
yinshengkai
205ca26556 libc/streams: Implement gets/puts for all streams
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-03-03 00:49:04 +08:00
Huang Qi
dfc70b1ddb libc/stdio: Implement lib_get_stream
Use lib_get_stream() to fetch stdin/stdout/stderr,
since is more easy to works with other language by function call
than export native C structure memory layout.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-03-02 09:56:57 +01:00
Huang Qi
b99a96a7d0 stream: Exchange name of lib_rawsostream.c and lib_rawoutstream.c
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-03-01 10:07:36 -03:00
Huang Qi
b96035885a stdio: Implement simple buffered out stream for vdprintf
Improve performance for raw fd based printf like operation.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-03-01 13:08:59 +09:00
YAMAMOTO Takashi
e9158efd42 libcxx.defs: Disable a warning and explain why 2023-02-27 23:55:52 +08:00
Xiang Xiao
2c5f653bfd Remove the tail spaces from all files except Documentation
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-26 13:24:24 -08:00
yinshengkai
8d16fa04df libc/stream: Implement lowoutstream_puts
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-02-25 18:39:27 +08:00
chenrun1
4f3c73fb45 libc/lib_bzero:Add bzero prototype.
Implement the bzero function as an alternative to macro expansion.
2023-02-25 08:07:07 +02:00
lilei19
38f64f559d change strcpy to strlcpy
Signed-off-by: lilei19 <lilei19@xiaomi.com>
2023-02-24 12:15:40 +08:00
Xiang Xiao
68ff73c5fb stdio: lib_fgets convert \r\n to \n
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-24 10:39:48 +08:00
Xiang Xiao
cd74a1df22 libc/stdio: Make gets/gets_s work without CONFIG_FILE_STREAM
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-24 10:39:48 +08:00
chenrun1
5430de72f8 libc/lib_rawmemchr.c:Add rawmemchr methon. 2023-02-24 04:06:04 +08:00
Huang Qi
ca61c40453 stdio: Remove CONFIG_EOL_IS_XXX
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-02-24 00:35:19 +08:00
Xiang Xiao
8b4ecac6c2 libc: Move math library from libs/libc/math to libs/libm/libm
to prepare the support of other implementation e.g.:
https://github.com/JuliaMath/openlibm
https://gitlab.com/gtd-gmbh/libmcs

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-23 10:40:07 +02:00
chao an
0f8ecc0150 libs/libc: export exit() if configured in flat mode
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-23 13:50:03 +08:00
Xiang Xiao
a05ab2ab49 libc: Remove dependence of LIBC_FLOATINGPOINT and LIBC_LONG_LONG from LIBC_NUMBERED_ARGS
since LIBC_NUMBERED_ARGS can work without both

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-22 16:37:48 +08:00
lilei19
e6e2017d3c fix a bug of strtof 2023-02-22 01:20:21 +08:00
Ville Juven
f8d3032732 libc/lib_assert.c: Remove the re-definition of abort()
This should now be irrelevant, as abort() is forwarded to _exit() instead.
2023-02-22 01:10:39 +08:00
Ville Juven
07039b8a36 lib_abort.c: Change call to userspace exit() into syscall _exit()
The POSIX standard dictates that during abnormal termination the functions
registered by atexit() are _not_ called, also flushing the streams is
optional. So in this case, it is perfectly legal / better to call the
kernel system call _exit() instead.

This fixes regression issues caused by removal exit() from the kernel.
2023-02-22 01:10:39 +08:00
chao an
5fac313df7 libs/libxx: Fix typo in shell expressions
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-22 01:05:46 +08:00
chao an
1d41182755 libs/libxx: check GCC version before set special flags
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-21 15:33:18 +08:00
chao an
e29d275ef8 libs/libcxx: Workaround -Wmaybe-uninitialized warning with "GCC 12.2"
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-20 19:26:55 +08:00
Xiang Xiao
fa3e0faffc fs: Map FD_SETSIZE to OPEN_MAX instead hardcoding 256
and change the default value of LIBC_OPEN_MAX to 256.
Here has more discussion:
https://www.mail-archive.com/dev@nuttx.apache.org/msg09095.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-19 19:17:20 +02:00
Ville Juven
e9ef70e24b sched/assert: Call abort() instead of exit() in assert
POSIX dictates that assert() terminates via abort(), even though in NuttX
abort() just calls exit(EXIT_FAILURE) it is better to use the correct
API here, if at some point a proper implementation for abort() is made.

Also, as the kernel must not use abort() which is a userspace API, direct
the exit to PANIC() if for some reason _assert() returns (it should not
but trap it here just in case).
2023-02-17 23:07:17 +08:00
Ville Juven
df1d7dd480 libc/exit: Purge calls to userspace API exit() from kernel
Remove calls to the userspace API exit() from the kernel. The problem
with doing such calls is that the exit functions are called with kernel
mode privileges which is a big security no-no.
2023-02-17 23:07:17 +08:00
Fotis Panagiotopoulos
85ceb7920e Typo fixes. 2023-02-17 11:17:11 -03:00
Takeyoshi Kikuchi
70ce4b4fc1 libc: unistd: lib_getrlimit: set cur/max value for RLIMIT_NOFILE to "OPEN_MAX".
Signed-off-by: Takeyoshi Kikuchi <kikuchi@centurysys.co.jp>
2023-02-17 18:07:30 +08:00
Takeyoshi Kikuchi
c4fc414b09 libc: unistd: lib_getrlimit: use INT_MAX as dummy rlim_max value.
Signed-off-by: Takeyoshi Kikuchi <kikuchi@centurysys.co.jp>
2023-02-17 18:07:30 +08:00
Takeyoshi Kikuchi
2e5a20612c libc: unistd: lib_getrlimit: return a value for RLIMIT_NOFILE request.
In the Nim language "selectors"(I/O multiplexing) module, the maximum
number of file descriptors is obtained with getrlimit() as follows.

        var fdLim: RLimit
        var res = int(getrlimit(RLIMIT_NOFILE, fdLim))
        if res >= 0:
          res = int(fdLim.rlim_cur) - 1

To be able to use the same implementation as other POSIX-based OS,
getrlimit() should return a value.
(For now, let it return 128.)

Signed-off-by: Takeyoshi Kikuchi <kikuchi@centurysys.co.jp>
2023-02-17 18:07:30 +08:00
crafcat7
33b22f51da libc/lib_memcpy.c: Add mempcpy method.
Signed-off-by: crafcat7 <chenrun1@xiaomi.com>
2023-02-17 15:15:19 +08:00
Nathan Hartman
409e2f3701 drivers/serial, libc/termios: Implement tcsendbreak
The TERMIOS(3) function tcsendbreak() and the IOCTLs TCSBRK and TCSBRKP
transmit a serial line Break.

Previously NuttX included an extern declaration for tcsendbreak() and
defines for TCSBRK and TCSBRKP but none of these were implemented.
Attempting to build programs that called tcsendbreak() would fail with
a linker error; attempting to use TCSBRK and TCSBRKP would result in an
error at runtime.

This changeset adds the tcsendbreak() function and handling for TCSBRK
and TCSBRKP; tcsendbreak() is implemented in terms of TCSBRK. Both
TCSBRK and TCSBRKP are implemented in terms of the BSD-compatible Break
IOCTLs TIOCSBRK and TIOCCBRK, which must be provided by the lower half
serial driver. Currently, not all lower half serial drivers in NuttX
support these IOCTLs. Those that do implement them may need one or more
Kconfig options to be set, such as `CONFIG_*_U[S]ART_BREAKS` and, on
some architectures, a separate `CONFIG_*_SERIALBRK_BSDCOMPAT`.

* drivers/serial/serial.c
  (uart_tcsendbreak): New function.
  (uart_ioctl): Implement TCSBRK and TCSBRKP.

* libs/libc/termios/lib_tcsendbreak.c
  (): New file.

* libs/libc/termios/Make.defs
  (CSRCS): Add lib_tcsendbreak.c to the build.

Thanks to Xiang Xiao for PR feedback.

Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>
2023-02-15 07:50:02 +08:00
Xiang Xiao
dc2e9b8771 libc: Move memfd related stuff to sys/mman.h
follow the freebsd definition:
https://github.com/freebsd/freebsd-src/blob/master/sys/sys/mman.h#L207-L228

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-13 16:00:37 +01:00