* @brief Retrieves the current time of a specified clock. * * This function retrieves the current time of the specified clock (identified by `clk`) and stores it in the * `struct timespec` pointed to by `ts`. The time is expressed in seconds and nanoseconds. The clock can be * one of several types, such as real-time, monotonic, or process-specific clocks. * * @param[in] clk The clock ID for
| 8092 | * @see sys_clock_settime(), sys_clock_getres() |
| 8093 | */ |
| 8094 | sysret_t sys_clock_gettime(clockid_t clk, struct timespec *ts) |
| 8095 | { |
| 8096 | int ret = 0; |
| 8097 | #ifdef ARCH_MM_MMU |
| 8098 | size_t size = sizeof(struct timespec); |
| 8099 | struct timespec *kts = NULL; |
| 8100 | |
| 8101 | if (!lwp_user_accessable((void *)ts, size)) |
| 8102 | { |
| 8103 | return -EFAULT; |
| 8104 | } |
| 8105 | |
| 8106 | kts = kmem_get(size); |
| 8107 | if (!kts) |
| 8108 | { |
| 8109 | return -ENOMEM; |
| 8110 | } |
| 8111 | |
| 8112 | ret = clock_gettime(clk, kts); |
| 8113 | if (ret != -1) |
| 8114 | lwp_put_to_user(ts, kts, size); |
| 8115 | |
| 8116 | if (ret < 0) |
| 8117 | { |
| 8118 | ret = GET_ERRNO(); |
| 8119 | } |
| 8120 | |
| 8121 | kmem_put(kts); |
| 8122 | |
| 8123 | return ret; |
| 8124 | #else |
| 8125 | if (!lwp_user_accessable((void *)ts, sizeof(struct timespec))) |
| 8126 | { |
| 8127 | return -EFAULT; |
| 8128 | } |
| 8129 | ret = clock_gettime(clk, ts); |
| 8130 | return (ret < 0 ? GET_ERRNO() : ret); |
| 8131 | #endif |
| 8132 | } |
| 8133 | |
| 8134 | /** |
| 8135 | * @brief Suspends the execution of the calling thread for the specified time duration. |
nothing calls this directly
no test coverage detected