zephyr/lib/posix/nanosleep.c
Tom Finet d09a1c39f9 posix: implement clock_nanosleep
Implements the posix clock_nanosleep function, where both relative
and absolute sleeps are made as absolute sleeps.
The nanosleep() function is a special case of clock_nanosleep(),
and so has been refactored to simply call it.

Signed-off-by: Tom Finet <tom.codeninja@gmail.com>
2023-08-30 13:02:58 -07:00

25 lines
541 B
C

/*
* Copyright (c) 2018 Friedt Professional Engineering Services, Inc
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
#include <zephyr/kernel.h>
#include <limits.h>
#include <errno.h>
/* required for struct timespec */
#include <zephyr/posix/time.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys_clock.h>
/**
* @brief Suspend execution for nanosecond intervals.
*
* See IEEE 1003.1
*/
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
{
return clock_nanosleep(CLOCK_MONOTONIC, 0, rqtp, rmtp);
}