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, nanosleep.h])
19
dnl Persuade glibc and Solaris <time.h> to declare nanosleep.
20
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
22
AC_REQUIRE([AC_HEADER_TIME])
23
AC_CHECK_HEADERS_ONCE(sys/time.h)
25
nanosleep_save_libs=$LIBS
27
# Solaris 2.5.1 needs -lposix4 to get the nanosleep function.
28
# Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
29
AC_SEARCH_LIBS([nanosleep], [rt posix4],
30
[test "$ac_cv_search_nanosleep" = "none required" ||
31
LIB_NANOSLEEP=$ac_cv_search_nanosleep])
32
AC_SUBST([LIB_NANOSLEEP])
34
AC_CACHE_CHECK([for nanosleep],
35
[gl_cv_func_nanosleep],
37
AC_LINK_IFELSE([AC_LANG_SOURCE([[
38
# if TIME_WITH_SYS_TIME
39
# include <sys/time.h>
43
# include <sys/time.h>
52
struct timespec ts_sleep, ts_remaining;
55
return nanosleep (&ts_sleep, &ts_remaining) < 0;
58
[gl_cv_func_nanosleep=yes],
59
[gl_cv_func_nanosleep=no])
61
if test $gl_cv_func_nanosleep = no; then
63
AC_DEFINE(nanosleep, rpl_nanosleep,
64
[Define to rpl_nanosleep if the replacement function should be used.])
68
LIBS=$nanosleep_save_libs
71
# Prerequisites of lib/nanosleep.c.
72
AC_DEFUN([gl_PREREQ_NANOSLEEP],
74
AC_CHECK_FUNCS_ONCE(siginterrupt)
75
AC_CHECK_HEADERS_ONCE(sys/select.h)