4 dnl Check for the nanosleep function.
5 dnl If not found, use the supplied replacement.
8 AC_DEFUN([jm_FUNC_NANOSLEEP],
10 nanosleep_save_libs=$LIBS
12 # Solaris 2.5.1 needs -lposix4 to get the nanosleep function.
13 # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
14 AC_SEARCH_LIBS(nanosleep, [rt posix4], [LIB_NANOSLEEP=$ac_cv_search_nanosleep])
15 AC_SUBST(LIB_NANOSLEEP)
17 AC_CACHE_CHECK([whether nanosleep works],
18 jm_cv_func_nanosleep_works,
20 AC_REQUIRE([AC_HEADER_TIME])
21 AC_CHECK_HEADERS_ONCE(sys/time.h)
23 # if TIME_WITH_SYS_TIME
24 # include <sys/time.h>
28 # include <sys/time.h>
37 struct timespec ts_sleep, ts_remaining;
40 exit (nanosleep (&ts_sleep, &ts_remaining) == 0 ? 0 : 1);
43 jm_cv_func_nanosleep_works=yes,
44 jm_cv_func_nanosleep_works=no,
45 dnl When crosscompiling, assume the worst.
46 jm_cv_func_nanosleep_works=no)
48 if test $jm_cv_func_nanosleep_works = no; then
50 AC_DEFINE(nanosleep, rpl_nanosleep,
51 [Define to rpl_nanosleep if the replacement function should be used.])
55 LIBS=$nanosleep_save_libs
58 # Prerequisites of lib/nanosleep.c.
59 AC_DEFUN([gl_PREREQ_NANOSLEEP],
61 AC_CHECK_HEADERS_ONCE(unistd.h)