Bruno Haible [Tue, 20 Sep 2011 01:16:18 +0000 (03:16 +0200)]
msvc-inval: Require a semicolon after DONE_MSVC_INVAL.
* lib/msvc-inval.h (TRY_MSVC_INVAL, DONE_MSVC_INVAL): Wrap in a
do...while(0).
* lib/dup2.c (rpl_dup2): Add a semicolon after DONE_MSVC_INVAL.
Suggested by Paul Eggert.
Bruno Haible [Mon, 19 Sep 2011 21:48:58 +0000 (23:48 +0200)]
sched: Ensure pid_t is defined.
* m4/sched_h.m4 (gl_SCHED_H): Arrange to override <sched.h> if it does
not define pid_t.
* lib/sched.in.h: Include <sys/types.h>.
* doc/posix-headers/sched.texi: Mention the pid_t problem.
Reported by Tom G. Christensen <tgc@jupiterrise.com>.
Jim Meyering [Mon, 19 Sep 2011 17:27:53 +0000 (19:27 +0200)]
tests: use printf, not echo in init.sh's warn_ function
* tests/init.sh (warn_): Use printf, not echo. The latter would
misbehave when given strings containing a backslash or starting
with e.g., -n. James Youngman suggested setting IFS.
Jim Meyering [Mon, 19 Sep 2011 07:48:35 +0000 (09:48 +0200)]
getcwd: don't fail in a deep directory on a system without openat
Before this change, getcwd would fail when called from a directory
of depth PATH_MAX / 3 or greater. That was due to the fact that
the non-openat implementation used "..", "../..", "../../..", etc.
to access ancestor directories. With too many, that string would
be longer than PATH_MAX.
* lib/getcwd.c (HAVE_OPENAT_SUPPORT): Define also when we are
using gnulib's openat replacement.
* m4/openat.m4: Set GNULIB_OPENAT, so getcwd.c knows when
we're using the replacement function.
maint.mk: avoid warnings from perl about missing files
* top/maint.mk (def_sym_regex): Ignore files listed in
$(gl_other_headers_) that do not exist, say because a project
does not use a corresponding module.
Paul Eggert [Mon, 19 Sep 2011 04:46:34 +0000 (21:46 -0700)]
stat: use pathmax.h only if needed
* lib/stat.c: Include pathmax.h only if REPLACE_FUNC_STAT_DIR.
This is better for Emacs, which does not have a mingw port and
therefore can avoid the pathmax module.
Bruno Haible [Mon, 19 Sep 2011 01:44:56 +0000 (03:44 +0200)]
inet_ntop, inet_pton: Look for it also in libresolv.
* m4/inet_ntop.m4 (gl_FUNC_INET_NTOP): If the function was not found in
libnsl, search for it in libresolv.
* m4/inet_pton.m4 (gl_FUNC_INET_PTON): Likewise.
Needed on Solaris 7.
Bruno Haible [Mon, 19 Sep 2011 01:10:16 +0000 (03:10 +0200)]
accept, accept4 tests: Avoid link error on Solaris.
* modules/accept-tests (Makefile.am): Link test-accept against
$(LIBSOCKET).
* modules/accept4-tests (Makefile.am): Link test-accept4 against
$(LIBSOCKET).
Bruno Haible [Sun, 18 Sep 2011 08:34:24 +0000 (10:34 +0200)]
dup2: Support for MSVC.
* lib/dup2.c: Include msvc-inval.h.
(rpl_dup2): Handle invalid parameter notifications during dup2 and
_get_osfhandle calls.
* modules/dup2 (Depends-on): Add msvc-inval.
* doc/posix-functions/dup2.texi: Mention problem on MSVC.
Bruno Haible [Sat, 17 Sep 2011 16:28:17 +0000 (18:28 +0200)]
popen: Support for MSVC.
* lib/stdio.in.h (popen): Declare it if the system lacks this function.
* lib/popen.c (popen): Provide alternate definition for native Windows.
* m4/popen.m4 (gl_FUNC_POPEN): Test if popen exists. Set HAVE_POPEN.
* m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Initialize HAVE_POPEN.
* modules/popen (Depends-on, configure.ac): Update condition.
* modules/stdio (Makefile.am): Substitute HAVE_POPEN.
* doc/posix-functions/popen.texi: Mention that the MSVC problem is
fixed.
Bruno Haible [Sat, 17 Sep 2011 13:09:53 +0000 (15:09 +0200)]
inet_pton: Support for MSVC on Windows Vista or newer.
* lib/arpa_inet.in.h (inet_pton): Also consider REPLACE_INET_PTON.
* lib/inet_pton.c (rpl_inet_pton): Use a simple wrapper if
HAVE_DECL_INET_PTON is defined.
* m4/inet_pton.m4 (gl_FUNC_INET_PTON): Invoke gl_PREREQ_SYS_H_WINSOCK2.
On platforms with <winsock2.h>, test whether inet_pton is declared in
<ws2tcpip.h>. If so, arrange to replace it.
* m4/arpa_inet_h.m4 (gl_ARPA_INET_H_DEFAULTS): Initialize
REPLACE_INET_PTON.
* modules/arpa_inet (Makefile.am): Substitute REPLACE_INET_PTON.
* modules/inet_pton (Files): Add m4/sys_socket_h.m4.
(Depends-on, configure.ac): Update condition.
* doc/posix-functions/inet_pton.texi: Mention the MSVC problem.
Bruno Haible [Sat, 17 Sep 2011 12:56:11 +0000 (14:56 +0200)]
inet_ntop: Support for MSVC on Windows Vista or newer.
* lib/arpa_inet.in.h (inet_ntop): Also consider REPLACE_INET_NTOP.
* lib/inet_ntop.c (rpl_inet_ntop): Use a simple wrapper if
HAVE_DECL_INET_NTOP is defined.
* m4/inet_ntop.m4 (gl_FUNC_INET_NTOP): Invoke gl_PREREQ_SYS_H_WINSOCK2.
On platforms with <winsock2.h>, test whether inet_ntop is declared in
<ws2tcpip.h>. If so, arrange to replace it.
* m4/arpa_inet_h.m4 (gl_ARPA_INET_H_DEFAULTS): Initialize
REPLACE_INET_NTOP.
* modules/arpa_inet (Makefile.am): Substitute REPLACE_INET_NTOP.
* modules/inet_ntop (Files): Add m4/sys_socket_h.m4.
(Depends-on, configure.ac): Update condition.
* doc/posix-functions/inet_ntop.texi: Mention the MSVC problem.
Bruno Haible [Fri, 16 Sep 2011 21:17:49 +0000 (23:17 +0200)]
sys_stat: Support for MSVC.
* lib/sys_stat.in.h (S_IFIFO): Define to _S_IFIFO if that exists.
* tests/test-sys_stat.c: Don't assume that S_IFBLK exists.
* doc/posix-headers/sys_stat.texi: Mention missing S_IFIFO, S_IFBLK on
MSVC.
Eric Blake [Fri, 16 Sep 2011 20:12:01 +0000 (14:12 -0600)]
fdatasync: port to Solaris
Cater to Solaris requiring extra libraries for fdatasync.
* m4/fdatasync.m4 (gl_FUNC_FDATASYNC): Set LIB_FDATASYNC.
* modules/fdatasync (Link): Document it.
* modules/fdatasync-tests (test_fdatasync_LDADD): Link with it.
Eric Blake [Fri, 16 Sep 2011 19:49:16 +0000 (13:49 -0600)]
fdatasync: port to MacOS X 10.7
MacOS X 10.7 added an fdatasync syscall and exports a symbol for it,
but fails to declare it anywhere. Lacking any hard evidence that this
syscall is broken, we will just provide the declaration and use it.
* m4/fdatasync.m4 (gl_FUNC_FDATASYNC): Check for present but not
declared.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Another default.
* modules/unistd (Makefile.am): Substitute it.
* lib/unistd.in.h (fdatasync): Declare on MacOS.
* doc/posix-functions/fdatasync.texi (fdatasync): Document it.
Eric Blake [Fri, 16 Sep 2011 18:12:41 +0000 (12:12 -0600)]
unistd: update refs to newer POSIX
usleep only exists in POSIX 2001, but for the rest of the functions
where we pointed to online POSIX specs, we might as well point to the
latest version of the standard.
* lib/unistd.in.h: Prefer POSIX 2008 over 2001.
Suggested by Bruno Haible.
Eric Blake [Fri, 16 Sep 2011 15:59:23 +0000 (09:59 -0600)]
fdatasync: new module
At least libvirt would like to use the lighter-weight fdatasync
on platforms where it is supported, while still guaranteeing full
sync (via the heavy-weight fsync fallback) on all platforms.
I've got an open question to the Austin Group, since the POSIX 2008
wording is self-contradictory (unlike fsync, fdatasync requires
EBADF on non-writable fds, but still mentions that read() errors
must be propagated). I can see how fsync() would affect atime after
read() while fdatasync() can skip that, explaining why fdatasync()
might have the EBADF requirement, but on the other hand, that prevents
an implementation (like ours) where fdatasync is a straight alias of
fsync. At any rate, glibc allows fdatasync on read-only fds.
* modules/fsync (Description): Document difference to fdatasync.
* modules/fdatasync: New module.
* m4/fdatasync.m4 (gl_FUNC_FDATASYNC): New file.
* lib/fdatasync.c (fdatasync): Likewise.
* m4/unistd_h.m4 (gl_UNISTD_H, gl_UNISTD_H_DEFAULTS): Set up
defaults.
* modules/unistd (Makefile.am): Set witnesses.
* lib/unistd.in.h (fdatasync): Declare.
* MODULES.html.sh: Document it.
* doc/posix-functions/fdatasync.texi (fdatasync): Likewise.
* modules/fdatasync-tests: New test.
* tests/test-fdatasync.c: Likewise.
Bruno Haible [Wed, 14 Sep 2011 23:00:17 +0000 (01:00 +0200)]
Avoid using #, the m4 comment starter character, near brackets.
* m4/absolute-header.m4 (gl_ABSOLUTE_HEADER_ONE): Use |, not #, as
delimiter character in sed expressions.
* m4/include_next.m4 (gl_NEXT_HEADERS_INTERNAL): Likewise.
Suggested by Eric Blake.
Bruno Haible [Wed, 14 Sep 2011 00:08:36 +0000 (02:08 +0200)]
sys_time: Support for MSVC.
* m4/sys_time_h.m4 (gl_HEADER_SYS_TIME_H_BODY): Invoke
gl_PREREQ_SYS_H_WINSOCK2. When testing for 'struct timeval', also
include <winsock2.h>.
* lib/sys_time.in.h: On MSVC, include <winsock2.h> and hide its
function declarations that collide with POSIX.
* modules/sys_time (Files): Add m4/sys_socket_h.m4.
(Makefile.am): Substitute HAVE_WINSOCK2_H.
Bruno Haible [Sun, 11 Sep 2011 19:44:32 +0000 (21:44 +0200)]
unistd et al.: Don't assume <unistd.h> exists.
* m4/chdir-long.m4 (gl_FUNC_CHDIR_LONG): Don't include <unistd.h> if it
does not exist.
* m4/environ.m4 (gl_ENVIRON): Don't include <unistd.h> if it does not
exist. But include <stdlib.h>.
* m4/fcntl-o.m4 (gl_FCNTL_O_FLAGS): If <unistd.h> does not exist,
include <io.h> and <stdlib.h> instead. Don't test symbolink links if
symlink() does not exist.
* m4/fflush.m4 (gl_FUNC_FFLUSH_STDIN): If <unistd.h> does not exist,
include <io.h> instead.
* m4/free.m4 (gl_FUNC_FREE): Assume free(NULL) works on native Windows.
* m4/getcwd.m4 (gl_FUNC_GETCWD_NULL): If <unistd.h> does not exist,
include <direct.h> instead.
* m4/getcwd-abort-bug.m4 (gl_FUNC_GETCWD_ABORT_BUG): Likewise.
* m4/getcwd-path-max.m4 (gl_FUNC_GETCWD_PATH_MAX): Likewise.
* m4/lseek.m4 (gl_FUNC_LSEEK): If <unistd.h> does not exist, include
<io.h> instead.
* m4/rename.m4 (gl_FUNC_RENAME): Assume rename() manages hard links
correctly if the system does not have hard links.
* m4/rmdir.m4 (gl_FUNC_RMDIR): If <unistd.h> does not exist, include
<direct.h> instead.
* m4/unistd_h.m4 (gl_UNISTD_H): If <unistd.h> does not exist, bypass
it when looking for function declarations.
* m4/unlink.m4 (gl_FUNC_UNLINK): If <unistd.h> does not exist, include
<direct.h> and <io.h> instead.
* doc/posix-headers/unistd.texi: More details about MSVC problem.
Bruno Haible [Sun, 11 Sep 2011 19:15:40 +0000 (21:15 +0200)]
strings: Don't assume <strings.h> exists.
* lib/strings.in.h: Include <strings.h> only if HAVE_STRINGS_H is 1.
* m4/strings_h.m4 (gl_HEADER_STRINGS_H_BODY): Set HAVE_STRINGS_H.
* modules/strings (Makefile.am): Substitute HAVE_STRINGS_H.
* doc/posix-headers/strings.texi: Mention the MSVC problem.