From 83e95bdff4c48c661b50e1eec56d5fd293b28fbb Mon Sep 17 00:00:00 2001 From: Shell Date: Thu, 28 Mar 2024 23:42:56 +0800 Subject: sync smart & dfs (#8672) Signed-off-by: xqyjlj Signed-off-by: Shell Co-authored-by: xqyjlj --- components/libc/compilers/common/ctime.c | 21 ++++++++------ components/libc/compilers/common/include/dirent.h | 6 +++- .../libc/compilers/common/include/sys/ioctl.h | 7 +++-- .../libc/compilers/common/include/sys/unistd.h | 2 ++ components/libc/compilers/musl/fcntl.h | 33 +++++++++++++++++++--- 5 files changed, 53 insertions(+), 16 deletions(-) (limited to 'components/libc/compilers') diff --git a/components/libc/compilers/common/ctime.c b/components/libc/compilers/common/ctime.c index 44822ec379..a1bb3c439d 100644 --- a/components/libc/compilers/common/ctime.c +++ b/components/libc/compilers/common/ctime.c @@ -25,6 +25,7 @@ * 2023-08-12 Meco Man re-implement RT-Thread lightweight timezone API * 2023-09-15 xqyjlj perf rt_hw_interrupt_disable/enable * 2023-10-23 Shell add lock for _g_timerid + * 2023-11-16 Shell Fixup of nanosleep if previous call was interrupted */ #include "sys/time.h" @@ -544,20 +545,24 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp) unsigned long ns = rqtp->tv_sec * NANOSECOND_PER_SECOND + rqtp->tv_nsec; rt_ktime_boottime_get_ns(&old_ts); rt_ktime_hrtimer_ndelay(ns); - if (rt_get_errno() == -RT_EINTR) + if (rt_get_errno() == RT_EINTR) { if (rmtp) { + rt_base_t rsec, rnsec; rt_ktime_boottime_get_ns(&new_ts); - rmtp->tv_sec = 0; - rmtp->tv_nsec = - (old_ts.tv_nsec + ns) - ((new_ts.tv_sec - old_ts.tv_sec) * NANOSECOND_PER_SECOND + new_ts.tv_nsec); - - if (rmtp->tv_nsec > NANOSECOND_PER_SECOND) + rsec = old_ts.tv_sec + rqtp->tv_sec - new_ts.tv_sec; + rnsec = old_ts.tv_nsec + rqtp->tv_nsec - new_ts.tv_nsec; + if (rnsec < 0) + { + rmtp->tv_sec = rsec - 1; + rmtp->tv_nsec = NANOSECOND_PER_SECOND + rnsec; + } + else { - rmtp->tv_nsec %= NANOSECOND_PER_SECOND; - rmtp->tv_sec += rmtp->tv_nsec / NANOSECOND_PER_SECOND; + rmtp->tv_sec = rsec; + rmtp->tv_nsec = rnsec; } } rt_set_errno(EINTR); diff --git a/components/libc/compilers/common/include/dirent.h b/components/libc/compilers/common/include/dirent.h index f1a45d2986..51451e2d59 100644 --- a/components/libc/compilers/common/include/dirent.h +++ b/components/libc/compilers/common/include/dirent.h @@ -32,9 +32,13 @@ extern "C" { #define DT_UNKNOWN 0x00 #define DT_FIFO 0x01 -#define DT_SYMLINK 0x03 +#define DT_CHR 0x02 #define DT_DIR 0x04 +#define DT_BLK 0x06 #define DT_REG 0x08 +#define DT_LNK 0x0a +#define DT_SOCK 0x0c +#define DT_SYMLINK DT_LNK #ifndef HAVE_DIR_STRUCTURE #define HAVE_DIR_STRUCTURE diff --git a/components/libc/compilers/common/include/sys/ioctl.h b/components/libc/compilers/common/include/sys/ioctl.h index ab0c069550..908074863a 100644 --- a/components/libc/compilers/common/include/sys/ioctl.h +++ b/components/libc/compilers/common/include/sys/ioctl.h @@ -15,6 +15,10 @@ extern "C" { #endif +#ifdef RT_USING_MUSLLIBC +#include_next +#else + struct winsize { unsigned short ws_row; @@ -23,9 +27,6 @@ struct winsize unsigned short ws_ypixel; }; -#ifdef RT_USING_MUSLLIBC -#include -#else /* * Direction bits, which any architecture can choose to override * before including this file. diff --git a/components/libc/compilers/common/include/sys/unistd.h b/components/libc/compilers/common/include/sys/unistd.h index b9c64f3bb6..824891d57e 100644 --- a/components/libc/compilers/common/include/sys/unistd.h +++ b/components/libc/compilers/common/include/sys/unistd.h @@ -19,6 +19,8 @@ extern "C" { #endif +#define _POSIX_VDISABLE 0 + #define STDIN_FILENO 0 /* standard input file descriptor */ #define STDOUT_FILENO 1 /* standard output file descriptor */ #define STDERR_FILENO 2 /* standard error file descriptor */ diff --git a/components/libc/compilers/musl/fcntl.h b/components/libc/compilers/musl/fcntl.h index 05d466f848..9388f10de1 100644 --- a/components/libc/compilers/musl/fcntl.h +++ b/components/libc/compilers/musl/fcntl.h @@ -13,12 +13,37 @@ #include_next -#ifndef O_DIRECTORY -#define O_DIRECTORY 0x200000 -#endif +#define O_CREAT 0100 +#define O_EXCL 0200 +#define O_NOCTTY 0400 +#define O_TRUNC 01000 +#define O_APPEND 02000 +#define O_NONBLOCK 04000 +#define O_DSYNC 010000 +#define O_SYNC 04010000 +#define O_RSYNC 04010000 +#define O_DIRECTORY 040000 +#define O_NOFOLLOW 0100000 +#define O_CLOEXEC 02000000 + +#define O_ASYNC 020000 +#define O_DIRECT 0200000 +#define O_LARGEFILE 0400000 +#define O_NOATIME 01000000 +#define O_PATH 010000000 +#define O_TMPFILE 020040000 +#define O_NDELAY O_NONBLOCK #ifndef O_BINARY -#define O_BINARY 0x10000 +#define O_BINARY 00 #endif +#ifndef O_SEARCH +#define O_SEARCH O_PATH +#endif /* O_SEARCH */ + +#ifndef O_EXEC +#define O_EXEC O_PATH +#endif /* O_EXEC */ + #endif -- cgit v1.3.1