X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Fnanosleep.m4;h=88e630e8970ff20d35a4bd4187e89016a35855e4;hb=901bc47c9a8db854db97bb28780352748020c81d;hp=e4b634181be795e199c5e64b1e8475799407739e;hpb=c3a36c262d8af12176ebd5f10dc6f7ff9a743f97;p=gnulib.git diff --git a/m4/nanosleep.m4 b/m4/nanosleep.m4 index e4b634181..88e630e89 100644 --- a/m4/nanosleep.m4 +++ b/m4/nanosleep.m4 @@ -1,15 +1,48 @@ -#serial 1 +#serial 18 dnl From Jim Meyering. -dnl FIXME +dnl Check for the nanosleep function. +dnl If not found, use the supplied replacement. dnl -AC_DEFUN(jm_FUNC_NANOSLEEP, +# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006 Free Software +# Foundation, Inc. + +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_NANOSLEEP], [ - AC_CACHE_CHECK([whether nanosleep works], - jm_cv_func_nanosleep_works, - [AC_TRY_RUN([ -# include + dnl Persuade glibc and Solaris to declare nanosleep. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([AC_HEADER_TIME]) + AC_CHECK_HEADERS_ONCE(sys/time.h) + + nanosleep_save_libs=$LIBS + + # Solaris 2.5.1 needs -lposix4 to get the nanosleep function. + # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4. + AC_SEARCH_LIBS([nanosleep], [rt posix4], + [test "$ac_cv_search_nanosleep" = "none required" || + LIB_NANOSLEEP=$ac_cv_search_nanosleep]) + AC_SUBST([LIB_NANOSLEEP]) + + AC_CACHE_CHECK([for nanosleep], + [gl_cv_func_nanosleep], + [ + AC_LINK_IFELSE([AC_LANG_SOURCE([[ +# if TIME_WITH_SYS_TIME +# include +# include +# else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +# endif int main () @@ -17,18 +50,25 @@ AC_DEFUN(jm_FUNC_NANOSLEEP, struct timespec ts_sleep, ts_remaining; ts_sleep.tv_sec = 0; ts_sleep.tv_nsec = 1; - exit (nanosleep (&ts_sleep, &ts_remaining) == 0 ? 1 : 0); + return nanosleep (&ts_sleep, &ts_remaining) < 0; } - ], - jm_cv_func_nanosleep_works=yes, - jm_cv_func_nanosleep_works=no, - dnl When crosscompiling, assume the worst. - jm_cv_func_nanosleep_works=yes) + ]])], + [gl_cv_func_nanosleep=yes], + [gl_cv_func_nanosleep=no]) ]) - if test $jm_cv_func_nanosleep_works = no; then - AC_SUBST(LIBOBJS) - LIBOBJS="$LIBOBJS nanosleep.$ac_objext" - AC_DEFINE_UNQUOTED(nanosleep, gnu_nanosleep, - [Define to gnu_nanosleep if the replacement function should be used.]) + if test $gl_cv_func_nanosleep = no; then + AC_LIBOBJ(nanosleep) + AC_DEFINE(nanosleep, rpl_nanosleep, + [Define to rpl_nanosleep if the replacement function should be used.]) + gl_PREREQ_NANOSLEEP fi + + LIBS=$nanosleep_save_libs +]) + +# Prerequisites of lib/nanosleep.c. +AC_DEFUN([gl_PREREQ_NANOSLEEP], +[ + AC_CHECK_FUNCS_ONCE(siginterrupt) + AC_CHECK_HEADERS_ONCE(sys/select.h) ])