Just a dead end. I tried again to add nanosleep to R_get_location_with_* functions:
configure.in:
have_nanosleep=false
NANOSLEEPLIB=
AC_CHECK_FUNC(nanosleep, have_nanosleep=true , [
AC_CHECK_LIB(nanoslee, rt, NANOSLEEPLIB=-lrt have_nanosleep=true, [
AC_CHECK_LIB(nanosleep, posix4, NANOSLEEPLIB=-lposix4 have_nanosleep=true, [
AC_MSG_WARN([*** Unable to locate nanosleep() function.])
])])])
AC_SUBST(NANOSLEEPLIB)
if ${have_nanosleep}; then
AC_DEFINE(HAVE_NANOSLEEP)
fi
R_get_location_with_*:
#ifdef HAVE_NANOSLEEP
{
struct timespec req;
int ret;
req.tv_sec=0;
req.tv_nsec=1000000;
ret = nanosleep(&req,NULL);
}
#endif
It does not work, it is too slow, I dont know why, man page:
| The current implementation of nanosleep is based on the normal
| kernel timer mechanism, which has a resolution of 1/HZ s
| (i.e, 10 ms on | Linux/i386 and 1 ms on Linux/Alpha).
which should be enough.
Radim