Files
semi-libc/src/time/timer_gettime.c
T
Rich Felker 3990c5c6a4 avoid all malloc/free in timer creation/destruction
instead of allocating a userspace structure for signal-based timers,
simply use the kernel timer id. we use the fact that thread pointers
will always be zero in the low bit (actually more) to encode integer
timerid values as pointers.

also, this change ensures that the timer_destroy syscall has completed
before the library timer_destroy function returns, in case it matters.
2011-03-30 13:04:55 -04:00

10 lines
245 B
C

#include <time.h>
#include "pthread_impl.h"
int timer_gettime(timer_t t, struct itimerspec *val)
{
if ((uintptr_t)t & 1) t = (void *)((unsigned long)t / 2);
else t = ((pthread_t)t)->result;
return syscall(SYS_timer_gettime, (long)t, val);
}