Paul Eggert [Wed, 22 Sep 2010 08:32:19 +0000 (01:32 -0700)]
pthread: add to system <pthread.h> instead of replacing it all, for MacOS
* lib/pthread.in.h: Add split double-inclusion guard, and include
system <pthread.h> if there is one. Use @@-style as in other
.in.h files. Define PTHREAD_COND_INITIALIZER etc. only if system
pthread.h doesn't.
(pthread_mutexattr_destroy, pthread_mutexattr_init):
(pthread_mutexattr_settype, pthread_mutex_trylock):
New static inline functions, if there's no system <pthread.h>.
(pthread_spinlock_t, pthread_spin_init, pthread_spin_destroy):
(pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock):
Approximate with mutexes if the system lacks spinlocks, as in
MacOS.
* m4/pthread.m4 (gl_PTHREAD_CHECK): Require gl_PTHREAD_DEFAULTS.
Add gl_CHECK_NEXT_HEADERS for pthread.h, and support the usual
@@-style. Check for spinlocks separately.
(gl_PTHREAD_DEFAULTS): New macro.
* modules/pthread: Redo to use a more typical style for in.h files.
Eric Blake [Tue, 21 Sep 2010 21:27:59 +0000 (15:27 -0600)]
net_if: enhance tests
* tests/test-net_if.c (main): Move signature checks earlier.
Print failures to stderr.
* doc/posix-functions/if_freenameindex.texi (if_freenameindex):
Document the bug that we do not yet fix.
Jim Meyering [Sat, 18 Sep 2010 19:26:27 +0000 (21:26 +0200)]
maint.mk: avoid unexpanded \n in two diagnostics
* top/maint.mk (sc_prohibit_always_true_header_tests):
Don't use a literal \n in a halt=... assignment. It would not be
expanded, and the two \n bytes would appear in the diagnostic output
rather than the desired newline. Use halt=$$(printf ... instead.
(sc_vulnerable_makefile_CVE-2009-4029): Likewise.
Jim Meyering [Sat, 18 Sep 2010 06:33:23 +0000 (08:33 +0200)]
init.sh: don't let an ephemeral "*.exe" make us skip all dir entries
Not that it's likely to happen, but if I were to remove from a PATH
directory a file named "*.exe" (yes, starting with an asterisk),
at just the right moment, it would have made init.sh ignore all
remaining .exe-suffixed names in that directory.
* tests/init.sh (find_exe_basenames_): Don't give up on a directory if
a file named "*.exe" is removed between the glob expansion and the
processing of that oddly named file.
Eric Blake [Fri, 17 Sep 2010 22:36:08 +0000 (16:36 -0600)]
mirbsd: add some more support
* m4/c-stack.m4 (AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC): MirBSD is
in BSD family.
* m4/gc-random.m4 (gl_GC_RANDOM): MirBSD supports same random
devices as OpenBSD.
* m4/host-os.m4 (mirbsd): Add MirBSD.
Bruno Haible [Fri, 17 Sep 2010 16:18:38 +0000 (10:18 -0600)]
Take over the maintenance of some older macros from Autoconf.
* m4/error.m4 (AC_FUNC_ERROR_AT_LINE): New macro, from GNU Autoconf.
* m4/lstat.m4 (AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK): New macro, from
GNU Autoconf.
* m4/memcmp.m4 (AC_FUNC_MEMCMP): New macro, from GNU Autoconf.
* m4/mktime.m4 (AC_FUNC_MKTIME): Change comment.
Eric Blake [Fri, 17 Sep 2010 14:29:16 +0000 (08:29 -0600)]
fdutimensat: drop atflag validation
* lib/fdutimensat.c (fdutimensat): Allow AT_SYMLINK_NOFOLLOW even
with valid fd, to close a race scenario where futimens is
unsupported and FILE was replaced by a symlink.
* tests/test-fdutimensat.c (do_fdutimens, main): Adjust test
accordingly.
Suggested by Paul Eggert.
Bruno Haible [Fri, 17 Sep 2010 02:05:32 +0000 (04:05 +0200)]
login_tty: Make the replacement code work on BSD systems.
* lib/login_tty.c: Include <sys/ioctl.h>.
(login_tty): Use ioctl TIOCSCTTY when available.
* modules/login_tty (Depends-on): Add sys_ioctl.
Reported by Mats Erik Andersson <mats.andersson@gisladisker.se>.
Bruno Haible [Fri, 17 Sep 2010 02:00:49 +0000 (04:00 +0200)]
login_tty: Stricter unit test.
* modules/login_tty-tests (Depends-on): Add tcgetsid.
* tests/test-login_tty.c (main): Also check the results of tcgetpgrp()
and tcgetsid() after login_tty.
Reported by Mats Erik Andersson <mats.andersson@gisladisker.se>.
Eric Blake [Thu, 16 Sep 2010 23:12:35 +0000 (17:12 -0600)]
fdutimensat: add an atflag parameter
* lib/fdutimensat.c (fdutimensat): Add new parameter.
* lib/utimens.h (fdutimensat): Update prototype.
* tests/test-fdutimensat.c: Adjust test to match.
* NEWS: Document the change.
Suggested by Paul Eggert.
* m4/memchr.m4 (gl_FUNC_MEMCHR): Detect glibc 2.11.2 failure on
Alpha.
* doc/posix-functions/memchr.texi (memchr): Tweak wording.
* tests/test-memchr.c (main): Enhance test.
Reported by Nelson H. F. Beebe.
Paul Eggert [Tue, 14 Sep 2010 16:03:55 +0000 (09:03 -0700)]
fts, getcwd, glob: audit for dirfd returning -1
* lib/fts.c (opendir): Remove #define; no longer used.
(opendirat): New arg PDIR_FD. All callers changed.
(fts_build, _opendir2): Use new opendirat to avoid the need for
dirfd, or for checking whether dirfd returns a negative value.
Don't use opendir; always use openat followed by fdopendir.
* lib/getcwd.c (__getcwd): Don't reset fd; fdopendir no longer clobbers
it.
* lib/glob.c (link_exists_p): Add comment explaining why dirfd never
returns -1 here.
* modules/fts (Depends-on): Remove dirfd.
* modules/getcwd (Depends-on): Likewise.
Paul Eggert [Mon, 13 Sep 2010 19:38:41 +0000 (12:38 -0700)]
fts: use O_NOFOLLOW to avoid race condition when opening a directory
* lib/fts.c (opendirat): New arg extra_flags.
(__opendir2): Use it to avoid following symlinks when opening
a directory, if symlinks are not supposed to be followed. See
<http://lists.gnu.org/archive/html/bug-gnulib/2010-09/msg00213.html>.
Paul Eggert [Mon, 13 Sep 2010 19:21:47 +0000 (12:21 -0700)]
fdopendir: preserve argument fd before returning
* lib/fdopendir.c: Adjust comments to say POSIX, not Solaris.
(fdopendir_with_dup, fd_clone_opendir): New static functions.
(fdopendir): Use them, arranging for FD to be open to the same
directory that it was when it started. (It might be temporarily
closed while fdopendir is running, so this not thread- or
signal-safe.) Be careful to do the right thing even when file
descriptors are scarce and dup fails with errno == EMFILE. See
<http://lists.gnu.org/archive/html/bug-gnulib/2010-09/msg00208.html>.
Paul Eggert [Sun, 12 Sep 2010 21:21:52 +0000 (14:21 -0700)]
savedir: add streamsavedir, deprecate fdsavedir
* NEWS: Mention deprecation of fdsavedir.
* lib/savedir.c (streamsavedir): New extern function, whose name
ends in "savedir" to be consistent with the others. This differs
from savedirstream in that it doesn't close its argument. The
next version of GNU tar will use this instead of fdsavedir, to
avoid some race conditions and conserve file descriptors.
(savedirstream): Reimplement as a wrapper around streamsavedir.
(fdsavedir): Add a comment deprecating this function. As far as
I know, only GNU tar used it, and GNU tar doesn't need it any more.
* lib/savedir.h (streamsavedir): New decl.
(fdsavedir): Add a comment deprecating this.
Paul Eggert [Fri, 10 Sep 2010 18:55:27 +0000 (11:55 -0700)]
fcntl-h: define O_CLOEXEC and O_EXEC if not defined; use new defines
* doc/posix-headers/fcntl.texi (fcntl.h): Document that
O_CLOEXEC is now defined to 0 if it is not defined, like other flags.
Also, O_EXEC is now defined to be O_RDONLY if O_EXEC is not defined.
Similarly for O_SEARCH; this last was already true, but not documented.
* lib/fcntl.in.h (O_CLOEXEC): Define to 0 if not defined.
* lib/dup-safer-flag.c (O_CLOEXEC): Remove now-useless #define.
* lib/dup3.c, lib/pipe2.c, tests/test-dup-safer.c, tests/test-fcntl.c:
Likewise.
* lib/popen-safer.c (open_noinherit): Check whether O_CLOEXEC
is zero, not whether it is defined.
* tests/test-dup3.c, tests/test-pipe2.c (main): Likewise.
* lib/progreloc.c (find_executable): Use O_EXEC rather than O_RDONLY.
* lib/open.c (open): Check for O_SEARCH as well as for O_RDONLY.
Bruno Haible [Fri, 10 Sep 2010 10:02:44 +0000 (12:02 +0200)]
pty, readutmp: Fix for FreeBSD 8.0 and OpenBSD 4.6.
* doc/glibc-functions/login_tty.texi: Mention the include file problem
on FreeBSD 8.0 and OpenBSD 4.6.
* lib/pty.in.h: Include <sys/types.h> before <libutil.h>.
* m4/pty_h.m4 (gl_PTY_H): Likewise.
* m4/pty.m4 (gl_FUNC_FORKPTY, gl_FUNC_OPENPTY): Likewise.
* m4/readutmp.m4 (gl_READUTMP): Include <sys/types.h> before <utmp.h>.
Invoke AC_INCLUDES_DEFAULT instead of using the undocumented variable
ac_includes_default.
Reported by Mats Erik Andersson <mats.andersson@gisladisker.se>.
Eric Blake [Thu, 9 Sep 2010 23:05:15 +0000 (17:05 -0600)]
strsignal: work around NetBSD bug
* m4/strsignal.m4 (gl_FUNC_STRSIGNAL): Also check in <unistd.h>.
* lib/string.in.h (includes): Likewise.
* doc/posix-functions/strsignal.texi (strsignal): Document the
bug.
Reported by Nelson H. F. Beebe.
Jim Meyering [Wed, 8 Sep 2010 20:24:22 +0000 (22:24 +0200)]
init.sh: penalize a set-x-impaired shell; don't disqualify it
* tests/init.sh: Too many shells corrupt application stderr when
you set -x, so we can't afford to disqualify them, since at least
on Irix-6.5, that would disqualify all bourne shells.
Instead, use a more discerning approach.
When iterating through candidate shells, give each a score
of 10 for perfect, 9 if corrupts stderr upon set -x but passes
all other tests, and some other value if it is unacceptable.
Use the first shell that gets a score of 10.
If no shell scores 10, use the first that scored 9.
Finally, when VERBOSE=yes is requested and set -x might cause trouble, simply
issue a warning and refrain from enabling debug output.
Eric Blake [Thu, 2 Sep 2010 03:34:44 +0000 (21:34 -0600)]
strtod: work around IRIX 6.5 bug
IRIX mis-parses "1e 1" as 10.0 and "" instead of 1.0 and "e 1".
Because the original parse may differ from the reparse in terms
of whether the value overflows, we have to do an errno dance.
* lib/strtod.c (strtod): Reparse number on shorter string if
exponent parse was invalid.
* tests/test-strtod.c (main): Add check for "0x1p 2".
Reported by Tom G. Christensen.
Jim Meyering [Wed, 8 Sep 2010 13:18:46 +0000 (15:18 +0200)]
init.sh: disqualify shells for which set -x corrupts stderr
* tests/init.sh: Add a test to disqualify /bin/sh from SunOS 5.11
and OpenBSD 4.7. They make it so with "set -x", environment settings
appear in stderr output. For example, this command:
/bin/sh -c 'set -x; P=1 true 2> err' 2>/dev/null; cat err
prints "P=1" on those two systems:
Bruno Haible [Wed, 8 Sep 2010 08:44:26 +0000 (10:44 +0200)]
gnulib-tool: Avoid stderr output on IRIX related to 'alias', 'unalias'.
* gnulib-tool: Use stderr redirection around the 'alias' and 'unalias'
commands, because some shells ignore redirections when there is an
error in the command lookup.
Reported by Eric Blake.
Bruno Haible [Sat, 4 Sep 2010 16:39:03 +0000 (18:39 +0200)]
gnulib-tool: Change --import. New options --add/remove-import.
* gnulib-tool: New options --add-import, --remove-import.
(func_usage): Document them.
(have_associative): Define always.
(func_import): In import mode, don't merge the specified settings with
the cached settings. Implement remove-import mode.
* doc/gnulib-tool.texi (Modified imports): Mention the new options.
Explain when to use them versus --import.
(Simple update): Use --add-import instead of --import.
* NEWS: Mention the change.
Jim Meyering [Sat, 4 Sep 2010 16:16:04 +0000 (18:16 +0200)]
maint.mk: avoid obscure sc_copyright_check failure in coreutils
* top/maint.mk (v_etc_file): Prepend $(gnulib_dir)/, to avoid
false positives (whose names may be ill-chosen) when searching
non-VC'd files. Otherwise, a file named "a b/lib/version-etc.c"
would cause a false-positive.
Jim Meyering [Sat, 4 Sep 2010 15:43:39 +0000 (17:43 +0200)]
avoid coreutils "make distcheck" failure
Coreutils tests with an absolute build directory name that contains
a space. Not quoting this directory name caused a failure.
* tests/test-vc-list-files-git.sh: Quote PATH dir name.
* tests/test-vc-list-files-cvs.sh: Likewise.
Bruno Haible [Sat, 4 Sep 2010 11:58:02 +0000 (13:58 +0200)]
update-copyright test: Improve output when perl is missing or too old.
* tests/test-update-copyright.sh: Move test of Perl version down after
the test whether Perl exists. Provide an explanation relating Perl's
error message to Automake's SKIP: message.