libc: Add support for POSIX timers
This commit is contained in:
parent
17b44a8ce6
commit
3231a1296d
@ -4,8 +4,11 @@
|
||||
#define _TIME_H
|
||||
|
||||
#include <bits/clockid.h>
|
||||
#include <bits/itimer.h>
|
||||
#include <bits/sigevent.h>
|
||||
#include <bits/struct_tm.h>
|
||||
#include <bits/timespec.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef long int clock_t;
|
||||
|
||||
@ -58,6 +61,18 @@ extern "C"
|
||||
/* Estimate the CPU time used by a process. */
|
||||
clock_t clock(void);
|
||||
|
||||
/* Create a new POSIX timer. */
|
||||
int timer_create(clockid_t clockid, struct sigevent* sevp, timer_t* timerid);
|
||||
|
||||
/* Get the current time remaining for a POSIX timer. */
|
||||
int timer_gettime(timer_t timerid, struct itimerspec* value);
|
||||
|
||||
/* Set the time remaining and interval for a POSIX timer. */
|
||||
int timer_settime(timer_t timerid, int flags, const struct itimerspec* new_value, struct itimerspec* old_value);
|
||||
|
||||
/* Delete an existing POSIX timer. */
|
||||
int timer_delete(timer_t timerid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -206,4 +206,28 @@ extern "C"
|
||||
long rc = syscall(SYS_setitimer, which, new_timer, old_timer);
|
||||
__errno_return(rc, int);
|
||||
}
|
||||
|
||||
int timer_create(clockid_t clockid, struct sigevent* sevp, timer_t* timerid)
|
||||
{
|
||||
long rc = syscall(SYS_timer_create, clockid, sevp, timerid);
|
||||
__errno_return(rc, int);
|
||||
}
|
||||
|
||||
int timer_gettime(timer_t timerid, struct itimerspec* value)
|
||||
{
|
||||
long rc = syscall(SYS_timer_gettime, timerid, value);
|
||||
__errno_return(rc, int);
|
||||
}
|
||||
|
||||
int timer_settime(timer_t timerid, int flags, const struct itimerspec* new_value, struct itimerspec* old_value)
|
||||
{
|
||||
long rc = syscall(SYS_timer_settime, timerid, flags, new_value, old_value);
|
||||
__errno_return(rc, int);
|
||||
}
|
||||
|
||||
int timer_delete(timer_t timerid)
|
||||
{
|
||||
long rc = syscall(SYS_timer_delete, timerid);
|
||||
__errno_return(rc, int);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user