Commit Graph

921 Commits

Author SHA1 Message Date
Petro Karashchenko
e7f9c7af21 typos: fix typos in Kconfig files
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-08 06:46:26 -03:00
chao.an
8c35d31808 Kconfig: Remove CONFIG_ prefix from config definition
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-07 13:16:18 +08:00
anjiahao
9aa69168e4 libc/pthread:pthread_barrierinit sem use pri_none
barrier is used protect resources. don't lock
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-01-05 20:21:05 +08:00
Petro Karashchenko
b859f2750b libc/math: fix log and logf calculations on ARMv7 (and maybe others)
Probably this is a bug of a GCC, but on AMRv7 the code "if (relax_factor > 1)"
generates "bne.n" instruction if "relax_factor" is "int". Few lines above
"relax_factor *= LOG_RELAX_MULTIPLIER;" is done without overflow check hence
at some moment overflow occurs and "relax_factor" becomes a zero and condition
"if (relax_factor > 1)" becomes always evaluated to "true" hence "epsilon"
becomes zero always.

Probably this is not the best way to fix the bug (The best way is to report it
to GCC), but this change allows to get correct behavior of "log" and "logf" for
ARMv7 based MCUs

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-01 20:38:38 +08:00
Petro Karashchenko
8462b14d4e libc/math: fix fmod family operation
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2021-12-31 20:51:23 +08:00
Norman Rasmussen
df956b08f2 Ensure that sethostname null terminates the hostname correctly
commit e1c306f2dd added sethostname using
strncpy. This replaces it with strlcpy and uses sizeof() instead of
re-calculating the buffer size.

