Commit Graph

429 Commits

Author SHA1 Message Date
Gustavo Henrique Nihei b9f231cdca include: Fix typos reported by codespell 2021-02-25 11:30:38 -08:00
Alin Jerpelea 9b9be7e1f0 include: Author: Gregory Nutt: update licenses to Apache 2.0
Update files from Gregory Nutt to Apache 2.0 license.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-04 03:33:58 -08:00
Alin Jerpelea 861c0071bd include: nuttx: fix nxstyle errors
Fix nxstyle errors to pass CI

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-04 03:33:58 -08:00
Xiang Xiao 98382dd8db sched: Add include/sys/poll.h
since many libc implementation(e.g. glibc, freebsd) provide this header file

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-01-06 14:23:50 +08:00
danguanghua 7d33f73e27 libs/libc/net: implement socketpair
N/A

Reference here:
https://www.freebsd.org/cgi/man.cgi?apropos=0&sektion=2&query=socketpair&manpath=FreeBSD+7.0-current&format=html

Change-Id: I959b4d661cd436f5d5050baf9e821db84139d482
Signed-off-by: danguanghua <danguanghua@xiaomi.com>
2021-01-03 20:56:27 -06:00
Xiang Xiao 085619d395 libc: Implement getppid
as specified here:
https://pubs.opengroup.org/onlinepubs/009695399/functions/getppid.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-12-20 16:40:14 -03:00
chao.an 859e1ce63a crypto/arc4random: rename getrandom to arc4random_buf
Change-Id: I5c9f0c9acf5af71f01beceaf06ebe0a2c87676bc
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-13 08:49:51 -06:00
Yoshinori Sugino a5e00ac3f0 include/sys/wait.h: Modify P_GID to P_PGID
Summary:
 - Follow the POSIX description.

Impact:
 - No impact as P_GID and P_PGID are not used.

Testing:
 - Built with hifive1-revb:nsh
2020-12-04 11:40:46 -06:00
Xiang Xiao bb8c4485a2 libc: Change OK/ERROR macro to enum
to avoid the conflict with 3rd party c++ library(e.g. protobuf):
fdc35840b9/src/google/protobuf/stubs/status.h (L47)

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ie8bb9008a8375c729f8b947c9f10baa80104d157
2020-11-30 09:43:18 +01:00
chao.an 27932faf1a sys/epoll: sync the epoll define with linux
Change-Id: If876e0c0b44de73cf2847a9d3c21ac138dd4f879
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-09 18:53:48 -08:00
chao.an 54d0c1c296 sys/uio: fix nxstyle warning
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-09 02:33:52 -08:00
chao.an 176d850445 sys/uio: include-able from C++ files
Change-Id: I4b512851fa96e1d696dbc886b25af4ab043da8dd
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-09 02:33:52 -08:00
chao.an 06d93828af sys/resource: fix nxstyle warning
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-09 02:22:34 -08:00
chao.an 82f1263db9 sys/resource: include-able from C++ files
Change-Id: I914ab40495a25da184d0b7f8f8b1fa0d376c66a4
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-09 02:22:34 -08:00
YAMAMOTO Takashi e99e185712 Don't typedef wchar_t for C++
wchar_t is a builtin type in C++.

clang complains like the following even with -fshort-wchar:

    error: cannot combine with previous 'type-name' declaration specifier

my clang version if it matters:

    spacetanuki% clang++ --version
    Apple clang version 11.0.0 (clang-1100.0.33.17)
    Target: x86_64-apple-darwin18.7.0
    Thread model: posix
    InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
    spacetanuki% clang++ -dM -E - < /dev/null | grep WCHAR
    #define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2
    #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
    #define __SIZEOF_WCHAR_T__ 4
    #define __WCHAR_MAX__ 2147483647
    #define __WCHAR_TYPE__ int
    #define __WCHAR_WIDTH__ 32
    spacetanuki% clang++ -fshort-wchar -dM -E - < /dev/null | grep WCHAR
    #define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2
    #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
    #define __SIZEOF_WCHAR_T__ 2
    #define __WCHAR_MAX__ 65535
    #define __WCHAR_TYPE__ unsigned short
    #define __WCHAR_UNSIGNED__ 1
    #define __WCHAR_WIDTH__ 16
    spacetanuki%
