diff options
| author | Meco Jianting Man <[email protected]> | 2021-02-19 22:24:14 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-02-19 22:24:14 -0600 |
| commit | c21f018b4a6ea88e1cbec86514056629a25ccb67 (patch) | |
| tree | 0943648fde317bca195acb32dcf2145d0f1b41ff /components/libc/compilers/common/sys | |
| parent | ae2d414ca1580fc4ae8ab5618db01cb75af4d425 (diff) | |
| parent | 3b003937e8ac9237956615349f6a42e4d5237f03 (diff) | |
Merge pull request #19 from RT-Thread/master
pr
Diffstat (limited to 'components/libc/compilers/common/sys')
| -rw-r--r-- | components/libc/compilers/common/sys/time.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h index 599b8b5262..e4d60d2d11 100644 --- a/components/libc/compilers/common/sys/time.h +++ b/components/libc/compilers/common/sys/time.h @@ -6,10 +6,12 @@ * Change Logs: * Date Author Notes * 2020-09-07 Meco Man combine gcc armcc iccarm + * 2021-02-12 Meco Man move all definitions located in <clock_time.h> to this file */ #ifndef _SYS_TIME_H_ #define _SYS_TIME_H_ +#include <rtconfig.h> #include <time.h> #ifdef __cplusplus @@ -53,6 +55,40 @@ time_t timegm(struct tm * const t); int gettimeofday(struct timeval *tv, struct timezone *tz); int settimeofday(const struct timeval *tv, const struct timezone *tz); +#ifdef RT_USING_POSIX +#include <sys/types.h> +/* posix clock and timer */ +#define MILLISECOND_PER_SECOND 1000UL +#define MICROSECOND_PER_SECOND 1000000UL +#define NANOSECOND_PER_SECOND 1000000000UL + +#define MILLISECOND_PER_TICK (MILLISECOND_PER_SECOND / RT_TICK_PER_SECOND) +#define MICROSECOND_PER_TICK (MICROSECOND_PER_SECOND / RT_TICK_PER_SECOND) +#define NANOSECOND_PER_TICK (NANOSECOND_PER_SECOND / RT_TICK_PER_SECOND) + +#ifndef CLOCK_REALTIME +#define CLOCK_REALTIME 1 +#endif + +#define CLOCK_CPUTIME_ID 2 + +#ifndef CLOCK_PROCESS_CPUTIME_ID +#define CLOCK_PROCESS_CPUTIME_ID CLOCK_CPUTIME_ID +#endif +#ifndef CLOCK_THREAD_CPUTIME_ID +#define CLOCK_THREAD_CPUTIME_ID CLOCK_CPUTIME_ID +#endif + +#ifndef CLOCK_MONOTONIC +#define CLOCK_MONOTONIC 4 +#endif + +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); +int clock_time_to_tick(const struct timespec *time); +#endif /* RT_USING_POSIX */ + #ifdef __cplusplus } #endif |
