source: grub-pc/trunk/fuentes/m4/sleep.m4 @ 22

Last change on this file since 22 was 22, checked in by mabarracus, 4 years ago

updated version and apply net.ifnames=0 into debian/rules

File size: 2.0 KB
Line 
1# sleep.m4 serial 7
2dnl Copyright (C) 2007-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_SLEEP],
8[
9  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
11  dnl We expect to see the declaration of sleep() in a header file.
12  dnl Older versions of mingw have a sleep() function that is an alias to
13  dnl _sleep() in MSVCRT. It has a different signature than POSIX sleep():
14  dnl it takes the number of milliseconds as argument and returns void.
15  dnl mingw does not declare this function.
16  AC_CHECK_DECLS([sleep], , , [[#include <unistd.h>]])
17  AC_CHECK_FUNCS_ONCE([sleep])
18  if test $ac_cv_have_decl_sleep != yes; then
19    HAVE_SLEEP=0
20  else
21    dnl Cygwin 1.5.x has a bug where sleep can't exceed 49.7 days.
22    AC_CACHE_CHECK([for working sleep], [gl_cv_func_sleep_works],
23      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
24#include <errno.h>
25#include <unistd.h>
26#include <signal.h>
27static void
28handle_alarm (int sig)
29{
30  if (sig != SIGALRM)
31    _exit (2);
32}
33]], [[
34    /* Failure to compile this test due to missing alarm is okay,
35       since all such platforms (mingw) also lack sleep.  */
36    unsigned int pentecost = 50 * 24 * 60 * 60; /* 50 days.  */
37    unsigned int remaining;
38    signal (SIGALRM, handle_alarm);
39    alarm (1);
40    remaining = sleep (pentecost);
41    if (remaining > pentecost)
42      return 3;
43    if (remaining <= pentecost - 10)
44      return 4;
45    return 0;
46    ]])],
47      [gl_cv_func_sleep_works=yes], [gl_cv_func_sleep_works=no],
48      [case "$host_os" in
49                 # Guess yes on glibc systems.
50         *-gnu*) gl_cv_func_sleep_works="guessing yes" ;;
51                 # If we don't know, assume the worst.
52         *)      gl_cv_func_sleep_works="guessing no" ;;
53       esac
54      ])])
55    case "$gl_cv_func_sleep_works" in
56      *yes) ;;
57      *)
58        REPLACE_SLEEP=1
59        ;;
60    esac
61  fi
62])
Note: See TracBrowser for help on using the repository browser.