Rename size argument for get/sethostname to match the implementation
2021-12-30 01:13:22 +08:00
Xiang Xiao
4262b09cbf libc: Implement terminal api regardless of CONFIG_SERIAL_TERMIOS setting
since many functions aren't related to termios directly

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-29 08:11:08 -03:00
Xiang Xiao
86684105f9 serial: Move tcdrain implementation from drivers/serial to libc
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-29 08:11:08 -03:00
Xiang Xiao
dd942f0b04 sched/backtrace: Dump the complete stack regardless the depth
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-29 12:09:54 +08:00
Xiang Xiao
9eecd4c5e2 libc: Prefix the address with 0 to the specified width in sched_dumpstack
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-29 12:09:54 +08:00
chao.an
7f2c5be07a libs/dumpstack: add support for print symbol name
ap> mw -1
[ EMERG] arm_usagefault: PANIC!!! Usage Fault:
[ EMERG] arm_usagefault:       IRQ: 6 regs: 0x3c24fa48
[ EMERG] arm_usagefault:       BASEPRI: 000000e0 PRIMASK: 00000000 IPSR: 00000006 CONTROL: 00000004
[ EMERG] arm_usagefault:       CFSR: 01000000 HFSR: 00000000 DFSR: 00000000 BFAR: 40101000 AFSR: 00000000
[ EMERG] arm_usagefault: Usage Fault Reason:
[ EMERG] arm_usagefault:       Unaligned access
[ EMERG] up_assert: Assertion failed at file:armv8-m/arm_usagefault.c line: 113 task: init
[ EMERG] backtrace|10:  0x2c325bde 0x2c319b98 0x2c3261cc 0x2c316b20 0x2c32699c 0x2c303a50 0x2c326072 0x2c3206ea
[ EMERG] backtrace|10:  0x2c3428cc 0x2c33ed14 0x2c342e8e 0x2c34403a 0x2c344ac0 0x2c319b60 0x2c3080ba
[ EMERG]  [10][ 0] [<0x2c325bde>] up_backtrace+0xa/0x13c
[ EMERG]  [10][ 1] [<0x2c319b98>] sched_dumpstack+0x10/0xc0
[ EMERG]  [10][ 2] [<0x2c3261cc>] up_assert+0x48/0x414
[ EMERG]  [10][ 3] [<0x2c316b20>] _assert+0x4/0x10
[ EMERG]  [10][ 4] [<0x2c32699c>] arm_usagefault+0xa8/0x138
[ EMERG]  [10][ 5] [<0x2c303a50>] irq_dispatch+0x1c/0x40
[ EMERG]  [10][ 6] [<0x2c326072>] arm_doirq+0x1a/0x2c
[ EMERG]  [10][ 7] [<0x2c3206ea>] exception_common+0x4a/0xac
[ EMERG]  [10][ 8] [<0x2c3428cc>] cmd_mw+0xec/0x11c
[ EMERG]  [10][ 9] [<0x2c33ed14>] nsh_parse_command+0x684/0xcf0
[ EMERG]  [10][10] [<0x2c342e8e>] nsh_session+0x92/0x168
[ EMERG]  [10][11] [<0x2c34403a>] nsh_consolemain+0x1e/0x38
[ EMERG]  [10][12] [<0x2c344ac0>] nsh_main+0x30/0x50
[ EMERG]  [10][13] [<0x2c319b60>] nxtask_startup+0x40/0x68
[ EMERG]  [10][14] [<0x2c3080ba>] nxtask_start+0x46/0x60

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-12-29 12:09:54 +08:00
Xiang Xiao
20bbdd0997 libc: Add backtrace_symbols[_fd] functions
specified here:
https://linux.die.net/man/3/backtrace_symbols

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-29 12:09:37 +08:00
Huang Qi
c2e8c92b25 arch/risc-v: Refine Toolchain.defs
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-12-28 00:30:10 -06:00
Petro Karashchenko
3ccb657dc2 nuttx: remove space befone newline in logs
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2021-12-27 21:01:19 -06:00
chao.an
e0f7bab13c libc/symtab: optimize the find speed by bisection
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-12-21 20:40:12 -06:00
Xiang Xiao
cc1a1b5781 net: Implement getifaddrs and freeifaddrs
specify here:
https://man7.org/linux/man-pages/man3/getifaddrs.3.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-21 11:01:33 -03:00
Juha Niskanen
422ceec99b Fix typos in comments and Kconfig files
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2021-12-21 03:26:16 -06:00
chao.an
ce1c8413a2 libc/lzfcompress: add lzf compress stream
compress stream based on lzf algorithm:

  struct lib_rawoutstream_s rawstream;
  struct lib_lzfoutstream_s lzfstream;

  lib_rawoutstream(&rawstream, fd);
  lib_lzfoutstream(&lzfstream, &rawstream);

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-12-20 08:39:33 -06:00
Petro Karashchenko
d445282566 fs/vfs: Add file descriptor based timers support
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2021-12-20 04:00:20 -06:00
Xiang Xiao
187d9e58c9 Remove the unnecessary inclusion of assert.h and string.h from public header files
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-20 10:30:08 +01:00
Petro Karashchenko
67d8a82393 Kconfig: fix non-string default values uniformity
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2021-12-20 00:10:57 +01:00
Xiang Xiao
c562263205 net: Move if_nametoindex and if_indextoname to libc
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-19 10:08:57 -06:00
Xiang Xiao
f9c1117c88 eventfd: Remove the unused and private eventfd_get_minor
since it isn't defined by Linux kernel too

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-19 01:41:11 -06:00
Takumi Ando
d0dd2684ce libc/unistd: getopt: Use argc to end parsing
It should end parsing with argc even the argv are remaining
or it may access to invalid address.

Signed-off-by: Takumi Ando <t-ando@advaly.co.jp>
2021-12-15 12:02:59 -06:00
Xiang Xiao
ed1e4ddfa7 libc: Add getprogname function
defined here:
https://www.freebsd.org/cgi/man.cgi?query=getprogname&sektion=3

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-15 10:47:56 -06:00
Petro Karashchenko
51a2db6ffc Kconfig: improve uniformity
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2021-12-14 07:32:48 -06:00
Petro Karashchenko
12b3491208 libc/textdomain: Fix error behaviour
- textdomain should set errno to ENOMEM in case if it is not
  possible to store domainname
- fix buffer overflow in textdomain if domainname is a string
  of NAME_MAX length