2020-11-01 18:19:13 -08:00
Juha Niskanen 1115452061 drivers/pipes: nx_pipe syscall takes three params, also use nx_close on error path
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-10-28 09:11:05 -07:00
Xiang Xiao eb4121ce38 Change all 'Nuttx' to 'NuttX'
Unify the naming convention

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-10-20 01:45:06 -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
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
liuhaitao e0aa7c6d81 syscall: update syscall_lookup.h with gettid to fix build break
proxies/PROXY_gettid.c: In function 'gettid':
proxies/PROXY_gettid.c:12:41: error: 'SYS_gettid' undeclared (first use in this function); did you mean 'SYS_getpid'?
   12 |   return (pid_t)sys_call0((unsigned int)SYS_gettid);
      |                                         ^~~~~~~~~~
      |                                         SYS_getpid
proxies/PROXY_gettid.c:12:41: note: each undeclared identifier is reported only once for each function it appears in
proxies/PROXY_gettid.c:13:1: warning: control reaches end of non-void function [-Wreturn-type]
   13 | }
      | ^
CC:  proxies/PROXY_mmap.c
Makefile:83: recipe for target 'PROXY_gettid.o' failed

Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
Change-Id: Ib4d6e315aa7f17235292dd2d6550458a53bc1596
2020-09-18 20:07:00 -07:00
chao.an 9241725312 fs/munmap: export the symbols to avoid build break on C++ syntax
base/metrics/persistent_memory_allocator.cc:1009:18: error: expected id-expression before ‘-’ token
 1009 |   int result = ::munmap(memory, size);
      |                  ^~~~~~

Change-Id: I24e55c18d09553d3acc341a27063d01489d905ec
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-09-18 20:05:10 -07:00
chao.an 78005a4ba0 sys/epoll: include-able from C++ files
Change-Id: Icc73be9de7a9217e33903243b0ecf1a9a596b381
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-09-18 19:51:55 -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
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
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 c8c2745fa7 include/sys/types.h: add u_intXX_t support
like u_int8_t u_int16_t u_in32_t...

Change-Id: Ieee5014bddb1cf1a6e769af7258ff524263f67fb
Signed-off-by: ligd <liguiding1@xiaomi.com>
2020-09-11 10:41:24 +08:00
Xiang Xiao 389b45359d epoll: Don't save fd into the field of epoll_data_t
since epoll_data_t is reserved to the caller and
then shouldn't be touched by the implementation

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-25 21:06:48 +01:00
Xiang Xiao a354b9a9d1 fs/vfs: Implement EPOLLONESHOT flag
https://linux.die.net/man/2/epoll_ctl:
EPOLLONESHOT (since Linux 2.6.2)
Sets the one-shot behavior for the associated file descriptor.
This means that after an event is pulled out with epoll_wait(2)
the associated file descriptor is internally disabled and
no other events will be reported by the epoll interface.
The user must call epoll_ctl() with EPOLL_CTL_MOD to
rearm the file descriptor with a new event mask.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I6c0dc93e1cdae0e8cea5b487c7005de2da2c2ec3
2020-08-25 21:06:48 +01:00
Xiang Xiao 6c9ff72b9a fs/vfs: Implement epoll_pwait API
specified here:
https://linux.die.net/man/2/epoll_pwait

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I20106fdbe4f403ded7eab43f3523edd262e1d9a3
2020-08-25 21:06:48 +01:00
spiriou 0ddefd7c69 fs/vfs/fs_epoll: fix epoll_wait function 2020-08-20 11:49:20 -05:00
chao.an b89737395b vfs/epoll: add epoll_create1(2) implement
Linux Programmer's Manual

NAME
       epoll_create, epoll_create1 - open an epoll file descriptor

...
SYNOPSIS
       #include <sys/epoll.h>

       int epoll_create1(int flags);
...

   epoll_create1()
       If flags is 0, then, other than the fact that the obsolete
       size argument is dropped, epoll_create1() is the same as
       epoll_create(). The following value can be included in flags
       to obtain different behavior:

       EPOLL_CLOEXEC
              Set the close-on-exec (FD_CLOEXEC) flag on the new file
              descriptor. See the description of the O_CLOEXEC flag in
              open(2) for reasons why this may be useful.

https://man7.org/linux/man-pages/man7/epoll.7.html
2020-08-17 23:41:13 -05:00
chao.an 2e2ebb95ca sys/poll/epoll: sync the epoll_event struct layout with pollfd
epoll(2) call broken caused by 94fe5c8349

Change-Id: I0811bb7a756797651819d46236e26869559b1767
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-08-17 23:41:13 -05:00
chao.an 155860ad15 sys/epoll: move the private handle to epoll_data_t
sync the struct epoll_event define with linux:

Linux Programmer's Manual:

