Fotis Panagiotopoulos
098b7bbfb3
Fixes in asprintf usage.
2023-04-19 02:48:39 +08:00
Fotis Panagiotopoulos
0b1ba70ac5
asprintf: Fixed possible memory leak if print fails.
2023-03-28 14:46:07 -03: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
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
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
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
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
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
dongjiuzhu1
14f8a6c2dd
fs: support openat/fchmodat/mkfifoat/fstatat/...at api
...
Refs to:
https://linux.die.net/man/2/openat
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-02-07 03:45:38 +08:00
yinshengkai
35ae47788b
libc: Keep printf("%pS", p) behavior consistent
...
When ALLSYMS is not turned on, %pS will be treated as %p
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-02-03 09:19:06 +02:00
Gustavo Henrique Nihei
e6b204f438
nuttx: Use MIN/MAX definitions from "sys/param.h"
...
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2023-02-01 23:47:44 +08:00
Huang Qi
4caf24a00c
libc/stdio: Minor comments fix
...
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-02-01 21:47:30 +08:00
wangxuedong
ba016eb5eb
libc/stdio: fix rounding errors for fractional values less than 1
...
Signed-off-by: wangxuedong <wangxuedong@xiaomi.com>
2023-01-30 23:39:56 +08:00
Ville Juven
2ed51d026c
fs/streams: Move the file streams from the group structure into TLS
...
This is preparation for flushing streams from user space, like it should
be done.
- Move tg_streamlist (group, kernel space) ->
ta_streamlist (TLS, user space)
- Access stream list via tg_info in kernel
- Access stream list via TLS in user space
- Remove / rename nxsched_get_streams -> lib_getstreams
- Remove system call for nxsched_get_streams
2022-12-22 20:16:11 +08:00
Petro Karashchenko
b107e4f417
nuttx: unify MIN, MAX and ABS macro definition across the code
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-12-21 09:31:28 +08:00
Xiang Xiao
fd0d6a9bf5
compiler.h: Add _ between format|printf|syslog|scanf|strftime and like
...
align with other macro naming style
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-21 01:05:19 +02:00
Xiang Xiao
055f1f33eb
libc/stream: Rename [lib_stream_](put|get) to [lib_stream_](putc|getc)
...
to make the naming style consistent with each other
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-05 14:27:55 +01:00
jihandong
965566d2e8
libc/stdio: add total_len back
...
"The number of characters written if successful or negative value if an error occurred.
If the resulting string gets truncated due to buf_size limit, function returns the total
number of characters (not including the terminating null-byte) which would have been written,
if the limit was not imposed." --- https://en.cppreference.com/w/c/io/vfprintf
Signed-off-by: jihandong <jihandong@xiaomi.com>
2022-12-04 17:27:49 +08:00
flyingfish89
bb040befee
optimize the code of the printf
2022-11-29 17:27:02 +08:00
Xiang Xiao
7c7ab96b53
libc/stdio: Remove putc macro from lib_libvsprintf.c
...
call lib_stream_put directly instead
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-27 22:59:21 +01:00
Xiang Xiao
7568a0df22
libc/stdio: Don't count the output length repeatly in vsprintf_internal
...
let's reuse the counting from lib_outstream_s::nput instead
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-27 22:59:21 +01:00
Xiang Xiao
33e35c6ce3
libc/stdio: Don't set FL_[LONG|SHORT] repeatly in vsprintf_internal
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-27 22:59:21 +01:00
Xiang Xiao
df6666ab5e
libc/stream: Rename lib_stream_[put|get]c to lib_stream_[put|get]
...
keep the macro consistent with the callback name
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-27 22:59:21 +01:00
yinshengkai
377bf97613
stream: replace the stream function pointer with a macro
...
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2022-11-25 21:41:51 +08:00
flyingfish89
4b87a8b079
lib_libvsprintf: fix the float point print bug
...
such as code: double value = +0x1.000000000000080000000000p-600;
printf("Hello, World!! %.7g:f64\n", value);
expected output : Hello, World!! 2.40992e-181:f64
but real output : Hello, World!! 2.40992e-B1:f64
the reason: we want printf "18", but the flag of character is 'B'
and 'B' is '0'+18,so printf 'B';
2022-11-24 12:02:03 -03:00
Xiang Xiao
898093a822
libc/stdio: Remove the one line mutex wrapper
...
and call nxmutex api directly
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-09 21:38:10 +01:00
Miguel Herranz
819ebe7356
libc/stdio: Add stdio file locking functions
...
Add flockfile(), ftrylockfile() and funlockfile() functions [1].
[1] POSIX.1-2008 / System Interfaces / flockfile
https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/functions/flockfile.html
Signed-off-by: Miguel Herranz <miguel@midokura.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-22 23:34:45 +08:00
Fotis Panagiotopoulos
ca9aeeec1f
freopen: Added flush of the read buffers.
2022-10-18 23:29:55 +08:00
Fotis Panagiotopoulos
10d6de46e6
libfread: Fixed error flag when reading a write-only file.
2022-10-18 21:29:14 +08:00
anjiahao
d1d46335df
Replace nxsem API when used as a lock with nxmutex API
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-17 15:59:46 +09:00
Petro Karashchenko
ec4a615f6c
libs/libc/stdio: fix ungetc operation
...
Do not modify errno in case of failure
Return EOF if the value of c equals to EOF
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-10-14 23:29:38 +08:00
Xiang Xiao
bdeaea3742
Remove the unnessary empty line after label
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-30 17:54:56 +02:00
Xiang Xiao
8565882bb5
libc/stdio: Let STDIO_DISABLE_BUFFERING depends on FILE_STREAM
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-22 17:41:05 +02:00
Huang Qi
e4e3208180
Replace all strncpy with strlcpy for safety
...
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-08-25 13:38:36 +08: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
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
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
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
anjiahao
e0c3bf64a0
libc:Optimize the behavior of fwrite
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-06-07 22:28:00 +08: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