diff options
| author | Meco Man <[email protected]> | 2021-02-12 01:30:41 +0800 |
|---|---|---|
| committer | Meco Man <[email protected]> | 2021-02-12 01:30:41 +0800 |
| commit | 291fe36139788cf31bd5c6cdb2ac3919dfa0b0cb (patch) | |
| tree | 3afe6c1bf30ff9b588dc81e70d419b80b242e716 /components/libc/compilers/common/sys/time.h | |
| parent | f0805a7973ffe62e459da7748cbada62bccf98b9 (diff) | |
[pthread][libc] move 'clock_time' to libc
Diffstat (limited to 'components/libc/compilers/common/sys/time.h')
| -rw-r--r-- | components/libc/compilers/common/sys/time.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h index 599b8b5262..34ca9427b9 100644 --- a/components/libc/compilers/common/sys/time.h +++ b/components/libc/compilers/common/sys/time.h @@ -10,6 +10,7 @@ #ifndef _SYS_TIME_H_ #define _SYS_TIME_H_ +#include <rtconfig.h> #include <time.h> #ifdef __cplusplus @@ -53,6 +54,38 @@ 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_PTHREADS +/* 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); +#endif /*RT_USING_PTHREADS*/ + #ifdef __cplusplus } #endif |
