| 1 | #serial 14
|
|---|
| 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 | # Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005 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.
|
|---|
| 12 |
|
|---|
| 13 | AC_DEFUN([gl_FUNC_NANOSLEEP],
|
|---|
| 14 | [
|
|---|
| 15 | AC_LIBSOURCES([nanosleep.c])
|
|---|
| 16 |
|
|---|
| 17 | nanosleep_save_libs=$LIBS
|
|---|
| 18 |
|
|---|
| 19 | # Solaris 2.5.1 needs -lposix4 to get the nanosleep function.
|
|---|
| 20 | # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
|
|---|
| 21 | AC_SEARCH_LIBS([nanosleep], [rt posix4],
|
|---|
| 22 | [test "$ac_cv_search_nanosleep" = "none required" ||
|
|---|
| 23 | LIB_NANOSLEEP=$ac_cv_search_nanosleep])
|
|---|
| 24 | AC_SUBST([LIB_NANOSLEEP])
|
|---|
| 25 |
|
|---|
| 26 | AC_CACHE_CHECK([whether nanosleep works],
|
|---|
| 27 | jm_cv_func_nanosleep_works,
|
|---|
| 28 | [
|
|---|
| 29 | AC_REQUIRE([AC_HEADER_TIME])
|
|---|
| 30 | AC_CHECK_HEADERS_ONCE(sys/time.h)
|
|---|
| 31 | AC_TRY_RUN([
|
|---|
| 32 | # if TIME_WITH_SYS_TIME
|
|---|
| 33 | # include <sys/time.h>
|
|---|
| 34 | # include <time.h>
|
|---|
| 35 | # else
|
|---|
| 36 | # if HAVE_SYS_TIME_H
|
|---|
| 37 | # include <sys/time.h>
|
|---|
| 38 | # else
|
|---|
| 39 | # include <time.h>
|
|---|
| 40 | # endif
|
|---|
| 41 | # endif
|
|---|
| 42 |
|
|---|
| 43 | int
|
|---|
| 44 | main ()
|
|---|
| 45 | {
|
|---|
| 46 | struct timespec ts_sleep, ts_remaining;
|
|---|
| 47 | ts_sleep.tv_sec = 0;
|
|---|
| 48 | ts_sleep.tv_nsec = 1;
|
|---|
| 49 | exit (nanosleep (&ts_sleep, &ts_remaining) == 0 ? 0 : 1);
|
|---|
| 50 | }
|
|---|
| 51 | ],
|
|---|
| 52 | jm_cv_func_nanosleep_works=yes,
|
|---|
| 53 | jm_cv_func_nanosleep_works=no,
|
|---|
| 54 | dnl When crosscompiling, assume the worst.
|
|---|
| 55 | jm_cv_func_nanosleep_works=no)
|
|---|
| 56 | ])
|
|---|
| 57 | if test $jm_cv_func_nanosleep_works = no; then
|
|---|
| 58 | AC_LIBOBJ(nanosleep)
|
|---|
| 59 | AC_DEFINE(nanosleep, rpl_nanosleep,
|
|---|
| 60 | [Define to rpl_nanosleep if the replacement function should be used.])
|
|---|
| 61 | gl_PREREQ_NANOSLEEP
|
|---|
| 62 | fi
|
|---|
| 63 |
|
|---|
| 64 | LIBS=$nanosleep_save_libs
|
|---|
| 65 | ])
|
|---|
| 66 |
|
|---|
| 67 | # Prerequisites of lib/nanosleep.c.
|
|---|
| 68 | AC_DEFUN([gl_PREREQ_NANOSLEEP],
|
|---|
| 69 | [
|
|---|
| 70 | AC_CHECK_FUNCS_ONCE(siginterrupt)
|
|---|
| 71 | ])
|
|---|