Reputation: 13440
I want to use the timerfd in a embedded device solution which runs a 2.6.39 kernel, but the cross compiler uses a too old glibc (2.5). Timerfd exists since 2.6.25, but only since glibc 2.8
When i try to use the header file from a newer glibc, the compiler complains about not finding the extern timerfd_create (undefined reference to 'timerfd_create'
), but I can't find the implementation anywhere in the glibc.
My question now is, how can I use the timerfd, regardless of the old glibc version? Do I have to invoke the syscall manually? If yes, how do I do so?
Upvotes: 0
Views: 540
Reputation: 213754
I can't find the implementation anywhere in the glibc.
Here is trick to finding it: with libc6-dbg installed:
gdb -q /lib/x86_64-linux-gnu/libc.so.6
(gdb) list timerfd_create
61 ../sysdeps/unix/syscall-template.S: No such file or directory.
This tells you that the implementation is simply to pass arguments directly to the kernel via system call.
Your implementation can then be:
#include <unistd.h>
#include <syscall.h>
#ifndef __NR_timerfd_create
#define __NR_timerfd_create 283
int timerfd_create(int clockid, int flags)
{
return syscall(__NR_timerfd_create, clockid, flags);
}
#endif
Upvotes: 1