summaryrefslogtreecommitdiff
path: root/components/libc/compilers/common/sys
diff options
context:
space:
mode:
authorxiangxistu <[email protected]>2022-01-20 20:53:47 +0800
committerGitHub <[email protected]>2022-01-20 20:53:47 +0800
commit075e04e344f0cea8d62504c244861f473921c495 (patch)
treeeccbd30b0b4dc05757836be4f076e66729f2155b /components/libc/compilers/common/sys
parent4dab5e0e59680ca77c5c3beab0d08ac15d1a1af9 (diff)
the support for PSE51 (#5534)
* [add] the function realization of signal for posix. * [update] the posix support for armclang. * [add] the new macro "RT_USING_POSIX_TIMER". * [modify] select "RT_USING_SOFT_TIMER" when use posix'timer. * [bug] optimize the logic for the "time_xxx" functions. * [modify] use "RT_USING_POSIX_TIMER" to protect the macro definition. * [modify] error code when except happened. * [delete] the "environ" is useless at this time.
Diffstat (limited to 'components/libc/compilers/common/sys')
-rw-r--r--components/libc/compilers/common/sys/signal.h38
-rw-r--r--components/libc/compilers/common/sys/time.h29
2 files changed, 65 insertions, 2 deletions
diff --git a/components/libc/compilers/common/sys/signal.h b/components/libc/compilers/common/sys/signal.h
index 9787958a37..041dd765b7 100644
--- a/components/libc/compilers/common/sys/signal.h
+++ b/components/libc/compilers/common/sys/signal.h
@@ -17,6 +17,19 @@ extern "C" {
#endif
#include <stdint.h>
+#include <sys/types.h>
+
+
+/* sigev_notify values
+ NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD. */
+
+#define SIGEV_NONE 1 /* No asynchronous notification shall be delivered */
+ /* when the event of interest occurs. */
+#define SIGEV_SIGNAL 2 /* A queued signal, with an application defined */
+ /* value, shall be delivered when the event of */
+ /* interest occurs. */
+#define SIGEV_THREAD 3 /* A notification function shall be called to */
+ /* perform notification. */
/* Signal Generation and Delivery, P1003.1b-1993, p. 63
NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
@@ -62,6 +75,16 @@ struct sigaction
int sa_flags;
};
+/*
+ * Structure used in sigaltstack call.
+ */
+typedef struct sigaltstack
+{
+ void *ss_sp; /* Stack base or pointer. */
+ int ss_flags; /* Flags. */
+ size_t ss_size; /* Stack size. */
+} stack_t;
+
#define SIG_SETMASK 0 /* set mask with sigprocmask() */
#define SIG_BLOCK 1 /* set of signals to block */
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
@@ -73,6 +96,15 @@ struct sigaction
#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
+int sigpending (sigset_t *set);
+int sigsuspend (const sigset_t *set);
+
+#include "time.h"
+int sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *timeout);
+int sigwait(const sigset_t *set, int *sig);
+int sigwaitinfo(const sigset_t *set, siginfo_t *info);
+int raise(int sig);
+int sigqueue(pid_t pid, int signo, const union sigval value);
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
#ifdef __ARMCC_VERSION
@@ -100,6 +132,9 @@ int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
#define SIGTTOU 22
#define SIGPOLL 23
#define SIGWINCH 24
+#define SIGXCPU 24 /* exceeded CPU time limit */
+#define SIGXFSZ 25 /* exceeded file size limit */
+#define SIGVTALRM 26 /* virtual time alarm */
/* #define SIGUSR1 25 */
/* #define SIGUSR2 26 */
#define SIGRTMIN 27
@@ -133,6 +168,9 @@ int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
#define SIGTTOU 22
#define SIGPOLL 23
#define SIGWINCH 24
+#define SIGXCPU 24 /* exceeded CPU time limit */
+#define SIGXFSZ 25 /* exceeded file size limit */
+#define SIGVTALRM 26 /* virtual time alarm */
#define SIGUSR1 25
#define SIGUSR2 26
#define SIGRTMIN 27
diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h
index 758333796d..a3af31b20b 100644
--- a/components/libc/compilers/common/sys/time.h
+++ b/components/libc/compilers/common/sys/time.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -60,6 +60,16 @@ struct timespec
time_t tv_sec; /* seconds */
long tv_nsec; /* and nanoseconds */
};
+
+/*
+ * Structure defined by POSIX.1b to be like a itimerval, but with
+ * timespecs. Used in the timer_*() system calls.
+ */
+struct itimerspec
+{
+ struct timespec it_interval;
+ struct timespec it_value;
+};
#endif
int stime(const time_t *t);
@@ -68,6 +78,9 @@ int gettimeofday(struct timeval *tv, struct timezone *tz);
int settimeofday(const struct timeval *tv, const struct timezone *tz);
#if defined(__ARMCC_VERSION) || defined (__ICCARM__)
struct tm *gmtime_r(const time_t *timep, struct tm *r);
+struct tm* localtime_r(const time_t* t, struct tm* r);
+char* asctime_r(const struct tm *t, char *buf);
+char *ctime_r(const time_t * tim_p, char * result);
#elif defined(_WIN32)
struct tm* gmtime_r(const time_t* timep, struct tm* r);
struct tm* gmtime(const time_t* t);
@@ -84,7 +97,7 @@ time_t time(time_t* t);
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
#endif /* RT_USING_POSIX_DELAY */
-#ifdef RT_USING_POSIX_CLOCK
+#if defined(RT_USING_POSIX_CLOCK) || defined (RT_USING_POSIX_TIMER)
/* POSIX clock and timer */
#define MILLISECOND_PER_SECOND 1000UL
#define MICROSECOND_PER_SECOND 1000000UL
@@ -110,7 +123,9 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
#ifndef CLOCK_MONOTONIC
#define CLOCK_MONOTONIC 4
#endif
+#endif /* defined(RT_USING_POSIX_CLOCK) || defined (RT_USING_POSIX_TIMER) */
+#ifdef RT_USING_POSIX_CLOCK
int clock_getres (clockid_t clockid, struct timespec *res);
int clock_gettime (clockid_t clockid, struct timespec *tp);
int clock_settime (clockid_t clockid, const struct timespec *tp);
@@ -118,6 +133,16 @@ int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqtp, s
int rt_timespec_to_tick(const struct timespec *time);
#endif /* RT_USING_POSIX_CLOCK */
+#ifdef RT_USING_POSIX_TIMER
+#include "signal.h"
+int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid);
+int timer_delete(timer_t timerid);
+int timer_getoverrun(timer_t timerid);
+int timer_gettime(timer_t timerid, struct itimerspec *its);
+int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
+ struct itimerspec *ovalue);
+#endif /* RT_USING_POSIX_TIMER */
+
/* timezone */
void tz_set(int8_t tz);
int8_t tz_get(void);