Commit Graph

520 Commits

Author SHA1 Message Date
YAMAMOTO Takashi
3e6561c3cf lib_libvscanf.c: Implement "j" modifier for scanf
It's a part of C99 and commonly used these days.
2020-09-23 03:28:40 -07:00
Gregory Nutt
ebdfd16f0f Move gettid() implementation to /libs/libc/unistd
Move sched/task/task/task_gettid.c to libs/libc/unistd/lib_gettid.c.  gettid() is a dumb wrapper around getpid().  It is wasteful of resources to support TWO systme calls, one for getpid() and one for gettid().  Instead, move gettid() in the C library where it calls the single sysgtem call, getpid().  Much cleaner.
2020-09-22 19:40:56 -07:00
Xiang Xiao
f4794f0b48 libc: Implement access function correctly
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I6ae3abf79bd9aa8cfb54b8bbe302d69c4d9cb8ff
2020-09-22 10:30:36 +02:00
spiriou
a1c047fe53 libc/uio: enable writev() for sockets 2020-09-21 19:31:06 -07:00
Xiang Xiao
ba3f12c93f libc: Implement popcount/popcountl/popcountll
specified here:
https://www.unix.com/man-page/netbsd/3/popcountll/

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-09-21 07:37:04 -07:00
chao.an
216c33a5c7 libs/libc/stdlib: Implement mkdtemp(3) syscall
See the reference here:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdtemp.html

Change-Id: I49081ecafc011a843e6067b1118b53bf65d4418b
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-09-19 04:16:14 -07:00
chao.an
4067a9f057 libs/libc/stdio: correct the prototype of mktemp(3)
From:   int       mktemp(FAR char *path_template);
To:     FAR char *mktemp(FAR char *path_template);

See the reference here:
https://pubs.opengroup.org/onlinepubs/009695399/functions/mktemp.html

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-09-19 04:16:14 -07:00
chao.an
0826b827ee libs/libc/time: add stub for futimes/ns(2)
Change-Id: I231817d10b9e2071b1f642e8694839b2a64b1c4c
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-09-19 03:20:09 -07:00
chao.an
0f06c35640 unistd/priority: Implement [s/g]etpriority(2) syscall
See the reference here:
https://pubs.opengroup.org/onlinepubs/009695399/functions/getpriority.html

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-09-19 01:06:51 -07:00
chao.an
b8fa1e51d8 time/tm: add "tm_zone" member into tm
base/time/time_exploded_posix.cc:190:14: error: ‘struct tm’ has no member named ‘tm_zone’; did you mean ‘tm_mon’?
  190 |   timestruct.tm_zone = nullptr;  // not a POSIX field, so mktime/timegm ignore
      |              ^~~~~~~
      |              tm_mon

Change-Id: I9f93e63b50c0692a7a2bfc47abd9d07aa2c8e8db
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-09-18 20:03:05 -07:00
chao.an
614ac5b0f2 libs/libc/unistd: Implement pipe2(2) syscall
See the reference here:
https://www.man7.org/linux/man-pages/man2/pipe2.2.html

Change-Id: Ife19b9bdbde73c7421be381a094da67017819e63
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-09-18 20:01:26 -07:00
Matias N
166242c171 use "export" to expose TOPDIR to all child make instead of passing it around every time 2020-09-15 21:11:33 -07:00
ligd
c38c821fc2 libs/libc/time: add gethrtime() support
Change-Id: I8882207d3a7e5062f70c7b4b95205361c71f8744
Signed-off-by: ligd <liguiding1@xiaomi.com>
2020-09-15 10:28:21 -03:00
ligd
b3541ccaf8 libs/libc/unistd: add dummy getrlimit & setrlimit support
Change-Id: Iee826204596c492ace853e49ab7ff26a2ae7fe60
Signed-off-by: ligd <liguiding1@xiaomi.com>
2020-09-15 10:28:21 -03:00
ligd
c11c1dc8fd libs/libc/stdio: replace double_t to double
Modify reason:

When build Nuttx SIM, in x86_64 system:

Compile with gcc option '-m64' (default):
sizeof(double_t) = 8
sizeof(double)   = 8

Compile with gcc option '-mx32':
sizeof(double_t) = 8
sizeof(double)   = 8

Compile with gcc option '-m32':
sizeof(double_t) = 12       // long double
sizeof(double)   = 8

When use '-m32', and print sth. like this:
printf("%f\n", (double)3.0);
SIM will print out: nan

This is because sizeof(double_t) is not equal with double.

Resolve:
replace all double_t to double in libs/libc/stdio.

As a user of '-m32', you should know double_t is one type
long double, and len is 12. And you use use '%lf' to print.
like:
printf("%lf\n", (double_t)3.0);

Currently we don't support '%lf'.

