4 dnl Check for the nanosleep function.
5 dnl If not found, use the supplied replacement.
8 # Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006 Free Software
11 # This file is free software; the Free Software Foundation
12 # gives unlimited permission to copy and/or distribute it,
13 # with or without modifications, as long as this notice is preserved.
15 AC_DEFUN([gl_FUNC_NANOSLEEP],
17 AC_LIBSOURCES([nanosleep.c])
19 nanosleep_save_libs=$LIBS
21 # Solaris 2.5.1 needs -lposix4 to get the nanosleep function.
22 # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
23 AC_SEARCH_LIBS([nanosleep], [rt posix4],
24 [test "$ac_cv_search_nanosleep" = "none required" ||
25 LIB_NANOSLEEP=$ac_cv_search_nanosleep])
26 AC_SUBST([LIB_NANOSLEEP])
28 AC_CACHE_CHECK([whether nanosleep works],
29 jm_cv_func_nanosleep_works,
31 dnl Persuade glibc and Solaris <time.h> to declare nanosleep.
32 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
34 AC_REQUIRE([AC_HEADER_TIME])
35 AC_CHECK_HEADERS_ONCE(sys/time.h)
37 # if TIME_WITH_SYS_TIME
38 # include <sys/time.h>
42 # include <sys/time.h>
51 struct timespec ts_sleep, ts_remaining;
54 exit (nanosleep (&ts_sleep, &ts_remaining) == 0 ? 0 : 1);
57 jm_cv_func_nanosleep_works=yes,
58 jm_cv_func_nanosleep_works=no,
59 dnl When crosscompiling, assume the worst.
60 jm_cv_func_nanosleep_works=no)
62 if test $jm_cv_func_nanosleep_works = no; then
64 AC_DEFINE(nanosleep, rpl_nanosleep,
65 [Define to rpl_nanosleep if the replacement function should be used.])
69 LIBS=$nanosleep_save_libs
72 # Prerequisites of lib/nanosleep.c.
73 AC_DEFUN([gl_PREREQ_NANOSLEEP],
75 AC_CHECK_FUNCS_ONCE(siginterrupt)