annotate m4/sleep.m4 @ 436:4c272633fce2 3.0 3.0

Added missing files
author lost@l-w.ca
date Fri, 29 Oct 2010 19:28:54 -0600
parents b8bf63962a99
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
434
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
1 # sleep.m4 serial 3
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
2 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
6
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
7 AC_DEFUN([gl_FUNC_SLEEP],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
8 [
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
10 dnl We expect to see the declaration of sleep() in a header file.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
11 dnl Older versions of mingw have a sleep() function that is an alias to
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
12 dnl _sleep() in MSVCRT. It has a different signature than POSIX sleep():
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
13 dnl it takes the number of milliseconds as argument and returns void.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
14 dnl mingw does not declare this function.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
15 AC_CHECK_DECLS([sleep], , , [#include <unistd.h>])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
16 AC_CHECK_FUNCS_ONCE([sleep])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
17 if test $ac_cv_have_decl_sleep != yes; then
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
18 HAVE_SLEEP=0
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
19 AC_LIBOBJ([sleep])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
20 else
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
21 dnl Cygwin 1.5.x has a bug where sleep can't exceed 49.7 days.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
22 AC_CACHE_CHECK([for working sleep], [gl_cv_func_sleep_works],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
23 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
24 #include <errno.h>
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
25 #include <unistd.h>
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
26 #include <signal.h>
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
27 static void
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
28 handle_alarm (int sig)
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
29 {
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
30 if (sig != SIGALRM)
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
31 _exit (2);
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
32 }
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
33 ]], [[
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
34 /* Failure to compile this test due to missing alarm is okay,
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
35 since all such platforms (mingw) also lack sleep. */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
36 unsigned int pentecost = 50 * 24 * 60 * 60; /* 50 days. */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
37 unsigned int remaining;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
38 signal (SIGALRM, handle_alarm);
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
39 alarm (1);
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
40 remaining = sleep (pentecost);
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
41 return !(pentecost - 10 < remaining && remaining <= pentecost);]])],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
42 [gl_cv_func_sleep_works=yes], [gl_cv_func_sleep_works=no],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
43 [gl_cv_func_sleep_works="guessing no"])])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
44 if test "$gl_cv_func_sleep_works" != yes; then
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
45 REPLACE_SLEEP=1
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
46 AC_LIBOBJ([sleep])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
47 fi
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
48 fi
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
49 ])