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.
10 lines
245 B
C
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);
|
|
}
|