DESCRIPTION

  EPOLL_CTL_DEL
    ...
       The event argument describes the object linked to the file descriptor
       fd.  The struct epoll_event is defined as:

           typedef union epoll_data {
               void        *ptr;
               int          fd;
               uint32_t     u32;
               uint64_t     u64;
           } epoll_data_t;

           struct epoll_event {
               uint32_t     events;      /* Epoll events */
               epoll_data_t data;        /* User data variable */
           };

https: //man7.org/linux/man-pages/man2/epoll_ctl.2.html

Change-Id: I3ad447b485fd331190e461a198ef7c39301eb1bb
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-08-17 23:41:13 -05:00
chao.an e5f6dafe1f net/socket: add SOCK_CLOEXEC/SOCK_NONBLOCK support
Reference here:
https://github.com/torvalds/linux/blob/master/include/linux/net.h

Change-Id: I9fd0170bcd1ae7e778e951d454ada76f63854de5
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-08-17 23:38:18 -05:00
David Sidrane bca0f3e275 sys/stat:Make comment match code 2020-08-06 08:36:03 -05:00
spiriou a4a9eb2f5a fs/vfs: Add file descriptor based events support 2020-07-31 15:09:35 -06: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 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
Nakamura, Yuuichi ac34ac9f5c Add g_funcnames declaration in syscall.h 2020-07-22 12:01:40 -05:00
Xiang Xiao 4f22f746f8 syscall: Remove g_funclookup and g_funcnparms
since nobody use them

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-07-19 13:07:31 -07:00
Xiang Xiao 6f6d61eec4 fs/vfs: Implement statvfs and fstatvfs
specified here:
https://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/statvfs.h.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-07-13 20:25:03 +01:00
Xiang Xiao 91ed14c631 vfs/stat: Make the flag defintion more confirm POSIX standard
specified here:
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-07-07 13:41:10 +01:00
chao.an 3fbdc213b7 syscall/prctl: fix PR_SET_NAME failure if without <pid> arg
add PR_SET_NAME_EXT/PR_GET_NAME_EXT extension to avoid semantic
conflicts, use extened version for pthread_setname_np/pthread_getname_np

Change-Id: I40404c737977a623130dcd37feb4061b5526e466
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-07-01 21:52:18 -05:00
Xiang Xiao 651eefc8f7 fs: Rename link to symlink
since the current implementation is really a symoblic link not hard link

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I59d30d0a620b0b5714fe91bbe90d4405cf53d187
2020-07-01 11:58:12 +02:00
Xiang Xiao b598ab43d7 fs: Implement lstat function
specified here:
https://pubs.opengroup.org/onlinepubs/009695399/functions/lstat.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Iefc23a02d425ff84fa4027aea7da1181b01eced7
2020-06-30 13:09:58 -06:00
Xiang Xiao a81a260490 vfs: Add chmod/fchmod/utimes function prototype
but skip the implemenation because VFS layer doesn't support the time/mode change yet:
https://pubs.opengroup.org/onlinepubs/009695399/functions/chmod.html
https://pubs.opengroup.org/onlinepubs/009696699/functions/fchmod.html
https://pubs.opengroup.org/onlinepubs/009695399/functions/utimes.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ie4a2d3bb4eb5f5aaa0aeb794a4012b096aa94e4f
2020-06-30 09:20:33 +01:00
chao.an b296adc3bb socket/SOL: sync the SOL index with linux
Change-Id: I32b9eb7cc3bc1428f0ff7bf5e60d7fff52621db2
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-06-29 11:34:43 -05:00
Xiang Xiao d17b963bca libc: Move double_t typedef from sys/types.h to math.h
specified here:
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/math.h.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I3497a73908301d999cf1cfc4a66552a7ca4868c6
2020-06-29 13:37:41 +01:00
Peter van der Perk 55d9e5f7af net: Add SocketCAN support 2020-06-15 08:07:19 -06:00
Gregory Nutt 1c002e1049 fs/vfs/fs_fstat: Correct fstat() for proxied block and MTD drivers.
Block and MTD drivers may be opened and managed as though they were character drivers.  But this is really sleight of hand; there is a hidden character driver proxy that mediates the interface to the block and MTD drivers in this case.

fstat(), however, did not account for this.  It would report the characteristics of the proxy character driver, not of the underlying block or MTD driver.

This change corrects that.  fstat now checks if the character driver is such a proxy and, if so, reports the characteristics of the underlying block or MTD driver, not the proxy character driver.
2020-05-28 17:34:09 +01:00