Change-Id: I9b9d11853140d5296dd80416c8ed6a260a9d2d9c
Signed-off-by: ligd <liguiding1@xiaomi.com>
2020-09-15 14:42:36 +08:00
Xiang Xiao
027e2eed28 libc: Implement umask function
Here is the spec:
https://pubs.opengroup.org/onlinepubs/009695399/functions/umask.html
Note: The simple implementaton is enough since
      NuttX doesn't really support the permission

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-09-14 12:16:58 -03:00
dongjiuzhu
03c7951cbd libc/termios: modify termios setting follow linux and posix
Change-Id: Id323b3169e74f4153fd8d132d20926b7fb8336a3
Signed-off-by: dongjiuzhu <dongjiuzhu1@xiaomi.com>
2020-09-14 09:23:46 -03:00
Matias N
34b34e2d45 Fix: ensure archive files do not carry object files from prior builds
In some cases, when NuttX configuration changes and this makes the
object list used to build one of the .a libraries change as well,
since the command used to build it is "ar crs" and this simply appends
the list of object files, the library could still include object
files from prior builds. This commit modifies the ARCHIVE macro to
erase the .a file if it already exists.

Since in some cases this behavior was actually expected (object
files from a subdirectory were appended to a library created one
level above) I added a ARCHIVE_ADD which works as ARCHIVE did.

This change should greatly improve behavior of building after
configuration changes.
2020-09-14 15:54:18 +08:00
Xiang Xiao
b0797263ca libc/stdio: Allocate file_struct dynamically
1.Reduce the default size of task_group_s(~512B each task)
2.Scale better between simple and complex application

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ia872137504fddcf64d89c48d6f0593d76d582710
2020-09-11 17:58:17 +08:00
ligd
f428160dcc signal: add SIGQUIT & SIGTERM support
SIGQUIT SIGTERM are equal with SIGINT now

Change-Id: Iefc084d58db28003dc40a17f1ff3fbd7a0b716ed
2020-09-11 10:41:24 +08:00
Huang Qi
1025456ffa libs/libc/time: Add stub for utimes
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Change-Id: Id4b51de943c4119d4d9ede1096475b1831593349
2020-08-29 23:21:47 +08:00
Xiang Xiao
b5f429c88b Fix nxstyle warning
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-22 17:37:21 -06:00
Xiang Xiao
ae356001cf Change all files come from Xiaomi/Pinecone to Apache License 2.0
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-22 17:37:21 -06:00
Xiang Xiao
6670bc2b27 libc/time: Implement tm::tm_gmtoff field
defined by BSD and GNU library extension:
https://www.gnu.org/software/libc/manual/html_node/Broken_002ddown-Time.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I33113bc322f038a3602880db4fb9cf93001947ac
2020-08-21 07:48:52 -03:00
Xiang Xiao
297c294c0f libc: Change ctype macro to normal function
to avoid the argument evaluation more than once

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ib59c9bc8d259731bc6e7ff542379b74ba22d6e33
2020-08-21 16:56:00 +08:00
Xiang Xiao
beb745ef92 sched/pthread: Implement pthread_attr_[get|set]detachstate
specified here:
https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_attr_getdetachstate.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I84ec2d14f14cb7118aac3f7f356f83a5f9af4e18
2020-08-20 10:46:14 +01:00
qiaowei
1d97b2ecee stack check: Support Stack Smashing Protector(SSP)
and enable on sim as a demo. Here is the paper:
ftp://gcc.gnu.org/pub/gcc/summit/2003/Stackguard.pdf

Signed-off-by: qiaowei <qiaowei@xiaomi.com>
Change-Id: I1926936328dad54eee16b322dcaad0b42f9c4a62
2020-08-18 09:58:21 -07:00
Xiang Xiao
a7a81b5126 libc: Replace all [nx]sem_xxx with _SEM_XXX
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I34f407ccd52391588ac1b720fce59d24458fe218
2020-08-18 07:59:21 -07:00
chao.an
7ce2b3fa74 libc/pthread: Implement pthread_condattr_[g|s]etclock
Reference:
https: //pubs.opengroup.org/onlinepubs/009695399/functions/pthread_condattr_setclock.html

