4 dnl Check for the nanosleep function.
5 dnl If not found, use the supplied replacement.
8 # Copyright (C) 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
9 # This file is free software; the Free Software Foundation
10 # gives unlimited permission to copy and/or distribute it,
11 # with or without modifications, as long as this notice is preserved.
13 AC_DEFUN([gl_FUNC_NANOSLEEP],
15 nanosleep_save_libs=$LIBS
17 # Solaris 2.5.1 needs -lposix4 to get the nanosleep function.
18 # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
19 AC_SEARCH_LIBS([nanosleep], [rt posix4],
20 [test "$ac_cv_search_nanosleep" = "none required" ||
21 LIB_NANOSLEEP=$ac_cv_search_nanosleep])
22 AC_SUBST([LIB_NANOSLEEP])
24 AC_CACHE_CHECK([whether nanosleep works],
25 jm_cv_func_nanosleep_works,
27 AC_REQUIRE([AC_HEADER_TIME])
28 AC_CHECK_HEADERS_ONCE(sys/time.h)
30 # if TIME_WITH_SYS_TIME
31 # include <sys/time.h>
35 # include <sys/time.h>
44 struct timespec ts_sleep, ts_remaining;
47 exit (nanosleep (&ts_sleep, &ts_remaining) == 0 ? 0 : 1);
50 jm_cv_func_nanosleep_works=yes,
51 jm_cv_func_nanosleep_works=no,
52 dnl When crosscompiling, assume the worst.
53 jm_cv_func_nanosleep_works=no)
55 if test $jm_cv_func_nanosleep_works = no; then
57 AC_DEFINE(nanosleep, rpl_nanosleep,
58 [Define to rpl_nanosleep if the replacement function should be used.])
62 LIBS=$nanosleep_save_libs
65 # Prerequisites of lib/nanosleep.c.
66 AC_DEFUN([gl_PREREQ_NANOSLEEP],
68 AC_CHECK_HEADERS_ONCE(unistd.h)