strerror_r-posix: work around cygwin 1.7.9
authorEric Blake <eblake@redhat.com>
Mon, 6 Jun 2011 23:59:01 +0000 (17:59 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 7 Jun 2011 22:48:54 +0000 (16:48 -0600)
commit4018d9e0e5fcaf2a7ee10309a49adc9364f67561
tree73d31fcc81c819a476a732d2c31a0609c93934a5
parentfd33cbeb2af00d79957ed51beeeadec715b0290a
strerror_r-posix: work around cygwin 1.7.9

Cygwin __xpg_strerror_r clobbers strerror, until cygwin 1.7.10; in
this case, we must replace strerror, but there was nothing in
strerror.m4 finding fault with cygwin's native strerror.  Solve
this by splitting strerror_r.m4 into two parts, one for probing
for the strerror_r bug, and one for replacing strerror_r based
on the presence of bugs unrelated to signature issues; that way,
the 'strerror' module in isolation will not replace strerror, but
if strerror_r is in use for any other reason, then the two use
separate buffers.

Note that cygwin's strerror is thread-safe while the gnulib
replacement is not; but this is no worse than any other
platform where strerror is not thread-safe; in a single-threaded
program, the difference is not observable, and in a multi-threaded
program, you really shouldn't be using strerror in the first place.

Also note that this ends up replacing glibc 2.13 strerror as it
deems __xpg_strerror_r broken on that platform, which isn't
technically necessary for strerror, but doesn't hurt too much.
Meanwhile, glibc 2.14 fixed __xpg_strerror_r, and strerror is not
replaced in that scenario.

* m4/strerror_r.m4 (gl_FUNC_STRERROR_R): Split...
(gl_FUNC_STRERROR_R_WORKS): ...into new macro, to detect Cygwin
bug without replacing strerror_r.
* m4/strerror.m4 (gl_FUNC_STRERROR): Replace strerror if
strerror_r is buggy, but without requiring strerror_r compilation.
* doc/posix-functions/strerror_r.texi (strerror_r): Fix docs.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
doc/posix-functions/strerror_r.texi
m4/strerror.m4
m4/strerror_r.m4