Paul Eggert [Mon, 25 Apr 2011 06:29:28 +0000 (23:29 -0700)]
strtoul: remove dependency on strtol
This is so that 'configure' need not check for strtol merely because
the application needs strtoul.
* modules/strtoul (Files): Add lib/strtol.c.
(Depends-on): Remove strtol.
Paul Eggert [Mon, 25 Apr 2011 06:27:44 +0000 (23:27 -0700)]
strtoll: remove dependency on strtol
This is so that 'configure' need not check for strtol merely because
the application needs strtoll.
* modules/strtoll (Files): Add lib/strtol.c.
(Depends-on): Remove strtol.
Eric Blake [Thu, 21 Apr 2011 17:48:22 +0000 (11:48 -0600)]
passfd: speed up configure and drop unused code
Ultimately, it would be nice to provide a sendmsg and recvmsg module,
and have those provide a replacement struct msghdr and silently
convert msg_accrights into the replacement struct's msg_control, when
targeting older BSD. But until that point in time, this is a nice
cleanup.
SCM_RIGHTS really only works on Unix sockets; however, there is
nothing in passfd.c that needs to be hard-coded to this (rather,
the hard-coding of the address family is done externally when
the socket or socketpair is created).
* m4/afunix.m4 (gl_SOCKET_AFUNIX): Rename...
* m4/passfd.m4 (gl_PASSFD): ...to something more fitting of
its use. Drop test for setting unused HAVE_UNIXSOCKET_SCM_RIGHTS.
Instead of probing at configure for unix_scm_rights_bsd44_way,
instead probe for CMSG_FIRSTHDR at compile time. Simplify BSD 4.3
check to a struct member probe.
* lib/passfd.c (includes): Nothing here requires <sys/un.h>.
(sendfd, recvfd): Update preprocessor checks.
* modules/passfd (Files): Reflect rename, and drop unused file.
(Depends-on): Drop unused dependency.
Eric Blake [Thu, 21 Apr 2011 13:16:20 +0000 (07:16 -0600)]
passfd: allow compilation on mingw
The passfd module now skips on mingw, rather than failing to compile.
It may be nice to add a sendmsg and recvmsg module in the future,
but for now passfd is the only client that cares.
* modules/sys_socket (Depends-on): Add sys_uio.
* lib/sys_socket.in.h [!@HAVE_SYS_SOCKET_H@]: Use it for struct
iovec and a minimal struct msghdr.
* tests/test-sys_socket.c (main): Enhance test.
* m4/afunix.m4 (gl_SOCKET_AFUNIX): Detect recvmsg/sendmsg.
* lib/passfd.c (include): Drop <sys/uio.h>; <sys/sockets.h> is
guaranteed to provide what we need.
(sendmsg, recvmsg): Declare fallbacks if we lack sendmsg.
* modules/passfd-tests (Depends-on): Add sys_wait.
* tests/test-passfd.c (main): Skip test on mingw, for now.
* doc/posix-headers/sys_socket.texi (sys/socket.h): Document the
partial 'struct msghdr' implementation.
Jim Meyering [Wed, 20 Apr 2011 13:44:54 +0000 (15:44 +0200)]
useless-if-before-free: avoid false-positive
* build-aux/useless-if-before-free: Adjust regexp for the non-brace
disjunct so that it too requires a terminating ";". Without that,
this script would identify as useless one statement from gcc that
was not:
if (aligned_ptr)
free (((void **) aligned_ptr) [-1]);
Bruno Haible [Tue, 19 Apr 2011 08:38:30 +0000 (10:38 +0200)]
Move the support of O_NONBLOCK in open() to the 'open' module.
* modules/nonblocking (Depends-on): Remove 'open'.
* m4/nonblocking.m4 (gl_NONBLOCKING_IO_BODY): Set
gl_cv_have_open_O_NONBLOCK.
* m4/open.m4 (gl_FUNC_OPEN): Replace open() also when required for
O_NONBLOCK support.
* doc/posix-functions/open.texi: Document support for O_NONBLOCK.
Bruno Haible [Sun, 17 Apr 2011 17:50:10 +0000 (19:50 +0200)]
nonblocking: Add tests for sockets.
* tests/test-nonblocking-socket.sh: New file.
* tests/test-nonblocking-socket-main.c: New file.
* tests/test-nonblocking-socket-child.c: New file.
* tests/test-nonblocking-socket.h: New file.
* tests/socket-server.h: New file.
* tests/socket-client.h: New file.
* modules/nonblocking-socket-tests: New file.
* modules/nonblocking-tests (Depends-on): Add nonblocking-socket-tests.
Bruno Haible [Sun, 17 Apr 2011 17:27:28 +0000 (19:27 +0200)]
nonblocking: Add tests for pipes.
* tests/test-nonblocking-pipe.sh: New file.
* tests/test-nonblocking-pipe-main.c: New file.
* tests/test-nonblocking-pipe-child.c: New file.
* tests/test-nonblocking-pipe.h: New file.
* tests/test-nonblocking-writer.h: New file.
* tests/test-nonblocking-reader.h: New file.
* tests/test-nonblocking-misc.h: New file.
* modules/nonblocking-pipe-tests: New file.
* modules/nonblocking-tests (Depends-on): Add nonblocking-pipe-tests.
Bruno Haible [Sat, 16 Apr 2011 10:10:16 +0000 (12:10 +0200)]
strchrnul: Tweak last commit.
* doc/glibc-functions/strchrnul.texi: Add more details about Cygwin
bug.
* lib/string.in.h (strchrnul): Use same arguments in _GL_FUNCDECL_RPL
as in _GL_FUNCDECL_SYS.
* m4/strchrnul.m4 (gl_FUNC_STRCHRNUL): Invoke gl_PREREQ_STRCHRNUL after
AC_LIBOBJ. When cross-compiling, say "guessing yes" not "yes".
Eric Blake [Fri, 15 Apr 2011 19:53:50 +0000 (13:53 -0600)]
strchrnul: work around cygwin bug
A misplaced * means that cygwin 1.7.9 dereferences NULL rather
than returning the location of the trailing NUL byte.
* doc/glibc-functions/strchrnul.texi (strchrnul): Document bug.
* m4/strchrnul.m4 (gl_FUNC_STRCHRNUL): Detect it.
* m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): New witness.
* modules/string (Makefile.am): Substitute it.
* lib/string.in.h (strchrnul): Use it.
Bruno Haible [Thu, 14 Apr 2011 21:42:01 +0000 (23:42 +0200)]
Support non-blocking pipe I/O in write() on native Windows.
* lib/write.c (rpl_write): Split a write request that failed merely
because the byte count was larger than the pipe buffer's size.
* doc/posix-functions/write.texi: Mention the problem with large byte
counts.
Jim Meyering [Sun, 10 Apr 2011 08:26:46 +0000 (10:26 +0200)]
maint.mk: prohibit doubled words
Detect them also when they're separated by a newline.
There are 3 ways to customize it:
- disable the test on a per file basis, as usual with rules using
$(VC_LIST_EXCEPT)
- replace the default doubled-word-selecting regexp (affects all files)
- ignore a particular file-vs-doubled-word match
I nearly used that last one to ignore the "is is" match in
coreutils' NEWS file, since the text was "ls -is is ..."
To do that, I would have added this line to cfg.mk:
ignore_doubled_word_match_RE_ = ^NEWS:[0-9]+:is[ ]is$
but it would have ignored any "is is" match in NEWS.
Low probability, but still...
Instead, I changed the text, slightly:
- ls -is is now consistent with ls -lis in ignoring values returned
+ "ls -is" is now consistent with ls -lis in ignoring values returned
* top/maint.mk (prohibit_double_word_RE_): Provide default.
(prohibit_doubled_word_): Define.
(sc_prohibit_doubled_word): New rule.
(sc_prohibit_the_the): Remove. Subsumed by the above.
Jim Meyering [Sat, 9 Apr 2011 21:05:22 +0000 (23:05 +0200)]
maint: change "can not" to "cannot"
But do not change the occurrences in maintain.texi or in
build-aux/po/Makefile.in.in, which I presume comes from gettext.
* doc/gnulib-tool.texi: s/can not/cannot/
* doc/posix-functions/accept.texi (accept): Likewise.
* doc/posix-functions/socket.texi (socket): Likewise.
* lib/mbrtowc.c: Likewise.
Bruno Haible [Sat, 9 Apr 2011 00:12:11 +0000 (02:12 +0200)]
verify: Fix syntax error with GCC 4.6 in C++ mode.
* lib/verify.h (HAVE__STATIC_ASSERT): Don't define in C++ mode.
(HAVE_STATIC_ASSERT): New macro.
(verify_true, verify): Use 'static_assert' if it is supported and
'_Static_assert' is not supported.
Paul Eggert [Fri, 8 Apr 2011 20:22:51 +0000 (13:22 -0700)]
allocator: New module.
* modules/allocator, lib/allocator.c: New files.
* lib/allocator.h (stdlib_allocator): New decl.
* lib/careadlinkat.c (_GL_USE_STDLIB_ALLOC, standard_allocator):
Remove. Do not include <stdlib.h>.
(careadlinkat): Use stdlib_allocator instead of rolling our own.
* modules/careadlinkat (Files): Remove lib/allocator.h.
(Depends-on): Add allocator.
Paul Eggert [Fri, 8 Apr 2011 17:41:30 +0000 (10:41 -0700)]
careadlinkat: rename members to avoid problem
* lib/allocator.h (struct allocator): Rename members from
malloc/realloc to allocate/reallocate, to avoid problems if malloc
and realloc are #define'd. Reported by Eric Blake in
<http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00091.html>.
* lib/careadlinkat.c (careadlinkat): Adjust to renaming.
Eric Blake [Fri, 8 Apr 2011 17:51:45 +0000 (11:51 -0600)]
nonblocking: reduce dependency
No need to make nonblocking drag in sockets just for a test;
test them if they are present and skip them otherwise.
* tests/test-nonblocking.c: Only test sockets when in use.
* modules/nonblocking-tests (Depends-on): Drop socket.
(Makefile.am): Link even if sockets are not present.
* modules/pipe2-tests (Makefile.am): Likewise.
* lib/ioctl.c (ioctl) [WIN32]: Fail if sockets are not also in use.
Eric Blake [Fri, 8 Apr 2011 16:15:54 +0000 (10:15 -0600)]
nonblocking: provide O_NONBLOCK for mingw
Mingw is the only known platform that lacks O_NONBLOCK (possibly
via the alternate spelling O_NDELAY). But mingw also lacks any
files where open() needs to enforce non-blocking behavior, and
lacks openat(), so it is relatively simple to provide a non-zero
flag. A future patches will make use of O_NONBLOCK for pipe2.
* modules/nonblocking (Depends-on): Add open.
(configure.ac): Set new witness macro.
* m4/fcntl_h.m4 (gl_FCNTL_H_DEFAULTS): Provide default for it.
* modules/fcntl-h (Makefile.am): Substitute it.
* lib/fcntl.in.h (O_NONBLOCK): Guarantee non-zero definition when
nonblocking module is in use.
* lib/nonblocking.c: Adjust portability test.
* lib/open.c (open): Don't let native open see gnulib flag.
* tests/test-fcntl-h.c (main): Enhance test.
* tests/test-open.h (test_open): Likewise.
* doc/posix-headers/fcntl.texi (fcntl.h): Document the replacement.
Eric Blake [Fri, 8 Apr 2011 14:51:56 +0000 (08:51 -0600)]
careadlink: fix compilation error on mingw
Mingw compilation failed:
lib/careadlinkat.c: In function 'careadlinkat':
lib/careadlinkat.c:143:39: error: 'const struct allocator' has no member named 'malloc'
lib/careadlinkat.c:149:66: error: 'const struct allocator' has no member named 'realloc'
lib/careadlinkat.c:152:39: error: 'const struct allocator' has no member named 'realloc'
lib/careadlinkat.c:169:27: error: 'const struct allocator' has no member named 'malloc'
make[4]: *** [careadlinkat.lo] Error 1
because "careadlinkat.h" includes enough system headers to get
replacement names defined for malloc, then "allocator.h" defines
fields with those replacement names, then undefining the macros
tries to reference missing fields.
I figured this patch is less invasive than changing the field names
in allocator.h, and possibly requiring clients to change.
* lib/careadlinkat.c (standard_allocator): Avoid renaming fields
within struct allocator.
Paul Eggert [Wed, 6 Apr 2011 06:45:10 +0000 (23:45 -0700)]
verify: use _Static_assert if available
* lib/verify.h (HAVE__STATIC_ASSERT): New macro.
(verify_true, verify): Use it if available. This generates better
diagnostics with GCC 4.6.0 and later.
Bruno Haible [Tue, 5 Apr 2011 23:55:16 +0000 (01:55 +0200)]
Remove leftover generated .h files after config.status changed.
* m4/alloca.m4 (gl_FUNC_ALLOCA): New automake conditional
GL_GENERATE_ALLOCA_H.
* modules/alloca-opt (Makefile.am): Remove alloca.h if
GL_GENERATE_ALLOCA_H evaluates to false.
* m4/argz.m4 (gl_FUNC_ARGZ): New automake conditional
GL_GENERATE_ARGZ_H.
* modules/argz (Makefile.am): Remove argz.h if GL_GENERATE_ARGZ_H
evaluates to false.
* m4/byteswap.m4 (gl_BYTESWAP): New automake conditional
GL_GENERATE_BYTESWAP_H.
* modules/byteswap (Makefile.am): Remove byteswap.h if
GL_GENERATE_BYTESWAP_H evaluates to false.
* m4/errno_h.m4 (gl_HEADER_ERRNO_H): New automake conditional
GL_GENERATE_ERRNO_H.
* modules/errno (Makefile.am): Remove errno.h if GL_GENERATE_ERRNO_H
evaluates to false.
* m4/float_h.m4 (gl_FLOAT_H): New automake conditional
GL_GENERATE_FLOAT_H.
* modules/float (Makefile.am): Remove float.h if GL_GENERATE_FLOAT_H
evaluates to false.
* m4/fnmatch.m4 (gl_FUNC_FNMATCH_POSIX): New automake conditional
GL_GENERATE_FNMATCH_H.
* modules/fnmatch (Makefile.am): Remove fnmatch.h if
GL_GENERATE_FNMATCH_H evaluates to false.
* m4/glob.m4 (gl_GLOB_SUBSTITUTE, gl_GLOB): New automake conditional
GL_GENERATE_GLOB_H.
* modules/glob (Makefile.am): Remove glob.h if GL_GENERATE_GLOB_H
evaluates to false.
* m4/iconv_h.m4 (gl_REPLACE_ICONV_H, gl_ICONV_H_DEFAULTS): New
automake conditional GL_GENERATE_ICONV_H.
* modules/iconv-h (Makefile.am): Remove iconv.h if GL_GENERATE_ICONV_H
evaluates to false.
* m4/netinet_in_h.m4 (gl_HEADER_NETINET_IN): New automake conditional
GL_GENERATE_NETINET_IN_H.
* modules/netinet_in (Makefile.am): Remove netinet/in.h if
GL_GENERATE_NETINET_IN_H evaluates to false.
* m4/pthread.m4 (gl_PTHREAD_CHECK): Set PTHREAD_H here. New automake
conditional GL_GENERATE_PTHREAD_H.
(gl_PTHREAD_DEFAULTS): Don't set PTHREAD_H here.
* modules/pthread (Makefile.am): Remove pthread.h if
GL_GENERATE_PTHREAD_H evaluates to false.
* m4/sched_h.m4 (gl_SCHED_H): New automake conditional
GL_GENERATE_SCHED_H.
* modules/sched (Makefile.am): Remove sched.h if GL_GENERATE_SCHED_H
evaluates to false.
* m4/selinux-context-h.m4 (gl_HEADERS_SELINUX_CONTEXT_H): New automake
conditional GL_GENERATE_SELINUX_CONTEXT_H.
* modules/selinux-h (Makefile.am): Remove selinux/context.h if
GL_GENERATE_SELINUX_CONTEXT_H evaluates to false.
* m4/stdarg.m4 (gl_STDARG_H): New automake conditional
GL_GENERATE_STDARG_H.
* modules/stdarg (Makefile.am): Remove stdarg.h if
GL_GENERATE_STDARG_H evaluates to false.
* m4/stdbool.m4 (AM_STDBOOL_H): New automake conditional
GL_GENERATE_STDBOOL_H.
* modules/stdbool (Makefile.am): Remove stdbool.h if
GL_GENERATE_STDBOOL_H evaluates to false.
* m4/stddef_h.m4 (gl_STDDEF_H): Set STDDEF_H here. New automake
conditional GL_GENERATE_STDDEF_H.
(gl_STDDEF_H_DEFAULTS): Don't set STDDEF_H here.
* modules/stddef (Makefile.am): Remove stddef.h if
GL_GENERATE_STDDEF_H evaluates to false.
* m4/stdint.m4 (gl_STDINT_H): New automake conditional
GL_GENERATE_STDINT_H.
* modules/stdint (Makefile.am): Remove stdint.h if
GL_GENERATE_STDINT_H evaluates to false.
* m4/sysexits.m4 (gl_SYSEXITS): New automake conditional
GL_GENERATE_SYSEXITS_H.
* modules/sysexits (Makefile.am): Remove sysexits.h if
GL_GENERATE_SYSEXITS_H evaluates to false.
careadlinkat: new module
* lib/allocator.h, lib/careadlinkat.h, lib/careadlinkat.c:
* modules/careadlinkat: New files, written by me with
a review and feedback from Ben Pfaff in
<http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00008.html>.
Bruno Haible [Fri, 1 Apr 2011 22:01:13 +0000 (00:01 +0200)]
wmemchr, wcschr, wcsrchr, wcspbrk, wcsstr: Avoid errors in C++ mode.
* lib/wchar.in.h (wmemchr, wcschr, wcsrchr, wcspbrk, wcsstr): Use
_GL_CXXALIAS_SYS_CAST2 instead of _GL_CXXALIAS_SYS. On glibc >= 2.10
systems, use _GL_CXXALIASWARN1 instead of _GL_CXXALIASWARN.
Reported by Bruce Korb <bruce.korb@gmail.com>.
Eric Blake [Thu, 31 Mar 2011 21:28:37 +0000 (15:28 -0600)]
nonblocking: fix mingw test failures
Actually testing on mingw uncovered a few more problems.
* lib/nonblocking.c (set_nonblocking_flag): Succeed when clearing
non-blocking flag on regular file.
(get_nonblocking_flag): Set errno on invalid fd.
* tests/test-nonblocking.c (main): Avoid test failure on
directories if fchdir is not active.
* modules/nonblocking-tests (Depends-on): Drop unused dependency.
Bruno Haible [Thu, 31 Mar 2011 16:21:36 +0000 (18:21 +0200)]
Fix bug with gl_WARN_ON_USE_PREPARE, introduced on 2011-01-23.
* m4/gnulib-common.m4 (gl_ASSERT_NO_GNULIB_POSIXCHECK): Hide the
gl_WARN_ON_USE_PREPARE definition from 'aclocal'.
Reported by Simon Josefsson <simon@josefsson.org>.
Bruno Haible [Thu, 31 Mar 2011 00:52:06 +0000 (02:52 +0200)]
stdio: Avoid GCC >= 4.4 warnings when using %lld and similar on mingw.
* lib/stdio.in.h (_GL_ATTRIBUTE_FORMAT_PRINTF): Use 'gnu_printf' format
instead of 'printf' format for GCC >= 4.4.
(_GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM): New macro.
(fprintf, printf, vfprintf, vprintf): Declare with
_GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM when the function ends up calling
the system's vfprintf() function.
Reported by Daniel P. Berrange <berrange@redhat.com> via Eric Blake.