|
Packit Service |
4684c1 |
# serial 39
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
dnl From Jim Meyering.
|
|
Packit Service |
4684c1 |
dnl Check for the nanosleep function.
|
|
Packit Service |
4684c1 |
dnl If not found, use the supplied replacement.
|
|
Packit Service |
4684c1 |
dnl
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
# Copyright (C) 1999-2001, 2003-2020 Free Software Foundation, Inc.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
# This file is free software; the Free Software Foundation
|
|
Packit Service |
4684c1 |
# gives unlimited permission to copy and/or distribute it,
|
|
Packit Service |
4684c1 |
# with or without modifications, as long as this notice is preserved.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
AC_DEFUN([gl_FUNC_NANOSLEEP],
|
|
Packit Service |
4684c1 |
[
|
|
Packit Service |
4684c1 |
AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
|
|
Packit Service |
4684c1 |
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
dnl Persuade glibc and Solaris <time.h> to declare nanosleep.
|
|
Packit Service |
4684c1 |
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
AC_CHECK_HEADERS_ONCE([sys/time.h])
|
|
Packit Service |
4684c1 |
AC_REQUIRE([gl_FUNC_SELECT])
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
AC_CHECK_DECLS_ONCE([alarm])
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
nanosleep_save_libs=$LIBS
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
# Solaris 2.5.1 needs -lposix4 to get the nanosleep function.
|
|
Packit Service |
4684c1 |
# Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
|
|
Packit Service |
4684c1 |
LIB_NANOSLEEP=
|
|
Packit Service |
4684c1 |
AC_SUBST([LIB_NANOSLEEP])
|
|
Packit Service |
4684c1 |
AC_SEARCH_LIBS([nanosleep], [rt posix4],
|
|
Packit Service |
4684c1 |
[test "$ac_cv_search_nanosleep" = "none required" ||
|
|
Packit Service |
4684c1 |
LIB_NANOSLEEP=$ac_cv_search_nanosleep])
|
|
Packit Service |
4684c1 |
if test "x$ac_cv_search_nanosleep" != xno; then
|
|
Packit Service |
4684c1 |
dnl The system has a nanosleep function.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
AC_REQUIRE([gl_MULTIARCH])
|
|
Packit Service |
4684c1 |
if test $APPLE_UNIVERSAL_BUILD = 1; then
|
|
Packit Service |
4684c1 |
# A universal build on Apple Mac OS X platforms.
|
|
Packit Service |
4684c1 |
# The test result would be 'no (mishandles large arguments)' in 64-bit
|
|
Packit Service |
4684c1 |
# mode but 'yes' in 32-bit mode. But we need a configuration result that
|
|
Packit Service |
4684c1 |
# is valid in both modes.
|
|
Packit Service |
4684c1 |
gl_cv_func_nanosleep='no (mishandles large arguments)'
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
AC_CACHE_CHECK([for working nanosleep],
|
|
Packit Service |
4684c1 |
[gl_cv_func_nanosleep],
|
|
Packit Service |
4684c1 |
[
|
|
Packit Service |
4684c1 |
AC_RUN_IFELSE(
|
|
Packit Service |
4684c1 |
[AC_LANG_SOURCE([[
|
|
Packit Service |
4684c1 |
#include <errno.h>
|
|
Packit Service |
4684c1 |
#include <limits.h>
|
|
Packit Service |
4684c1 |
#include <signal.h>
|
|
Packit Service |
4684c1 |
#if HAVE_SYS_TIME_H
|
|
Packit Service |
4684c1 |
#include <sys/time.h>
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
#include <time.h>
|
|
Packit Service |
4684c1 |
#include <unistd.h>
|
|
Packit Service |
4684c1 |
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
|
Packit Service |
4684c1 |
#define TYPE_MAXIMUM(t) \
|
|
Packit Service |
4684c1 |
((t) (! TYPE_SIGNED (t) \
|
|
Packit Service |
4684c1 |
? (t) -1 \
|
|
Packit Service |
4684c1 |
: ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#if HAVE_DECL_ALARM
|
|
Packit Service |
4684c1 |
static void
|
|
Packit Service |
4684c1 |
check_for_SIGALRM (int sig)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
if (sig != SIGALRM)
|
|
Packit Service |
4684c1 |
_exit (1);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
int
|
|
Packit Service |
4684c1 |
main ()
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
static struct timespec ts_sleep;
|
|
Packit Service |
4684c1 |
static struct timespec ts_remaining;
|
|
Packit Service |
4684c1 |
/* Test for major problems first. */
|
|
Packit Service |
4684c1 |
if (! nanosleep)
|
|
Packit Service |
4684c1 |
return 2;
|
|
Packit Service |
4684c1 |
ts_sleep.tv_sec = 0;
|
|
Packit Service |
4684c1 |
ts_sleep.tv_nsec = 1;
|
|
Packit Service |
4684c1 |
#if HAVE_DECL_ALARM
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
static struct sigaction act;
|
|
Packit Service |
4684c1 |
act.sa_handler = check_for_SIGALRM;
|
|
Packit Service |
4684c1 |
sigemptyset (&act.sa_mask);
|
|
Packit Service |
4684c1 |
sigaction (SIGALRM, &act, NULL);
|
|
Packit Service |
4684c1 |
alarm (1);
|
|
Packit Service |
4684c1 |
if (nanosleep (&ts_sleep, NULL) != 0)
|
|
Packit Service |
4684c1 |
return 3;
|
|
Packit Service |
4684c1 |
/* Test for a minor problem: the handling of large arguments. */
|
|
Packit Service |
4684c1 |
ts_sleep.tv_sec = TYPE_MAXIMUM (time_t);
|
|
Packit Service |
4684c1 |
ts_sleep.tv_nsec = 999999999;
|
|
Packit Service |
4684c1 |
alarm (1);
|
|
Packit Service |
4684c1 |
if (nanosleep (&ts_sleep, &ts_remaining) != -1)
|
|
Packit Service |
4684c1 |
return 4;
|
|
Packit Service |
4684c1 |
if (errno != EINTR)
|
|
Packit Service |
4684c1 |
return 5;
|
|
Packit Service |
4684c1 |
if (ts_remaining.tv_sec <= TYPE_MAXIMUM (time_t) - 10)
|
|
Packit Service |
4684c1 |
return 6;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
#else /* A simpler test for native Windows. */
|
|
Packit Service |
4684c1 |
if (nanosleep (&ts_sleep, &ts_remaining) < 0)
|
|
Packit Service |
4684c1 |
return 3;
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}]])],
|
|
Packit Service |
4684c1 |
[gl_cv_func_nanosleep=yes],
|
|
Packit Service |
4684c1 |
[case $? in dnl (
|
|
Packit Service |
4684c1 |
4|5|6) gl_cv_func_nanosleep='no (mishandles large arguments)';; dnl (
|
|
Packit Service |
4684c1 |
*) gl_cv_func_nanosleep=no;;
|
|
Packit Service |
4684c1 |
esac],
|
|
Packit Service |
4684c1 |
[case "$host_os" in dnl ((
|
|
Packit Service |
4684c1 |
linux*) # Guess it halfway works when the kernel is Linux.
|
|
Packit Service |
4684c1 |
gl_cv_func_nanosleep='guessing no (mishandles large arguments)' ;;
|
|
Packit Service |
4684c1 |
mingw*) # Guess no on native Windows.
|
|
Packit Service |
4684c1 |
gl_cv_func_nanosleep='guessing no' ;;
|
|
Packit Service |
4684c1 |
*) # If we don't know, obey --enable-cross-guesses.
|
|
Packit Service |
4684c1 |
gl_cv_func_nanosleep="$gl_cross_guess_normal" ;;
|
|
Packit Service |
4684c1 |
esac
|
|
Packit Service |
4684c1 |
])
|
|
Packit Service |
4684c1 |
])
|
|
Packit Service |
4684c1 |
case "$gl_cv_func_nanosleep" in
|
|
Packit Service |
4684c1 |
*yes)
|
|
Packit Service |
4684c1 |
REPLACE_NANOSLEEP=0
|
|
Packit Service |
4684c1 |
;;
|
|
Packit Service |
4684c1 |
*)
|
|
Packit Service |
4684c1 |
REPLACE_NANOSLEEP=1
|
|
Packit Service |
4684c1 |
case "$gl_cv_func_nanosleep" in
|
|
Packit Service |
4684c1 |
*"mishandles large arguments"*)
|
|
Packit Service |
4684c1 |
AC_DEFINE([HAVE_BUG_BIG_NANOSLEEP], [1],
|
|
Packit Service |
4684c1 |
[Define to 1 if nanosleep mishandles large arguments.])
|
|
Packit Service |
4684c1 |
;;
|
|
Packit Service |
4684c1 |
*)
|
|
Packit Service |
4684c1 |
# The replacement uses select(). Add $LIBSOCKET to $LIB_NANOSLEEP.
|
|
Packit Service |
4684c1 |
for ac_lib in $LIBSOCKET; do
|
|
Packit Service |
4684c1 |
case " $LIB_NANOSLEEP " in
|
|
Packit Service |
4684c1 |
*" $ac_lib "*) ;;
|
|
Packit Service |
4684c1 |
*) LIB_NANOSLEEP="$LIB_NANOSLEEP $ac_lib";;
|
|
Packit Service |
4684c1 |
esac
|
|
Packit Service |
4684c1 |
done
|
|
Packit Service |
4684c1 |
;;
|
|
Packit Service |
4684c1 |
esac
|
|
Packit Service |
4684c1 |
;;
|
|
Packit Service |
4684c1 |
esac
|
|
Packit Service |
4684c1 |
else
|
|
Packit Service |
4684c1 |
HAVE_NANOSLEEP=0
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
LIBS=$nanosleep_save_libs
|
|
Packit Service |
4684c1 |
])
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
# Prerequisites of lib/nanosleep.c.
|
|
Packit Service |
4684c1 |
AC_DEFUN([gl_PREREQ_NANOSLEEP],
|
|
Packit Service |
4684c1 |
[
|
|
Packit Service |
4684c1 |
AC_CHECK_HEADERS_ONCE([sys/select.h])
|
|
Packit Service |
4684c1 |
gl_PREREQ_SIG_HANDLER_H
|
|
Packit Service |
4684c1 |
])
|