diff options
| author | Bernard Xiong <[email protected]> | 2021-02-20 12:12:56 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-02-20 12:12:56 +0800 |
| commit | b204651517aa1840d778f2f6fcfdc40207cab753 (patch) | |
| tree | d9fc79f86a3d5de3d8d8a82c48da313a4976c9e4 /components/libc/compilers/common/sys | |
| parent | e596921019839fdaf1c0c2c76a1aa13f4c083299 (diff) | |
| parent | 598aa86f750bdc96ffb427fc8507a426a99fc63f (diff) | |
Merge pull request #4333 from mysterywolf/pthread
[pthread][libc][time] 修改pthread与libc的时间函数若干问题
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 |
