Fix typo in cross-compiling case: s/yes/no/.
[gnulib.git] / m4 / nanosleep.m4
1 #serial 3
2
3 dnl From Jim Meyering.
4 dnl Check for the nanosleep function.
5 dnl If not found, use the supplied replacement.
6 dnl
7
8 AC_DEFUN(jm_FUNC_NANOSLEEP,
9 [
10  # Solaris 2.5.1 needs -lposix4 to get the nanosleep function.
11  # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
12  AC_SEARCH_LIBS(nanosleep, [rt posix4])
13
14  AC_CACHE_CHECK([whether nanosleep works],
15   jm_cv_func_nanosleep_works,
16   [
17    AC_REQUIRE([AC_HEADER_TIME])
18    AC_TRY_RUN([
19 #   if TIME_WITH_SYS_TIME
20 #    include <sys/time.h>
21 #    include <time.h>
22 #   else
23 #    if HAVE_SYS_TIME_H
24 #     include <sys/time.h>
25 #    else
26 #     include <time.h>
27 #    endif
28 #   endif
29
30     int
31     main ()
32     {
33       struct timespec ts_sleep, ts_remaining;
34       ts_sleep.tv_sec = 0;
35       ts_sleep.tv_nsec = 1;
36       exit (nanosleep (&ts_sleep, &ts_remaining) == 0 ? 0 : 1);
37     }
38           ],
39          jm_cv_func_nanosleep_works=yes,
40          jm_cv_func_nanosleep_works=no,
41          dnl When crosscompiling, assume the worst.
42          jm_cv_func_nanosleep_works=no)
43   ])
44   if test $jm_cv_func_nanosleep_works = no; then
45     AC_SUBST(LIBOBJS)
46     LIBOBJS="$LIBOBJS nanosleep.$ac_objext"
47     AC_DEFINE_UNQUOTED(nanosleep, gnu_nanosleep,
48       [Define to gnu_nanosleep if the replacement function should be used.])
49   fi
50 ])