1 /* 2 * Copyright (c) 2006-2018, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2017-12-31 Bernard the first version 9 */ 10 11 #ifndef CLOCK_TIME_H__ 12 #define CLOCK_TIME_H__ 13 14 /* posix clock and timer */ 15 #define MILLISECOND_PER_SECOND 1000UL 16 #define MICROSECOND_PER_SECOND 1000000UL 17 #define NANOSECOND_PER_SECOND 1000000000UL 18 19 #define MILLISECOND_PER_TICK (MILLISECOND_PER_SECOND / RT_TICK_PER_SECOND) 20 #define MICROSECOND_PER_TICK (MICROSECOND_PER_SECOND / RT_TICK_PER_SECOND) 21 #define NANOSECOND_PER_TICK (NANOSECOND_PER_SECOND / RT_TICK_PER_SECOND) 22 23 #ifndef CLOCK_REALTIME 24 #define CLOCK_REALTIME 1 25 #endif 26 27 #define CLOCK_CPUTIME_ID 2 28 29 #ifndef CLOCK_PROCESS_CPUTIME_ID 30 #define CLOCK_PROCESS_CPUTIME_ID CLOCK_CPUTIME_ID 31 #endif 32 #ifndef CLOCK_THREAD_CPUTIME_ID 33 #define CLOCK_THREAD_CPUTIME_ID CLOCK_CPUTIME_ID 34 #endif 35 36 #ifndef CLOCK_MONOTONIC 37 #define CLOCK_MONOTONIC 4 38 #endif 39 40 int clock_getres (clockid_t clockid, struct timespec *res); 41 int clock_gettime (clockid_t clockid, struct timespec *tp); 42 int clock_settime (clockid_t clockid, const struct timespec *tp); 43 44 #endif 45