Mercurial > hg > octave-shane > gnulib-hg
annotate m4/strerror.m4 @ 16869:38e6d30d7e4d
poll/select: prevent busy-waiting
2012-05-21 Paolo Bonzini <bonzini@gnu.org>
poll/select: prevent busy-waiting. SwitchToThread() only gives away
the rest of the current time slice to another thread in the current
process. So if the thread that feeds the file decscriptor we're
polling is not in the current process, we get busy-waiting.
* lib/poll.c: Use SleepEx(1, TRUE) instead of SwitchToThread().
Patch from Theodore Leblond.
* lib/select.c: Split polling out of the loop that sets the output
fd_sets. Check for zero result and loop if the wait timeout is
infinite.
author | Paolo Bonzini <bonzini@gnu.org> |
---|---|
date | Mon, 21 May 2012 09:52:42 +0200 |
parents | d9b4f726faa7 |
children | e542fd46ad6f |
rev | line source |
---|---|
16821
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
1 # strerror.m4 serial 17 |
16201
8250f2777afc
maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents:
15308
diff
changeset
|
2 dnl Copyright (C) 2002, 2007-2012 Free Software Foundation, Inc. |
5611
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4334
diff
changeset
|
3 dnl This file is free software; the Free Software Foundation |
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4334
diff
changeset
|
4 dnl gives unlimited permission to copy and/or distribute it, |
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4334
diff
changeset
|
5 dnl with or without modifications, as long as this notice is preserved. |
4107
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 |
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 AC_DEFUN([gl_FUNC_STRERROR], |
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 [ |
9502
9be60e099f13
Fix strerror module on Solaris 7.
Eric Blake <ebb9@byu.net>
parents:
9324
diff
changeset
|
9 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) |
10429
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9921
diff
changeset
|
10 AC_REQUIRE([gl_HEADER_ERRNO_H]) |
15308
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
11 AC_REQUIRE([gl_FUNC_STRERROR_0]) |
16821
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
14889
a78ddb38a66b
strerror_r-posix: work around cygwin 1.7.9
Eric Blake <eblake@redhat.com>
parents:
14887
diff
changeset
|
13 m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [ |
a78ddb38a66b
strerror_r-posix: work around cygwin 1.7.9
Eric Blake <eblake@redhat.com>
parents:
14887
diff
changeset
|
14 AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS]) |
a78ddb38a66b
strerror_r-posix: work around cygwin 1.7.9
Eric Blake <eblake@redhat.com>
parents:
14887
diff
changeset
|
15 ]) |
15308
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
16 if test "$ERRNO_H:$REPLACE_STRERROR_0" = :0; then |
10429
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9921
diff
changeset
|
17 AC_CACHE_CHECK([for working strerror function], |
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9921
diff
changeset
|
18 [gl_cv_func_working_strerror], |
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9921
diff
changeset
|
19 [AC_RUN_IFELSE( |
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9921
diff
changeset
|
20 [AC_LANG_PROGRAM( |
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9921
diff
changeset
|
21 [[#include <string.h> |
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9921
diff
changeset
|
22 ]], |
15308
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
23 [[if (!*strerror (-2)) return 1;]])], |
10429
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9921
diff
changeset
|
24 [gl_cv_func_working_strerror=yes], |
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9921
diff
changeset
|
25 [gl_cv_func_working_strerror=no], |
16821
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
26 [case "$host_os" in |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
27 # Guess yes on glibc systems. |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
28 *-gnu*) gl_cv_func_working_strerror="guessing yes" ;; |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
29 # If we don't know, assume the worst. |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
30 *) gl_cv_func_working_strerror="guessing no" ;; |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
31 esac |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
32 ]) |
10429
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9921
diff
changeset
|
33 ]) |
16821
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
34 case "$gl_cv_func_working_strerror" in |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
35 *yes) ;; |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
36 *) |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
37 dnl The system's strerror() fails to return a string for out-of-range |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
38 dnl integers. Replace it. |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
39 REPLACE_STRERROR=1 |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
40 ;; |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
41 esac |
14892 | 42 m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [ |
43 dnl If the system's strerror_r or __xpg_strerror_r clobbers strerror's | |
44 dnl buffer, we must replace strerror. | |
45 case "$gl_cv_func_strerror_r_works" in | |
46 *no) REPLACE_STRERROR=1 ;; | |
47 esac | |
48 ]) | |
10429
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9921
diff
changeset
|
49 else |
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9921
diff
changeset
|
50 dnl The system's strerror() cannot know about the new errno values we add |
15308
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
51 dnl to <errno.h>, or any fix for strerror(0). Replace it. |
9321
c25260956dfa
Simplify and modernize strerror substitute, partly to fix Solaris 8 bug.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9224
diff
changeset
|
52 REPLACE_STRERROR=1 |
10429
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9921
diff
changeset
|
53 fi |
8309
e5ee9891c553
Make it possible to compile strerror.c separately, unconditionally.
Bruno Haible <bruno@clisp.org>
parents:
5611
diff
changeset
|
54 ]) |
15308
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
55 |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
56 dnl Detect if strerror(0) passes (that is, does not set errno, and does not |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
57 dnl return a string that matches strerror(-1)). |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
58 AC_DEFUN([gl_FUNC_STRERROR_0], |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
59 [ |
16821
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
60 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
15308
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
61 REPLACE_STRERROR_0=0 |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
62 AC_CACHE_CHECK([whether strerror(0) succeeds], |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
63 [gl_cv_func_strerror_0_works], |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
64 [AC_RUN_IFELSE( |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
65 [AC_LANG_PROGRAM( |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
66 [[#include <string.h> |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
67 #include <errno.h> |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
68 ]], |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
69 [[int result = 0; |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
70 char *str; |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
71 errno = 0; |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
72 str = strerror (0); |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
73 if (!*str) result |= 1; |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
74 if (errno) result |= 2; |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
75 if (strstr (str, "nknown") || strstr (str, "ndefined")) |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
76 result |= 4; |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
77 return result;]])], |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
78 [gl_cv_func_strerror_0_works=yes], |
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
79 [gl_cv_func_strerror_0_works=no], |
16821
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
80 [case "$host_os" in |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
81 # Guess yes on glibc systems. |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
82 *-gnu*) gl_cv_func_strerror_0_works="guessing yes" ;; |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
83 # If we don't know, assume the worst. |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
84 *) gl_cv_func_strerror_0_works="guessing no" ;; |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
85 esac |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
86 ]) |
15308
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
87 ]) |
16821
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
88 case "$gl_cv_func_strerror_0_works" in |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
89 *yes) ;; |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
90 *) |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
91 REPLACE_STRERROR_0=1 |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
92 AC_DEFINE([REPLACE_STRERROR_0], [1], [Define to 1 if strerror(0) |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
93 does not return a message implying success.]) |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
94 ;; |
d9b4f726faa7
strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
95 esac |
15308
a3ba680ad389
strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents:
14895
diff
changeset
|
96 ]) |