Commit Graph

907 Commits

Author SHA1 Message Date
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
Xiang Xiao
bec1b0bc92 Revert "libc: Implement fesetround & fegetround for arm"
Since the toolchain provide the implementation now.
This reverts commit fe992a5b6c.
2021-11-10 14:35:53 -03:00
ligd
3f94828f6b netdb: fix access within misaligned address error
netdb/lib_dnsquery.c:444:14: runtime error: member access within misaligned address 0xef2f5a1b for type 'struct dns_question_s', which requires 2 byte alignment
0xef2f5a1b: note: pointer points here
 63  6f 6d 00 00 01 00 01 c0  0c 00 05 00 01 00 00 00  1c 00 1a 05 6d 75 73 69  63 06 6e 74 65 73 35
              ^
netdb/lib_dnsquery.c:445:14: runtime error: member access within misaligned address 0xef2f5a1b for type 'struct dns_question_s', which requires 2 byte alignment
0xef2f5a1b: note: pointer points here
 63  6f 6d 00 00 01 00 01 c0  0c 00 05 00 01 00 00 00  1c 00 1a 05 6d 75 73 69  63 06 6e 74 65 73 35
              ^

Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-11-08 21:57:27 -06:00
zhuyanlin
5a4140f020 arch:xtensa: add setjmp xtensa function
N/A

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2021-11-06 07:39:27 -05:00
zhuyanlin
cfcff5f570 libc:machine:xtensa:add xtensa libc implement
N/A

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2021-11-06 07:39:27 -05:00
Jukka Laitinen
7e9e8a817d libs/libc/wqueue/work_usrthread.c: Correct time calculation in work_process
This fixes busylooping in work_usrthread, due to incorrect time spec given to sem_timedwait

_SEM_TIMEDWAIT works on absolute time stamps, using CLOCK_REALTIME

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-11-04 13:19:01 -05:00
Jukka Laitinen
c79d2067c7 Move timespec calculations from sched into libc/sched
Allow using these functions also outside sched, where systick
related calculations are performed

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-11-04 13:19:01 -05:00
Xiang Xiao
aa9c17e93d libc: Move lib_filesem.c and lib_stream.c to libc/stdio
since it make more sense to put all FILE functions in one place

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-11-02 09:00:11 +01:00
Xiang Xiao
ad2f82898a libc/misc: Add lib_ prefix to stream_semtake and tream_semgive
and merge lib_streamsem.c to lib_stream.c

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-11-02 09:00:11 +01:00
Jiuzhu Dong
ee29175811 libc/machine: add config LIBC_ARCH_MEMCHR
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-11-01 12:44:02 +01:00
Xiang Xiao
5f7cc04627 fs/aio: Fix compile warning
aio/lio_listio.c:227:7: warning: implicit declaration of function ‘ferr’ [-Wimplicit-function-declaration]
  227 |       ferr("ERROR: lib_zalloc failed\n");
      |       ^~~~
aio/lio_listio.c:275:3: warning: implicit declaration of function ‘finfo’ [-Wimplicit-function-declaration]
  275 |   finfo("Registering signal handler\n");

aio/aio_read.c: In function ‘aio_read_worker’:
aio/aio_read.c:90:11: warning: implicit declaration of function ‘file_pread’; did you mean ‘aio_read’? [-Wimplicit-function-declaration]
   90 |   nread = file_pread(aioc->aioc_filep, (FAR void *)aiocbp->aio_buf,
      |           ^~~~~~~~~~
      |           aio_read

aio/aio_write.c: In function ‘aio_write_worker’:
aio/aio_write.c:85:12: warning: implicit declaration of function ‘file_fcntl’ [-Wimplicit-function-declaration]
   85 |   oflags = file_fcntl(aioc->aioc_filep, F_GETFL);
      |            ^~~~~~~~~~
CC:  mmap/fs_mmap.c
CC:  pthread/pthread_condclockwait.c
aio/aio_write.c:107:18: warning: implicit declaration of function ‘file_write’; did you mean ‘aio_write’? [-Wimplicit-function-declaration]
  107 |       nwritten = file_write(aioc->aioc_filep,
      |                  ^~~~~~~~~~
      |                  aio_write
aio/aio_write.c:113:18: warning: implicit declaration of function ‘file_pwrite’; did you mean ‘aio_write’? [-Wimplicit-function-declaration]
  113 |       nwritten = file_pwrite(aioc->aioc_filep,
      |                  ^~~~~~~~~~~
      |                  aio_write
In file included from aio/aio_write.c:34:
aio/aio_write.c:121:12: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  121 |       ferr("ERROR: write/pwrite/send failed: %d\n", nwritten);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~~~
      |                                                     |
      |                                                     ssize_t {aka long int}
aio/aio_write.c:121:47: note: format string is defined here
  121 |       ferr("ERROR: write/pwrite/send failed: %d\n", nwritten);
      |                                              ~^
      |                                               |
      |                                               int
      |                                              %ld

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-10-31 06:30:57 -03:00
YAMAMOTO Takashi
3097f62511 Revert "lib/netdb: Change the default NETDB_DNSCLIENT_NAMESIZE to NAME_MAX"
This reverts commit 3724f6be55.

Because there is no real correlation between DNS namesize and NAME_MAX
as far as I know. The former is about network and the latter is about
filesystem. While they might happen to be similar values for
some configurations, it's very confusing to use them this way.
2021-10-29 01:15:58 -05:00
Xiang Xiao
3724f6be55 lib/netdb: Change the default NETDB_DNSCLIENT_NAMESIZE to NAME_MAX
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-10-25 19:50:16 -03:00
Xiang Xiao
c4472b64cb libc/netdb: Change default of NETDB_DNSCLIENT_MAXRESPONSE to NETDB_BUFSIZE
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-10-25 19:50:16 -03:00
Xiang Xiao
1e607a70bc libc/vsprintf_internal: Call va_copy just like vsyslog
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-10-11 16:39:44 -03:00