1 /* 2 * Copyright (c) 2006-2021, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2021-04-27 flybreak the first version. 9 */ 10 11 #include <arm-tpl.h> 12 #include <sys/time.h> 13 #include <rtthread.h> 14 __ARM_TPL_clock_realtime(__ARM_TPL_timespec_t * __ts)15extern "C" int __ARM_TPL_clock_realtime(__ARM_TPL_timespec_t* __ts) 16 { 17 unsigned int t = std::time(nullptr); 18 __ts->tv_sec = t; 19 __ts->tv_nsec = 0; 20 return 0; 21 } 22 __ARM_TPL_clock_monotonic(__ARM_TPL_timespec_t * __ts)23extern "C" int __ARM_TPL_clock_monotonic(__ARM_TPL_timespec_t* __ts) 24 { 25 unsigned int t = rt_tick_get(); 26 __ts->tv_sec = t / RT_TICK_PER_SECOND; 27 __ts->tv_nsec = (t %RT_TICK_PER_SECOND) * NANOSECOND_PER_TICK ; 28 return 0; 29 } 30