- improve textdomain error detection in case if domainname
  points to non null terminated buffer

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2021-12-14 05:54:34 -06:00
Xiang Xiao
b869c1ce0e libc: Move stream implementation from libs/libc/stdio to libs/libc/stream
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-14 00:51:59 -06:00
ligd
5b369c5cec libs/lbc: remove CHAR_BIT = 16 support
For CEVA platform CHAR_BIT is 16, and will do lots of extra work
when use IPC.
We will not support this platform anymore, so remove all the b2c operations.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-13 11:08:28 -06:00
Xiang Xiao
db6dd623c6 libc/gettextdomain: Fix the typo error
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-13 11:07:27 -06:00
chao.an
d3a07ca26c libs/printf: add support for print symbol name
Show a '%p' thing.  A nuttx extension is that the '%p' is followed
by an extra set of alphanumeric characters that are extended format
specifiers.

* - 'S' For symbolic direct pointers (or function descriptors) with offset
* - 's' For symbolic direct pointers (or function descriptors) without offset

printf("%ps %pS\n", ptr, ptr) will print:

module_start module_start+0x0/0x62

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-12-13 08:31:13 -06:00
chao.an
d20bd62e08 libc/allsyms: Load all symbols for debugging
let the nuttx print out symbolic crash information and
symbolic stack backtraces. This increases the size of the nuttx
somewhat, as all symbols have to be loaded into the nuttx image.

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-12-13 08:31:13 -06:00
Xiang Xiao
1af8cd4de8 sched: Move argv from tcb_s to task_info_s
argv is allocated from stack and then belong to userspace,
so task_info_s is a best location to hold this information.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-11 10:08:53 -06:00
chao.an
0161da4415 sched/dumpstack: raise the stack dump level to emergency
since sometimes dumpstack will be used in extreme situations(eg. assert)

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-12-09 00:14:30 -06:00
anjiahao
f9570810c0 libc/misc/err.c:add err.c to libc
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2021-12-07 04:01:27 -08:00
Xiang Xiao
a6eb6df688 libc/getopt: Move struct getopt_s to include/nuttx/tls.h
and remove include/nuttx/lib/getopt.h

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-06 06:30:16 -08:00
Xiang Xiao
a0990ee416 arch: Remove the duplicated up_tls_info implementation
Define up_tls_info in arch/arch.h directly if the general one isn't suitable

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-05 20:59:53 -06:00
Xiang Xiao
54eabf9616 libc: Add mknod implementation
https://pubs.opengroup.org/onlinepubs/007904875/functions/mknod.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-11-28 23:31:16 +01:00
Xiang Xiao
5da9dbe57a libc/gets: Remove the unnecessary cast
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-11-27 16:07:39 -03:00
Xiang Xiao
b5f6dcb523 libc/getdelim: Remove __KERNEL__ check since it shouldn't be called inside kernel
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-11-27 16:07:39 -03:00
anjiahao
80d32edbe1 libc/str:add strlcat to libc
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2021-11-26 15:24:35 -03:00
Xiang Xiao
c1cb429a98 libc/hex2bin: Handle the line ending(\r, \n and \r\n) dynamically
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-11-26 11:55:00 -03:00
chao.an
f3b019d1d2 libc/stdoutstream: restore the output method to fputc()
keep the default behavior for stdoutstream since the character
needs to flush every output

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-11-24 15:50:33 +09:00
chao.an
e228434cea libs/libc: add interface to support output stream as buffer style
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-11-23 21:00:43 -06:00
Xiang Xiao
e5cf5faa86 libc/psignal: Output the message to STDERR_FILENO instead STDOUT_FILENO
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-11-22 19:37:12 +01:00
Xiang Xiao
91f616e824 libc/pthread: Implement pthread_atfork
fork isn't supported yet, so the dummy implementation is enough.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-11-22 15:11:48 -03:00
Xiang Xiao
55311ea3df libc/stdio: Move source files to the right Makefile section
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-11-19 08:21:27 -03:00
Xiang Xiao
fe94670ca9 lib/stdio: Handle 64bits off_t correctly
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-11-18 10:06:27 -05:00
Xiang Xiao
bd2327cc2d libc: Make perror/putchar/getchar/puts work without CONFIG_FILE_STREAM
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-11-18 06:29:09 -08:00
Alin Jerpelea
384e38fc9b libs: libc: Haltian Ltd: update licenses to Apache
Gregory Nutt has submitted the SGA
Haltian Ltd has submitted the SGA

as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-11-15 06:49:32 -06:00