Change-Id: I19c15d5f219fcf28dbfeb2e5a1e3fc7b38ba2259
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-08-17 19:17:08 +01:00
Xiang Xiao
79d476e423 Fix libsupc++.a(vterminate.o): undefined reference to `_impure_ptr'
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ibbd9d980aa642b5a23016b54de8a7808db7b3b9f
2020-08-17 13:45:56 -03:00
Xiang Xiao
6039fb48ae libxx: Integrate libc++ latest official release
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ic0a5f6dd8504382c49546c05399c2ea6470cd528
2020-08-17 13:45:56 -03:00
Xiang Xiao
4ebaf12b4b libxx: Ensure uClibc++ distclean clear
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-17 13:45:56 -03:00
chao.an
82caa786cc libc/fopen: add open for text (translated) access support
Change-Id: I5bb4e01a91a0f8ea82437cdcba191c484aa1b77f
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-08-16 00:01:36 +01:00
Huang Qi
57e1211ed6 math: Implement cbrt
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2020-08-14 07:27:55 -05:00
chao.an
7356b5a2ed libc: Implement strlcpy function
Reference:
http://www.delorie.com/djgpp/doc/libc/libc_763.html

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-08-14 03:44:26 -07:00
Xiang Xiao
4df42ba9fb libc/ftw: Fix error: cast between incompatible function types from 'ftw_cb_t' nftw_cb_t
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I9e617ac04127e1e9126de2e3d32b35f2c6d636c0
2020-08-11 08:16:58 -07:00
Xiang Xiao
b13f3212ad libc: Implement ftw and nftw function
see the reference here:
https://pubs.opengroup.org/onlinepubs/009695399/basedefs/ftw.h.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I3b368106a56b0e9d4c653f3ae16304b0a9d55fbc
2020-08-11 16:44:42 +09:00
Huang Qi
fd78f83e02 drivers/video: Refine the update region notification mechanism
1.Expose the notification through fb_vtable_s::updatearea
2.Incorporate old nx_notify_rectangle into the new updatearea callback
3.Migrate the calle of nx_notify_rectangle to fb_vtable_s::updatearea

Change-Id: Ia3d1f73e8757b2d381586d76ec6adc16c810018d
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2020-08-10 08:08:33 +02:00
Xiang Xiao
5c67eac27f libc: Change index/rindex from macro to function
to avoid the confliction with the same name variable

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-05 04:39:03 -07:00
Gregory Nutt
188d4b0fb4 user-space memalign() must not be called from within the OS.
drivers/net/ftmac100.c, libs/libc/stdlib/lib_aligned_alloc.c

A continuation of PRs #1507, #1510, and #1512.  See Issue #1481 for additional information.
2020-08-04 22:45:47 +01:00
spiriou
a4a9eb2f5a fs/vfs: Add file descriptor based events support 2020-07-31 15:09:35 -06:00
YAMAMOTO Takashi
b6316e9a03 libs/libc/modlib/modlib_sections.c: Remove a redundant assignment
Found by clang-check:

modlib/modlib_sections.c:93:3: warning: Value stored to 'buffer' is never read
  buffer    = loadinfo->iobuffer;
  ^           ~~~~~~~~~~~~~~~~~~
1 warning generated.
2020-07-30 16:16:21 +02:00
YAMAMOTO Takashi
39ed1417d8 lib_libfread.c: Replace Gregory Nutt's copyright notice with Apache 2.0
The new license text was copied from sched_getcpu.c.
2020-07-30 16:16:21 +02:00
YAMAMOTO Takashi
15590005d0 lib_libfread.c: nxstyle fixes 2020-07-30 16:16:21 +02:00
YAMAMOTO Takashi
d02354c766 libs/libc/stdio/lib_libfread.c: Remove a redundant assignment
Found by clang-check:

stdio/lib_libfread.c:75:7: warning: Value stored to 'bytes_read' is never read
      bytes_read = -1;
      ^            ~~
1 warning generated.
2020-07-30 16:16:21 +02:00
Xiang Xiao
3cff139b85 libc: Make gethostname as syscall instead of uname
simplify and symmetry the implementation in KERNEL/PROTECTED build

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Iefdeea5f6ef6348c774b2ca9f7e45fe89c0c22dd
2020-07-30 10:33:08 +09:00
Xiang Xiao
1cb1fb427d libc: Replace all malloc/free to lib_malloc/lib_free
since libc can be built and used in kernel space,
we must call kmm_malloc and kmm_free in this case.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-07-29 10:14:27 +01:00
SPRESENSE
e249a2f82f Makefile: Fix Make.dep not updated by config changes
Make.dep file should be updated by .config changed after first make.
There are 2 cases affected for this problem:

 1) Add source files by config symbol
 2) Include header files in #ifdef directive

These 2 cases may not be included in Make.dep and this may prevent the
differential build from working correctly.
2020-07-28 03:59:45 -05:00
Masayuki Ishikawa
524f18c4cd libs: termios: Replace license header with Apache License 2.0
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2020-07-28 00:47:39 -05:00
Xiang Xiao
33ec242caf Implement proposed POSIX _clockwait variants of existing _timedwait functions
Here is the related glibc patchset:
https://patchwork.ozlabs.org/project/glibc/cover/cover.b0c66849a87ca79889a49f2f1f2563b1a8a15d8b.1551291557.git-series.mac@mcrowe.com/

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I0095cb34cef3d0d88a100255053da79266b73ff2
2020-07-27 20:39:59 -03:00