annotate m4/sleep.m4 @ 423:079d43b6967b 3.0-beta2 3.0-beta2

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