| 255 | } |
| 256 | |
| 257 | static void runtime_wait_tick(uint64_t deadline_ms) { |
| 258 | uint64_t now_ms = cbm_now_ms(); |
| 259 | if (now_ms >= deadline_ms) { |
| 260 | return; |
| 261 | } |
| 262 | uint64_t remaining_ms = deadline_ms - now_ms; |
| 263 | struct timespec pause = { |
| 264 | .tv_sec = 0, |
| 265 | .tv_nsec = remaining_ms > 1 ? RUNTIME_WAIT_POLL_NS : (long)(remaining_ms * 1000000ULL), |
| 266 | }; |
| 267 | (void)cbm_nanosleep(&pause, NULL); |
| 268 | } |
| 269 | |
| 270 | static void runtime_put_u32(uint8_t *out, uint32_t value) { |
| 271 | out[0] = (uint8_t)(value >> 24); |
no test coverage detected