]> Savannah Git Hosting - gnulib.git/log
gnulib.git
8 years agopoll: Enable argument check also in the Windows implementation.
Bruno Haible [Sun, 23 Apr 2017 01:25:10 +0000 (03:25 +0200)]
poll: Enable argument check also in the Windows implementation.

* lib/poll.c (poll) [WINDOWS_NATIVE]: Check value of nfd correctly.
Reported by Paul Eggert.

8 years agogetlogin_r: Work around bug in Mac OS X 10.12.
Bruno Haible [Sun, 23 Apr 2017 00:45:19 +0000 (02:45 +0200)]
getlogin_r: Work around bug in Mac OS X 10.12.

* m4/getlogin_r.m4 (gl_FUNC_GETLOGIN_R): Test also against the Mac OS X
bug.
* lib/getlogin_r.c (getlogin_r): When getlogin_r returns a string of the
given size minus 1, call getlogin_r a second time, on a larger buffer.
* modules/getlogin_r (Depends-on): Add malloca.
* doc/posix-functions/getlogin_r.texi: Mention the Mac OS X bug.

8 years agoparse-datetime: fix %z and prefer signed int
Paul Eggert [Sat, 22 Apr 2017 22:13:24 +0000 (15:13 -0700)]
parse-datetime: fix %z and prefer signed int

%z problem reported by Pádraig Brady in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00103.html
While fixing it, I decided to prefer signed ints to size_t, as
they are less error-prone (e.g., ubsan catches overflow).
* lib/parse-datetime.y (textint, parser_control, lookup_word, yylex)
(parse_datetime2): Prefer ptrdiff_t to size_t for sizes and object
counts, since signed integers make for better debugging.
(date): Don’t assume %z works in printf formats.
(debug_strfdatetime, debug_strfdate, debug_strftime): Use int for
sizes of buffers known to be small, e.g., because we’re using snprintf.
(parse_datetime2): Simplify call to debug_mktime_not_ok.

8 years ago*printf: Work around rounding bug on Mac OS X.
Bruno Haible [Sat, 22 Apr 2017 14:27:45 +0000 (16:27 +0200)]
*printf: Work around rounding bug on Mac OS X.

* m4/printf.m4 (gl_PRINTF_DIRECTIVE_A): Test for Mac OS X 10.12 bug.
* doc/posix-functions/*printf.texi: Mention the rounding bugs of
Mac OS X and FreeBSD.
* doc/glibc-functions/*printf.texi: Likewise.

8 years agovasnprintf tests: Avoid warnings.
Bruno Haible [Sat, 22 Apr 2017 12:51:37 +0000 (14:51 +0200)]
vasnprintf tests: Avoid warnings.

* tests/test-vasnprintf-posix3.c (test_function, my_asnprintf,
test_vasnprintf, test_asnprintf): Don't define if there's nothing to
test.

8 years agosys_file tests: Avoid warning.
Bruno Haible [Sat, 22 Apr 2017 12:43:23 +0000 (14:43 +0200)]
sys_file tests: Avoid warning.

* tests/test-sys_file.c (main): Add a default clause to the switch
statement.

8 years agosethostname: Update doc.
Bruno Haible [Sat, 22 Apr 2017 12:39:09 +0000 (14:39 +0200)]
sethostname: Update doc.

* doc/glibc-functions/sethostname.texi: Mention differing prototype on
Mac OS X.

8 years agoquotearg tests: Avoid warnings.
Bruno Haible [Sat, 22 Apr 2017 12:24:36 +0000 (14:24 +0200)]
quotearg tests: Avoid warnings.

* tests/test-quotearg.c: Don't include test-quotearg.h if ENABLE_NLS is
false.

8 years agopoll: Enable argument check.
Bruno Haible [Sat, 22 Apr 2017 12:18:45 +0000 (14:18 +0200)]
poll: Enable argument check.

* lib/poll.c: Include intprops.h.
(poll): Check value of nfd correctly.
* modules/poll (Depends-on): Add intprops.

8 years agoget-rusage-data: Avoid warnings on Mac OS X.
Bruno Haible [Sat, 22 Apr 2017 11:51:02 +0000 (13:51 +0200)]
get-rusage-data: Avoid warnings on Mac OS X.

* lib/get-rusage-data.c: On Mac OS X, don't define
get_rusage_data_via_setrlimit nor get_rusage_data_via_iterator.
(get_rusage_data) [Mac OS X]: Just return 0.

8 years agoxbinary-io: Fix build error.
Bruno Haible [Sat, 22 Apr 2017 10:02:38 +0000 (12:02 +0200)]
xbinary-io: Fix build error.

* modules/xbinary-io (Depends-on): Add gettext-h.
* lib/xbinary-io.c: Include gettext.h and define _().
Reported by Gisle Vanem <gisle.vanem@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00089.html>.

8 years agoparse-datetime: overflow and debug cleanups
Paul Eggert [Sat, 22 Apr 2017 09:11:26 +0000 (02:11 -0700)]
parse-datetime: overflow and debug cleanups

This long patch was triggered by this bug report from Ruediger Meier:
http://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00028.html
I fixed the bug he noted, then found some others nearby, and then
still others.  Oh my goodness, there were a lot of bugs.  I cleaned
up some of the code to follow GNU standards while I was at it.
* lib/parse-datetime.y (ISDIGIT): Remove; all callers changed to
use c_isdigit.
(EPOCH_YEAR): Remove; unused.
(TM_YEAR_BASE): Now an enum rather than a macro.
(HOUR, debug_strfdatetime): Multiply hour by 3600, not 60, to get
time zone offset, since timezones now are in terms of seconds and
not minutes.
(long_time_t): Remove.  All uses replaced by time_t or intmax_t as
appropriate.  Verify that intmax_t is wide enough.
(time_overflow, time_zone_str): New functions, used to deal
more reliably with overflow.
(dbg_printf): Add printf attribute, to help catch integer width errors.
(textint, relative_time, parser_control, time_zone_hhmm, set_hhmmss)
(%union, to_hour, yylex, parse_datetime2):
Use intmax_t instead of long int and/or long_time_t.
All uses changed.
(DBGBUFSIZE): Move earlier.
(relative_time, set_hhmmss, parser_control):
Just use int for nanoseconds and for time zones; that’s wide enough.
(parser_control): Use bool for members like year_seen that can
be booleans instead of counters.  All uses changed.
Remove debug_default_input_timezone; no longer needed.
All uses removed.
(apply_relative_time): Return a bool overflow flag.
All uses changed to check for overflow.
(apply_relative_time, zone, date, relunit, relunit_snumber)
(signed_seconds, unsigned_seconds, yylex, parse_datetime2):
Check for integer overflow portably.
(str_days): Use just int for N, as it’s wide enough.
Prefer 2D char arrays to arrays of char * when it looks like
2D is a win on typical platforms.
Prefer snprintf to strncpy/strncat, for simplicity;
all buffers are smaller than INT_MAX so this is safe.
(TIME_ZONE_BUFSiZE, TM_YEAR_BUFSIZE): New constants.
(debug_print_current_time): Don’t assume tv_nsec is of type long,
as this is not true on x32.  Output "." before any nanoseconds.
(debug_print_current_time, parse_datetime2):
Output local zones using a more-consistent format.
(debug_print_current_time, date, parse_datetime2):
(main) [TEST]:
Don’t assume time_t is the same width as long.
(print_rel_part): New function, replacing ...
(PRINT_REL_PART): ... this macro, which was removed.  All uses changed.
(debug_print_relative_time): Use bool for boolean.
(local_zone): dsts_seen now counts only tDST instances.
(date): Fix printf of size_t to use %z.  Do not assume numeric
tokens have negative values merely because the context suggests
a syntax with "-" separating tokens.
(time_zone_hhmm): Return bool success indicator, which checks for
overflow.  Store result into PC->time_zone instead.  All callers
changed.
(tm_year_str): New function.  Return a bool success indicator and
store the result into a buffer.  All callers changed.  Output the
numerically correct string even if adding 1900 to the year would
overflow.
(to_tm_year): New function, replacing the old to_year.  All
callers changed.
(tm_diff): Sync with glibc.
(lookup_word): Use to_uchar instead of doing it by hand.
(TZBUFSIZE): Now local to the only function that needs it.
(debug_strfdatetime): Simplify now that time zones are int seconds.
(debug_strfdate): Work even if tm_year + 1900 would overflow.
(get_effective_timezone): Remove.  All uses removed.
(parse_datetime2): Use fprintf in pieces instead of snprintfing
to a fixed-size buffer.  Don’t assume that gmtime succeeds iff
localtime succeeds.  Use tm_gmtoff if available.  Simplify how
‘goto fail;’ works in conjunction with the ‘ok’ flag.
* m4/parse-datetime.m4 (gl_PARSE_DATETIME): Don’t define
TIME_T_FITS_IN_LONG_INT, as it is no longer needed.
* modules/parse-datetime (Depends-on): Add inttypes.

8 years agogettext-h: Avoid -Wundef warning.
Bruno Haible [Fri, 21 Apr 2017 23:37:22 +0000 (01:37 +0200)]
gettext-h: Avoid -Wundef warning.

* lib/gettext.h: Test the value of ENABLE_NLS only if it is defined.
Reported by Tim Rühsen <tim.ruehsen@gmx.de> in
<https://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00022.html>.

8 years agoerror: Avoid "function declaration isn't a prototype" warning.
Tim Rühsen [Wed, 5 Apr 2017 13:58:22 +0000 (15:58 +0200)]
error: Avoid "function declaration isn't a prototype" warning.

* lib/error.c (strerror_r): Turn K&R C prototype to an ANSI C prototype.

8 years agovasnprintf: Fix for MSVC 14.
Bruno Haible [Fri, 21 Apr 2017 15:24:48 +0000 (17:24 +0200)]
vasnprintf: Fix for MSVC 14.

* lib/vasnprintf.c (USE_MSVC__SNPRINTF): New macro.
Everywhere, use !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF instead
of !HAVE_SNPRINTF_RETVAL_C99.

8 years agombrtowc tests: Fix test failures on MSVC 14.
Bruno Haible [Fri, 21 Apr 2017 14:55:49 +0000 (16:55 +0200)]
mbrtowc tests: Fix test failures on MSVC 14.

* tests/test-mbrtowc-w32.c (test_one_locale): Accept MSVC's conversion
behaviour for invalid input.

8 years agombsinit: Fix for MSVC 14.
Bruno Haible [Fri, 21 Apr 2017 14:43:01 +0000 (16:43 +0200)]
mbsinit: Fix for MSVC 14.

* lib/mbsinit.c (mbsinit): If GNULIB_defined_mbstate_t, provide an
implementation that is in sync with mbrtowc.c. On other platforms, use
an adequate ad-hoc implementation.

8 years agoFix test-mbrtowc5.sh failure on native Windows.
Bruno Haible [Fri, 21 Apr 2017 13:41:54 +0000 (15:41 +0200)]
Fix test-mbrtowc5.sh failure on native Windows.

* lib/setlocale.c (setlocale_unixlike): Accept "POSIX" as an alias for
"C".

8 years agoAvoid accidental use of native Windows APIs on Cygwin.
Bruno Haible [Fri, 21 Apr 2017 13:28:40 +0000 (15:28 +0200)]
Avoid accidental use of native Windows APIs on Cygwin.

* lib/getaddrinfo.c (WINDOWS_NATIVE): Don't define on Cygwin.
* lib/localcharset.c (WINDOWS_NATIVE): Likewise.
* lib/localename.c (WINDOWS_NATIVE): Likewise.

8 years agoRemove red warnings from the generated MODULES.html.
Bruno Haible [Fri, 21 Apr 2017 01:10:32 +0000 (03:10 +0200)]
Remove red warnings from the generated MODULES.html.

* modules/fcntl (Description): Disambiguate function references.
* modules/getcwd-lgpl (Description): Likewise.
* modules/hostent (Description): Likewise.
* modules/servent (Description): Likewise.
* modules/tempname (Description): Likewise.

8 years agoverify tests: Fix spurious failure with parallel make.
Bruno Haible [Thu, 20 Apr 2017 19:27:40 +0000 (21:27 +0200)]
verify tests: Fix spurious failure with parallel make.

* gnulib-tool (func_emit_tests_Makefile_am): Emit initialization of
EXTRA_PROGRAMS.
* tests/test-verify.sh: Build test-verify-try.o, not test-verify.o.
* tests/test-verify-try.c: New file.
* modules/verify-tests (Files): Add it.
(EXTRA_PROGRAMS): Add test-verify-try.
(MOSTLYCLEANFILES): Update accordingly.
Reported by Adam James Stewart <ajstewart@anl.gov>.

8 years agovma-iter: Fix compilation error on Solaris 7.
Bruno Haible [Tue, 18 Apr 2017 23:27:17 +0000 (01:27 +0200)]
vma-iter: Fix compilation error on Solaris 7.

* lib/vma-iter.c (vma_iterate): Treat missing MAP_ANONYMOUS on Solaris
like on IRIX, OSF/1.
Reported by Tom G. Christensen <tgc@jupiterrise.com>.

8 years agovma-iter: Fix conflict with module 'largefile' on 32-bit Solaris 9.
Bruno Haible [Tue, 18 Apr 2017 23:03:34 +0000 (01:03 +0200)]
vma-iter: Fix conflict with module 'largefile' on 32-bit Solaris 9.

* modules/vma-iter (configure.ac): Test whether <sys/procfs.h> can be
included.
* lib/vma-iter.c: On Solaris, test HAVE_SYS_PROCFS_H before including
<sys/procfs.h>.
* lib/vma-iter.h (VMA_ITERATE_SUPPORTED): Don't define on Solaris when
<sys/procfs.h> cannot be included.
Reported by Tom G. Christensen <tgc@jupiterrise.com>.

8 years agogetopt-gnu: Add comments.
Bruno Haible [Tue, 18 Apr 2017 22:05:34 +0000 (00:05 +0200)]
getopt-gnu: Add comments.

* m4/getopt.m4 (gl_FUNC_GETOPT_GNU): Add comments.
* modules/getopt-gnu (configure.ac): Likewise.

8 years agoregex: port better to Solaris 10
Paul Eggert [Sun, 16 Apr 2017 19:43:20 +0000 (12:43 -0700)]
regex: port better to Solaris 10

Solaris 10 <locale.h> includes <libintl.h>, which #defines
gettext, and this causes a double #define.
Problem reported by Gavin Smith in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00056.html
* lib/regex_internal.h (gettext): #undef before #defining.

8 years agoautoupdate
Karl Berry [Sat, 15 Apr 2017 21:37:10 +0000 (14:37 -0700)]
autoupdate

8 years agointprops: improve comments
Paul Eggert [Sat, 15 Apr 2017 21:27:11 +0000 (14:27 -0700)]
intprops: improve comments

* lib/intprops.h: Improve and shorten commentary.
For the record, if we ever run into a pedantic compiler that
behaves differently from GCC when converting an out-of-range value
to a signed integer, we can work around the problem with something
like the following code, where UCT is the signed counterpart of T
(UCT is sometimes narrower than UT) and all callers are changed
accordingly:
   ((t) ((ut) (a) op (ut) (b)))
   (TYPE_MINIMUM (t) <= (uct) ((ut) (a) op (ut) (b)) \
    ? ((t) (uct) (((ut) (a) op (ut) (b)) - TYPE_MINIMUM (t)) \
       + TYPE_MINIMUM (t)) \
    : (t) (uct) ((ut) (a) op (ut) (b)))

8 years agointprops: fix comment typo
Paul Eggert [Sat, 15 Apr 2017 02:03:20 +0000 (19:03 -0700)]
intprops: fix comment typo

8 years agointprops: try to avoid tickling similar bugs
Paul Eggert [Sat, 15 Apr 2017 01:55:42 +0000 (18:55 -0700)]
intprops: try to avoid tickling similar bugs

* lib/intprops.h (_GL_INT_OP_CALC): Document that UT no longer
needs to be the same width as T; it can be wider.
Change callers so that UT is at least as wide as unsigned int,
as I suspect that this is less likely to run into compiler bugs.

8 years agointprops: port to Oracle Studio 12.3 x86
Paul Eggert [Sat, 15 Apr 2017 00:38:58 +0000 (17:38 -0700)]
intprops: port to Oracle Studio 12.3 x86

Problem reported by Gavin Smith in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00049.html
* lib/intprops.h (_GL_INT_OP_WRAPV_VIA_UNSIGNED):
Convert unsigned to signed via the usual rather than the standard way,
to avoid a compiler bug in Oracle Studio 12.3 x86.

8 years agogetopt: prefer - to _ in new file names
Paul Eggert [Sun, 9 Apr 2017 06:48:02 +0000 (23:48 -0700)]
getopt: prefer - to _ in new file names

* lib/getopt-cdefs.in.h: Rename from lib/getopt_cdefs.in.h.
* lib/getopt-core.h: Rename from lib/getopt_core.h.
* lib/getopt-ext.h: Rename from lib/getopt_ext.h.
* lib/getopt-pfx-core.h: Rename from lib/getopt_pfx_core.h.
* lib/getopt-pfx-ext.h: Rename from lib/getopt_pfx_ext.h.
All uses changed.

8 years agogetopt: port recent getopt changes to macOS
Paul Eggert [Sun, 9 Apr 2017 00:26:03 +0000 (17:26 -0700)]
getopt: port recent getopt changes to macOS

Problem reported by Harald Maier (Bug#26398).
The macOS C compiler uses __nonnull for its own purposes and that
clashes with glibc's __nonnull.
* lib/getopt.in.h: Add comment for _GL_ARG_NONNULL snippet.
* lib/getopt_cdefs.in.h (__nonnull): Remove.
* lib/getopt_core.h (getopt):
* lib/getopt_ext.h (getopt_long, getopt_long_only):
Use _GL_ARG_NONNULL, not __nonnull.
* lib/unistd.in.h: Move snippet hooks to before where the getopt
.h files are included, so that _GL_ARG_NONNULL is defined in time.
* modules/getopt-posix (Depends-on): Add snippet/arg-nonnull.
(getopt.h): Interpolate _GL_ARG_NONNULL snippet.

8 years agogetopt-gnu: omit some duplicate code
Paul Eggert [Thu, 6 Apr 2017 22:41:05 +0000 (15:41 -0700)]
getopt-gnu: omit some duplicate code

* m4/getopt.m4 (gl_FUNC_GETOPT_GNU): Don’t require
gl_FUNC_GETOPT_POSIX, as the configure.ac code generated by
gnulib-tool already does this.
* modules/getopt-gnu (configure.ac): Omit code duplicated from
getopt-posix, which we depend on.

8 years agogetopt-posix: use angle-bracket include
Paul Eggert [Thu, 6 Apr 2017 20:15:46 +0000 (13:15 -0700)]
getopt-posix: use angle-bracket include

* lib/getopt1.c: Include <config.h>, not "config.h".

8 years agogetopt: annotate files with relationship to glibc
Zack Weinberg [Thu, 6 Apr 2017 18:14:14 +0000 (11:14 -0700)]
getopt: annotate files with relationship to glibc

As the final act in this patchset, adjust the message at the top of
each file to indicate which files are synced with glibc.  (This has
already been done for most of the headers.)

* lib/getopt.c, lib/getopt1.c, lib/getopt_int.h:
Mention in top-of-file boilerplate that these files are shared
between glibc and gnulib.

8 years agogetopt: split up getopt.in.h and eliminate __need_getopt
Zack Weinberg [Thu, 6 Apr 2017 18:14:14 +0000 (11:14 -0700)]
getopt: split up getopt.in.h and eliminate __need_getopt

Over in glibc, all of the __need macros are being phased out in favor
of small headers that declare only the necessary components, as this
is much simpler and less prone to bugs.  As getopt is shared with
glibc, gnulib needs to do the same for __need_getopt.

__need_getopt is misnamed; what it really means is "we want only the
getopt features specified in POSIX, not the GNU extensions".  glibc
placed the "meat" of getopt.h into getopt_core.h and getopt_ext.h;
these files can be shared verbatim with gnulib.  The portability
wrapper, on the other hand, they have renounced altogether; glibc's
getopt.h will no longer be shared with gnulib at all.  In exchange,
certain glibc-specific quirks (having to do with __posix_getopt) no
longer need appear in gnulib's headers at all.

This patch merges getopt_core.h and getopt_ext.h from glibc, and
splits up the current gnulib-side portability wrapper into three
additional headers: getopt_pfx_core.h and getopt_pfx_ext.h handle
__GETOPT_PREFIX for their respective headers, getopt_cdefs.in.h
handles things like __BEGIN_DECLS and __THROW, and getopt.in.h and
unistd.in.h just use them.  All new files are clearly marked with
whether they are shared with glibc.

* lib/getopt.in.h: Eliminate __need_getopt.  Break up into ...
* lib/getopt_core.h, lib/getopt_ext.h: ... these new files shared
with glibc, and ...
* lib/getopt_cdefs.in.h, lib/getopt_pfx_core.h
* lib/getopt_pfx_ext.h: ... these new files not shared with glibc.
* lib/unistd.in.h: Include getopt_cdefs.h and getopt_pfx_core.h,
instead of defining __need_getopt and including the full getopt.h.

* m4/getopt.m4 (gl_GETOPT_SUBSTITUTE_HEADER): Check for sys/cdefs.h.
Define substitution variables GETOPT_CDEFS_H and HAVE_SYS_CDEFS_H.
* modules/getopt-posix (Files): Add new headers and sort list.
(Depends-on): No longer need snippet/arg-nonnull.
(Makefile.am): Generate getopt_cdefs.h.

8 years agogetopt: better handling of ambiguous options
Zack Weinberg [Thu, 6 Apr 2017 18:14:14 +0000 (11:14 -0700)]
getopt: better handling of ambiguous options

glibc's getopt uses alloca to construct a linked list of possibilities
for an "ambiguous" long option.  In gnulib, malloc should be used
instead.  Providing for both cases complicates things a fair bit.

This patch rewrites ambiguous-option handling to use a boolean vector
instead of a linked list.  There is then only one allocation that
might need freeing; in glibc it can honor __libc_use_alloca as usual,
and in gnulib we define __libc_use_alloca to always be false, so we
don't need ifdefs in the middle of the function.  This should also be
slightly more efficient in the normal case of long options being fully
spelled out -- I think most people aren't even aware they _can_
sometimes abbreviate long options.

One interesting consequence is that the list of possibilities is now
printed in exactly the order they appear in the list of long options,
instead of the first possibility being shuffled to the end.

(The patch looks bigger than it really is because there's a fair bit
of reindentation and code rearrangement.)

* lib/getopt.c: When used standalone, define __libc_use_alloca
as always false and alloca to abort if called.
(process_long_option): Rewrite handling of ambiguous long options
to use a single boolean vector, not a linked list; use
__libc_use_alloca to decide whether to allocate this using alloca.

8 years agogetopt: refactor long-option handling
Zack Weinberg [Thu, 6 Apr 2017 18:14:14 +0000 (11:14 -0700)]
getopt: refactor long-option handling

There were two copies of the bulk of the code to handle long options.
Now there is only one.

This change temporarily removes the logic to avoid using alloca when
standalone; the next patch in the series will restore it.

* lib/getopt.c (process_long_option): New function split out
from _getopt_internal_r.
(_getopt_internal_r): Replace both copies of the long-option
processing code with calls to process_long_option.

8 years agogetopt: tidy up _getopt_initialize a bit
Zack Weinberg [Thu, 6 Apr 2017 18:14:14 +0000 (11:14 -0700)]
getopt: tidy up _getopt_initialize a bit

_getopt_data.__posixly_correct is completely redundant to
_getopt_data.__ordering, and some work that logically belongs in
_getopt_initialize was being done by _getopt_internal_r, making the
code harder to understand.

As a side effect, getenv will no longer be called if the first
character of the options string is '+' or '-', which is probably a
Good Thing.  (Perhaps we should have a flag character that
specifically asks for the permutation behavior?)

* lib/getopt_int.h (_getopt_data): Remove __posixly_correct field.
* lib/getopt.c (_getopt_internal_r): Move some initialization code...
(_getopt_initialize): ...here. Don't set d->__posixly_correct.

8 years agogetopt: merge from glibc: repetition reduction
Zack Weinberg [Thu, 6 Apr 2017 18:14:14 +0000 (11:14 -0700)]
getopt: merge from glibc: repetition reduction

The definitions of the entry point functions 'getopt' and
'__posix_getopt' can be made substantially less repetitive with a
helper macro.

While I was merging the const-correctness changes from gnulib into
glibc I noticed there are still some unnecessary casts in
_getopt_internal_r.

* lib/getopt.c (getopt, __posix_getopt): Eliminate repetition with
a macro.  Consistently cast 'argv' to 'char **' when calling
_getopt_internal.
(_getopt_internal_r): Remove unnecessary casts when calling exchange.

8 years agogetopt: clean up error reporting
Zack Weinberg [Thu, 6 Apr 2017 18:14:14 +0000 (11:14 -0700)]
getopt: clean up error reporting

getopt can print a whole bunch of error messages, and when used
standalone (from gnulib) it uses fprintf to do that.  But fprintf is a
cancellation point and getopt isn't, and also applying fprintf to a
stream in wide-character mode is not allowed.  So every single error
reporting case has an #ifdef _LIBC block in which it calls internal
libc functions instead.  The counterpart patch series in glibc makes
it possible to simplify all of that down to a set of #defines at the
top of the file; core code is written as if it is safe to just call
fprintf, flockfile, and funlockfile.  (One caveat: it's *not* safe to
call any *other* stdio functions.)

* lib/getopt.c: When _LIBC is defined, define fprintf to
__fxprintf_nocancel, flockfile to _IO_flockfile, and funlockfile
to _IO_funlockfile.  When neither _LIBC nor
_POSIX_THREAD_SAFE_FUNCTIONS is defined, define flockfile and
funlockfile as no-ops.
(_getopt_internal_r): Remove all internal #ifdef _LIBC blocks; the
standalone error-printing code can now be used for libc as well.
Add an flockfile/funlockfile pair around one case where the error
message is printed in several chunks.  Don't use fputc.

8 years agogetopt: fix fencepost error in ambiguous-W-option handling
Zack Weinberg [Thu, 6 Apr 2017 18:14:13 +0000 (11:14 -0700)]
getopt: fix fencepost error in ambiguous-W-option handling

getopt_long contains an undocumented (AFAICT) feature in which, if you
put "W;" in the short-options list, then '-W foo' and '-Wfoo' are
treated as equivalent to '--foo'.  This is implemented with a partial
second copy of the code for handling long options, and that code
increments optind one too many times when recovering from an ambiguous
abbreviated option, which can cause the main loop to walk past the end
of argv and crash.

I discovered this while writing a test case that tries to exercise all
of getopt's error reporting paths; I wouldn't be surprised to learn
that this feature is never used by real applications.

* lib/getopt.c (_getopt_internal_r): Don't increment
d->optind a second time when reporting ambiguous -W options.

8 years agogetopt: clean up getopt.c and getopt1.c file headers
Zack Weinberg [Thu, 6 Apr 2017 18:14:13 +0000 (11:14 -0700)]
getopt: clean up getopt.c and getopt1.c file headers

In getopt.c, there is no need to include wchar.h at all, and it is
safe nowadays to assume that stdlib.h does declare getenv (several
other gnulib modules make this assumption).

In getopt1.c, the #ifdef _LIBC block at the top can be simplified
by using "" inclusions consistently, and there is no actual need to
include stdlib.h (except in the #ifdef TEST block, where it should be
unconditional), nor to provide a backup definition of NULL at all.

* lib/getopt1.c: Simplify #ifdeffage at top of file.
Move inclusion of stdlib.h to #ifdef TEST block and make
unconditional.  Do not define NULL.
* lib/getopt.c: Don't include wchar.h. No need to declare getenv.
* m4/getopt.m4 (gl_PREREQ_GETENV): Delete.
* modules/getopt-gnu, modules/getopt-posix: Don't call
gl_PREREQ_GETENV.

8 years agogetopt: harmonize comments with glibc
Zack Weinberg [Thu, 6 Apr 2017 18:14:13 +0000 (11:14 -0700)]
getopt: harmonize comments with glibc

The comments explaining how the behavior of 'getopt' varies depending
on whether it's the standalone version and whether there are special
characters at the beginning of the options string were inconsistent
between gnulib and glibc, and also out of sync with the code.

* lib/getopt.c, lib/getopt_int.h: Harmonize comments with glibc.

8 years agogetopt: remove USE_NONOPTION_FLAGS
Zack Weinberg [Thu, 6 Apr 2017 18:14:13 +0000 (11:14 -0700)]
getopt: remove USE_NONOPTION_FLAGS

getopt includes code to parse an environment variable named
_XXX_GNU_nonoption_argv_flags_ (where XXX is the current process's PID
in decimal); but all of it has been #ifdefed out since 2001, with no
official way to turn it back on.

According to commentary in glibc's config.h.in, bash version 2.0
set this environment variable to indicate argv elements that were
the result of glob expansion and therefore should not be treated
as options, but the feature was "disabled later" because "it
caused problems".  According to bash's CHANGES file, "later" was
release 2.01; it gives no more detail about what the problems
were.

Version 2.0 of bash was released on the last day of 1996, and version
2.01 in June of 1997.  Twenty years later, I think it is safe to
assume that this environment variable isn't coming back.

* lib/getopt_int.h: Remove all #ifdef USE_NONOPTION_FLAGS blocks.
* lib/getopt.c: Likewise. Also remove SWAP_FLAGS and the
__libc_argc and __libc_argv externs, which were only used by

8 years agogetopt: tabify, in preparation for merge with glibc
Zack Weinberg [Thu, 6 Apr 2017 18:14:13 +0000 (11:14 -0700)]
getopt: tabify, in preparation for merge with glibc

glibc sticks to the GNU default of indenting with a mix of
8-column tabs and spaces; make the gnulib copy match.

getopt.h is not included because it is *not* going to be merged in its
present form.

* getopt.c, getopt1.c, getopt_int.h: Tabify.

8 years agorelocatable-lib-lgpl: Fix link error (regression from 2011-06-16).
Bruno Haible [Sun, 2 Apr 2017 19:53:54 +0000 (21:53 +0200)]
relocatable-lib-lgpl: Fix link error (regression from 2011-06-16).

* modules/relocatable-lib-lgpl (configure.ac): Add AC_LIBOBJ invocation,
like it was done in modules/relocatable-lib on 2011-05-21 and in
modules/relocatable-prog on 2011-08-15.
Reported by Reuben Thomas <rrt@sc3d.org>.

8 years agoautoupdate
Karl Berry [Sun, 2 Apr 2017 13:51:11 +0000 (06:51 -0700)]
autoupdate

8 years agoglob: Fix invalid free() call.
Bruno Haible [Fri, 31 Mar 2017 20:43:35 +0000 (22:43 +0200)]
glob: Fix invalid free() call.

* lib/glob.c (glob): Reset malloc_home_dir when assigning a pointer to
static storage to home_dir.
Reported by Coverity via Tim Rühsen.

8 years agoglob: Fix memory leaks.
Bruno Haible [Fri, 31 Mar 2017 20:41:38 +0000 (22:41 +0200)]
glob: Fix memory leaks.

* lib/glob.c (glob): Free allocated memory before returning.
Reported by Coverity via Tim Rühsen.

8 years agomd5, sha1, sha256, sha512: Add comments regarding correctness.
Bruno Haible [Fri, 31 Mar 2017 20:03:49 +0000 (22:03 +0200)]
md5, sha1, sha256, sha512: Add comments regarding correctness.

* lib/md5.h (buflen): Add comments regarding range.
* lib/sha1.h (buflen): Likewise.
* lib/sha256.h (buflen): Likewise.
* lib/sha512.h (buflen): Likewise.
* lib/md5.c (md5_process_bytes): Add comment why memmove is not needed.
* lib/sha1.c (sha1_process_bytes): Likewise.
* lib/sha256.c (sha256_process_bytes): Likewise.
* lib/sha512.c (sha512_process_bytes): Likewise.
Reported by Coverity via Tim Rühsen.

8 years agoautoupdate
Karl Berry [Mon, 27 Mar 2017 14:57:41 +0000 (07:57 -0700)]
autoupdate

8 years agousers.txt: add grub link
Andrei Borzenkov [Thu, 23 Mar 2017 16:20:41 +0000 (19:20 +0300)]
users.txt: add grub link

8 years agogetopt: merge from glibc
Paul Eggert [Wed, 22 Mar 2017 17:25:04 +0000 (10:25 -0700)]
getopt: merge from glibc

This does not change anything substantial; it merely simplifies
hypothetical merges back to glibc.
* lib/getopt.c, lib/getopt.in.h, lib/getopt1.c, lib/getopt_int.h:
Change copyright notice to match what is in glibc.
* lib/getopt.c: Reorder includes to match glibc.  Remove uses of
USE_IN_LIBIO.  Remove 'register'.  In __LIBC code, use
__open_memstream rather than open_memstream and __glibc_likely
instead of __builtin_expect.
* lib/getopt.in.h (__posix_getopt) [!__GETOPT_PREFIX]: New decl.

8 years agodfa: make [0-9] faster in non-C locales
Paul Eggert [Wed, 22 Mar 2017 02:05:17 +0000 (19:05 -0700)]
dfa: make [0-9] faster in non-C locales

Problem reported by John P. Linderman (Bug#26193).
* lib/dfa.c (parse_bracket_exp): Remove redundant assignment.
If both ends of the range are ASCII digits, do not worry about
multi-character collating sequences and the like.  Be consistent
about using isalpha as a precondition for setbit_case_fold_c.

8 years agoautoupdate
Karl Berry [Tue, 21 Mar 2017 13:51:56 +0000 (06:51 -0700)]
autoupdate

8 years agolock: Fix compilation error with HP-UX IA64 cc.
Bruno Haible [Sun, 19 Mar 2017 19:42:43 +0000 (20:42 +0100)]
lock: Fix compilation error with HP-UX IA64 cc.

* lib/glthread/lock.h (pthread_rwlockattr_setkind_np): Don't declare
weak on non-glibc platforms.

8 years agostdalign: tweak version# and test for HP-UX IA64
Paul Eggert [Sun, 19 Mar 2017 16:34:23 +0000 (09:34 -0700)]
stdalign: tweak version# and test for HP-UX IA64

Problems reported by Bruno Haible in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-03/msg00078.html
* lib/stdalign.in.h (_Alignas):
* m4/stdalign.m4 (gl_STDALIGN_H):
Use octal, not decimal, for __HP_cc version.  Perhaps HP formerly
used octal (as that is how they document it), but it is decimal in
practice now and the ancient implementations no longer matter.
* tests/test-stdalign.c (main) [__HP_cc && __ia64]: Skip test.

8 years agovma-iter: Add support for Solaris.
Bruno Haible [Sun, 19 Mar 2017 14:45:26 +0000 (15:45 +0100)]
vma-iter: Add support for Solaris.

* lib/vma-iter.c (vma_iterate): On Solaris, use the /proc filesystem
approach.
* lib/vma-iter.h (VMA_ITERATE_SUPPORTED): Define also on Solaris.
* lib/get-rusage-as.c: Update comment about Solaris.
* lib/get-rusage-data.c: Likewise.

8 years agovma-iter: Prefer HP-UX specific API on HP-UX.
Bruno Haible [Sun, 19 Mar 2017 13:19:07 +0000 (14:19 +0100)]
vma-iter: Prefer HP-UX specific API on HP-UX.

* lib/vma-iter.c (vma_iterate): Move HP-UX specific implementation up.
* lib/vma-iter.h: Update.
Just in case HP-UX ever implements mquery().

8 years agostdalign: restore previous behavior for HP-UX IA64
Paul Eggert [Sun, 19 Mar 2017 05:35:02 +0000 (22:35 -0700)]
stdalign: restore previous behavior for HP-UX IA64

See Bruno Haible's email in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-03/msg00066.html
which cites p 150 of a manual saying that 'aligned' works on Itanium.
* lib/stdalign.in.h (_Alignas):
Assume the '061200' applies to Itanium, not to PA-RISC.
* m4/stdalign.m4 (gl_STDALIGN_H): Adjust to match stdalign.in.h.

8 years agostat-time, timespec: Support use of the header files in C++ mode.
Bruno Haible [Fri, 17 Mar 2017 23:43:36 +0000 (00:43 +0100)]
stat-time, timespec: Support use of the header files in C++ mode.

* lib/stat-time.h: Add "C" linkage declaration.
* lib/timespec.h: Likewise.

8 years agostdalign: Make it work with HP-UX cc.
Bruno Haible [Wed, 15 Mar 2017 20:44:13 +0000 (21:44 +0100)]
stdalign: Make it work with HP-UX cc.

* lib/stdalign.in.h (_Alignas): Don't define for HP-UX cc.
* m4/stdalign.m4 (gl_STDALIGN_H): No need to enable the extra test
for HP-UX cc.

8 years agoflexmember: try to detect HP-UX 11.31 cc bug
Paul Eggert [Fri, 17 Mar 2017 08:37:34 +0000 (01:37 -0700)]
flexmember: try to detect HP-UX 11.31 cc bug

Problem reported by Bruno Haible in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-03/msg00066.html
* m4/flexmember.m4 (AC_C_FLEXIBLE_ARRAY_MEMBER):
Attempt to detect bug in HP-UX 11.31 cc.

8 years agostdint: Fix test compilation failure with HP-UX 11 cc.
Bruno Haible [Thu, 16 Mar 2017 22:55:49 +0000 (23:55 +0100)]
stdint: Fix test compilation failure with HP-UX 11 cc.

* lib/stdint.in.h (_STDINT_MIN): Remove macro.
(_STDINT_UNSIGNED_MIN, _STDINT_SIGNED_MIN): New macros.
(PTRDIFF_MIN, SIG_ATOMIC_MIN, WCHAR_MIN, WINT_MIN): Define using
_STDINT_UNSIGNED_MIN, _STDINT_SIGNED_MIN.

8 years agognulib-tool: Don't produce a tests directory with only snippet .h files.
Bruno Haible [Wed, 15 Mar 2017 22:24:03 +0000 (23:24 +0100)]
gnulib-tool: Don't produce a tests directory with only snippet .h files.

* gnulib-tool (func_modules_transitive_closure_separately): If
testsrelated_modules ends up with no "real" modules, aside from
modules with applicability 'all', set it to empty.

8 years agovma-iter: Add support for HP-UX.
Bruno Haible [Wed, 15 Mar 2017 21:07:56 +0000 (22:07 +0100)]
vma-iter: Add support for HP-UX.

* modules/vma-iter (configure.ac): Check for 'pstat_getprocvm'.
* lib/vma-iter.c (vma_iterate): On HP-UX, use pstat_getprocvm().
* lib/vma-iter.h (VMA_ITERATE_SUPPORTED): Define also on HP-UX.
* lib/get-rusage-as.c: Update comment about HP-UX.
* lib/get-rusage-data.c: Likewise.
(get_rusage_data): Use get_rusage_data_via_setrlimit.

8 years agolimits-h: Make it work with HP-UX cc.
Bruno Haible [Wed, 15 Mar 2017 20:22:00 +0000 (21:22 +0100)]
limits-h: Make it work with HP-UX cc.

* lib/limits.in.h (LLONG_MIN, LLONG_MAX, ULLONG_MAX): Define if not
defined.

8 years agoFix test failures on DragonFlyBSD.
Bruno Haible [Wed, 15 Mar 2017 19:32:45 +0000 (20:32 +0100)]
Fix test failures on DragonFlyBSD.

* tests/test-localeconv.c (main): Treat DragonFlyBSD like FreeBSD.
* tests/test-select.h (test_bad_fd): Likewise.
* tests/test-get-rusage-data.c (main): Treat DragonFlyBSD like OpenBSD.

8 years agofreadahead: Silence warning on DragonFlyBSD.
Bruno Haible [Wed, 15 Mar 2017 17:53:58 +0000 (18:53 +0100)]
freadahead: Silence warning on DragonFlyBSD.

* lib/freadahead.c (__sreadahead): Declare ourselves.

8 years agovma-iter: Add comment about AIX.
Bruno Haible [Tue, 14 Mar 2017 23:12:50 +0000 (00:12 +0100)]
vma-iter: Add comment about AIX.

* lib/vma-iter.c: Add comment about why this module is not implemented
on AIX.

8 years agosnippets: move unadjusted snippet sources to lib
Paul Eggert [Tue, 14 Mar 2017 20:23:25 +0000 (13:23 -0700)]
snippets: move unadjusted snippet sources to lib

Problem reported by Michal Privoznik in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-03/msg00039.html
* lib/_Noreturn.h: Rename from build-aux/snippet/_Noreturn.h.
* lib/arg-nonnull.h: Rename from build-aux/snippet/arg-nonnull.h.
* lib/c++defs.h: Rename from build-aux/snippet/c++defs.h.
* lib/unused-parameter.h: Rename from
build-aux/snippet/unused-parameter.h.
* lib/warn-on-use.h: Rename from build-aux/snippet/warn-on-use.h.
* modules/snippet/_Noreturn (Files:, _NORETURN_H):
* modules/snippet/arg-nonnull (Files:, ARG_NONNULL_H):
* modules/snippet/c++defs (Files:, CXXDEFS_H):
* modules/snippet/unused-parameter (Files:, UNUSED_PARAMETER_H):
* modules/snippet/warn-on-use (Files: WARN_ON_USE_H):
Adjust to file renamings.

8 years agognulib-tool: don't automatically distribute files from top/
Mathieu Lirzin [Tue, 14 Mar 2017 11:19:40 +0000 (12:19 +0100)]
gnulib-tool: don't automatically distribute files from top/

* gnulib-tool (func_get_automake_snippet_unconditional): To be able to
not distribute top/README-release by default, don't distribute files
from top/ unconditionally.
* modules/gnumakefile (Makefile.am): Distribute top/GNUmakefile.
* modules/maintainer-makefile (Makefile.am): Distribute top/maint.mk.

8 years agousers.txt: Update link to libvirt's repo
Michal Privoznik [Tue, 14 Mar 2017 12:22:47 +0000 (13:22 +0100)]
users.txt: Update link to libvirt's repo

The currently listed link does not exist anymore. For a quite
long time the libvirt's repo lives on libvirt.org server.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agognulib-tool: fix typo in comment output
Paul Eggert [Tue, 14 Mar 2017 15:39:27 +0000 (08:39 -0700)]
gnulib-tool: fix typo in comment output

* gnulib-tool (func_import): Fix typo with previous change.

8 years agosnippets: work around GNU Make 3.82 VPATH
Paul Eggert [Tue, 14 Mar 2017 08:20:11 +0000 (01:20 -0700)]
snippets: work around GNU Make 3.82 VPATH

When using 'gnulib-tool --gnu-make' on Emacs, and building
the resulting tarball on Solaris 10 which bundles GNU Make 3.82,
an out-of-source (VPATH) build failed because the sans-copyright
snippet file was not built before the file that used it.
Presumably this is some sort of VPATH thing.  Work around the
problem by using the original snippet, i.e., don’t bother to
remove its copyright notice.
* modules/snippet/_Noreturn, modules/snippet/link-warning:
Don’t assume Automake in comments.  Omit long-incorrect comment.
* modules/snippet/arg-nonnull (BUILT_SOURCES, arg-nonnull.h)
(MOSTLYCLEANFILES):
* modules/snippet/c++defs (BUILT_SOURCES, c++defs.h)
(MOSTLYCLEANFILES):
* modules/snippet/unused-parameter (BUILT_SOURCES, unused-parameter.h)
(MOSTLYCLEANFILES):
* modules/snippet/warn-on-use (BUILT_SOURCES, warn-on-use.h)
(MOSTLYCLEANFILES):
Remove.
* modules/snippet/arg-nonnull (ARG_NONNULL_H):
* modules/snippet/c++defs (CXXDEFS_H):
* modules/snippet/unused-parameter (UNUSED_PARAMETER_H):
* modules/snippet/warn-on-use (WARN_ON_USE_H):
Don’t bother to remove the copyright notice; just use the
original snippet as-is.

8 years agognulib-tool: minor --gnu-make fixups
Paul Eggert [Mon, 13 Mar 2017 22:50:44 +0000 (15:50 -0700)]
gnulib-tool: minor --gnu-make fixups

* gnulib-tool (func_emit_lib_Makefile_am):
Remove useless code that was a blind alley during implementation.
Problem reported by Thien-Thi Nguyen in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-03/msg00029.html
(func_import): Note the "--gnu-make" option in the output comment.

8 years agognulib-tool: new option --gnu-make
Paul Eggert [Mon, 13 Mar 2017 02:18:53 +0000 (19:18 -0700)]
gnulib-tool: new option --gnu-make

This is for applications like GNU Emacs that use GNU Make
features instead of Automake.
* doc/gnulib-tool.texi (Initial import): Mention --gnu-make.
* doc/gnulib.texi (Unit test modules, Build robot for gnulib):
Do not assume Automake.
* gnulib-tool (func_determine_path_separator)
(func_modules_transitive_closure, func_update_file)
(func_emit_lib_Makefile_am, func_emit_tests_Makefile_am)
(func_import): Add support for --gnu-make.

8 years agognulib-common.m4: avoid aclocal.m4 bloat
Paul Eggert [Sun, 12 Mar 2017 02:13:44 +0000 (18:13 -0800)]
gnulib-common.m4: avoid aclocal.m4 bloat

* m4/gnulib-common.m4 (gl_PROG_AR_RANLIB):
Hide AM_PROG_AR from aclocal, so that aclocal does not
install irrelevant macro definitions into aclocal.m4.

8 years agovma-iter: Let callers know about error.
Bruno Haible [Fri, 10 Mar 2017 17:08:18 +0000 (18:08 +0100)]
vma-iter: Let callers know about error.

* lib/vma-iter.h (vma_iterate): Return 'int', not 'void'.
* lib/vma-iter.c (vma_iterate): Return -1 in case of error.

8 years agoparse-datetime: remove extraneous generated source file
Pádraig Brady [Thu, 9 Mar 2017 03:44:46 +0000 (19:44 -0800)]
parse-datetime: remove extraneous generated source file

* modules/parse-datetime: Remove the tmp generated source.

8 years agoautoupdate
Karl Berry [Wed, 8 Mar 2017 14:37:57 +0000 (06:37 -0800)]
autoupdate

8 years agoautoupdate
Karl Berry [Tue, 7 Mar 2017 15:51:04 +0000 (07:51 -0800)]
autoupdate

8 years agoautoupdate
Karl Berry [Mon, 6 Mar 2017 14:38:58 +0000 (06:38 -0800)]
autoupdate

8 years agoFix value of LD for 64-bit compilers on AIX.
Bruno Haible [Sun, 5 Mar 2017 16:50:34 +0000 (17:50 +0100)]
Fix value of LD for 64-bit compilers on AIX.

* m4/lib-ld.m4 (AC_LIB_PROG_LD): For 64-bit compilers on AIX
("gcc -maix64" and "xlc -q64"), add option -b64 to $LD.

8 years agoautoupdate
Karl Berry [Sun, 5 Mar 2017 16:55:23 +0000 (08:55 -0800)]
autoupdate

8 years agodtotimespec: simplify
Paul Eggert [Sun, 5 Mar 2017 04:42:52 +0000 (20:42 -0800)]
dtotimespec: simplify

* lib/dtotimespec.c (dtotimespec): Simplify.

8 years agotest-calloc-gnu: Reenable test also for GCC 7.
Bruno Haible [Sun, 5 Mar 2017 01:17:00 +0000 (02:17 +0100)]
test-calloc-gnu: Reenable test also for GCC 7.

* tests/test-calloc-gnu.c (eight): New function.
(main): Don't skip test; use eight() instead.

8 years agotest-calloc-gnu: port to GCC7
Jim Meyering [Sat, 4 Mar 2017 22:50:41 +0000 (14:50 -0800)]
test-calloc-gnu: port to GCC7

* tests/test-calloc-gnu.c (main) [__GNUC__ >= 7]: Skip a test
that attempts to calloc more than SIZE_MAX bytes, because GCC7
and newer would detect that at compilation time.

8 years agotests: Avoid compiler warning about uses of null_ptr.
Bruno Haible [Sat, 4 Mar 2017 10:24:37 +0000 (11:24 +0100)]
tests: Avoid compiler warning about uses of null_ptr.

* tests/null-ptr.h: New file.
* tests/test-canonicalize.c: Include null-ptr.h.
(null_ptr): Remove function.
* tests/test-canonicalize-lgpl.c: Likewise.
* tests/test-memmem.c: Likewise.
* tests/test-ptsname_r.c: Likewise.
* modules/canonicalize-tests (Files): Add tests/null-ptr.h.
* modules/canonicalize-lgpl-tests: Likewise.
* modules/memmem-tests: Likewise.
* modules/ptsname_r-tests: Likewise.
Reported by Jim Meyering.

8 years agodoc: Mention Mac OS X deficiencies regarding semaphores.
Bruno Haible [Fri, 3 Mar 2017 11:47:04 +0000 (12:47 +0100)]
doc: Mention Mac OS X deficiencies regarding semaphores.

* doc/posix-functions/sem_init.texi: Mention status on Mac OS X.
* doc/posix-functions/sem_destroy.texi: Likewise.
* doc/posix-functions/sem_getvalue.texi: Likewise.

8 years agolock tests: Fix test failure on Mac OS X (regression from 2017-01-05).
Bruno Haible [Fri, 3 Mar 2017 11:13:48 +0000 (12:13 +0100)]
lock tests: Fix test failure on Mac OS X (regression from 2017-01-05).

Reported by Assaf Gordon <assafgordon@gmail.com> via
Pádraig Brady <P@draigBrady.com>.
* tests/test-lock.c: On Mac OS X, use named semaphores, not unnamed
semaphores.
(USE_NAMED_SEMAPHORE, USE_UNNAMED_SEMAPHORE): New macros.
(atomic_int_semaphore): New macro.

8 years agoperror tests: Tweak for z/OS.
Bruno Haible [Tue, 28 Feb 2017 23:57:33 +0000 (00:57 +0100)]
perror tests: Tweak for z/OS.

Reported by Daniel Richard G. <skunk@iskunk.org>.
* tests/test-perror.sh: Don't fail z/OS style perror output.

8 years agonproc: Refactor large function.
Bruno Haible [Sun, 26 Feb 2017 17:05:12 +0000 (18:05 +0100)]
nproc: Refactor large function.

* lib/nproc.c (num_processors_ignoring_omp): New function, extracted
from num_processors.
(num_processors): In this function, only deal with OMP.

8 years agonproc: adjust handling of OpenMP environment variables
Pádraig Brady [Sun, 26 Feb 2017 14:32:19 +0000 (06:32 -0800)]
nproc: adjust handling of OpenMP environment variables

Adjust to match the return value from omp_get_num_threads(), i.e.:
 - honor OMP_THREAD_LIMIT without OMP_NUM_THREADS
 - Treat 0 as an invalid value and ignore

Also remove the call to omp_get_num_threads()
added in the previous recent commit, because it's
ineffective without the omp pragmas in place.

* lib/nproc.c (parse_omp_threads): Return 0 if specified,
so that it can be ignored.
(num_processors): Honor OMP_THREAD_LIMIT even without
OMP_NUM_THREADS being set.  Also fix a typo in the environment
variable being checked, from the previous recent commit.

8 years agonproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT
Pádraig Brady [Tue, 21 Feb 2017 04:26:35 +0000 (20:26 -0800)]
nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMIT

* lib/nproc.c (parse_omp_threads): A new function refactored
from num_processors() to support parsing both of the
above environment variables.
(num_processors): Prefer using omp_get_num_threads() with [_OPENMP]
to accurately reflect the current OpenMP nesting level.
Also support the OMP_THREAD_LIMIT environment variable
to limit the max value determined from OMP_NUM_THREADS.
* modules/nproc: Depend on minmax header.
Suggested by Oliver Heimlich.

8 years agomaintainer-makefile: Fix AC_PROG_SED with autoconf cache.
Bruno Haible [Sat, 25 Feb 2017 21:54:53 +0000 (22:54 +0100)]
maintainer-makefile: Fix AC_PROG_SED with autoconf cache.

* m4/gnulib-common.m4 (AC_PROG_SED): Fix AC_CACHE_CHECK invocation.

8 years agoftoastr: port to -Wdouble-promotion
Paul Eggert [Fri, 24 Feb 2017 16:44:27 +0000 (08:44 -0800)]
ftoastr: port to -Wdouble-promotion

Work around -Wdouble-promotion false alarm in recent GCCs.
* lib/ftoastr.c (PROMOTED_FLOAT): New macro.
(ftoastr_snprintf, FTOASTR): Use it.

8 years agolock tests: Fix build failure on GNU/Hurd (regression from 2017-01-05).
Bruno Haible [Tue, 21 Feb 2017 16:07:27 +0000 (17:07 +0100)]
lock tests: Fix build failure on GNU/Hurd (regression from 2017-01-05).

Reported by Rene Saavedra <rennes@openmailbox.org> in
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25821 via Paul Eggert.
* lib/glthread/lock.h: On glibc systems without
PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP, use the fallback
implementation of rwlocks.
* lib/glthread/lock.c: Likewise.

8 years agolock tests: Fix build failure on z/OS.
Bruno Haible [Mon, 20 Feb 2017 21:34:24 +0000 (22:34 +0100)]
lock tests: Fix build failure on z/OS.

Reported by Daniel Richard G. <skunk@iskunk.org>.
* modules/lock-tests (configure.ac): Test for <semaphore.h>.
* tests/test-lock.c (USE_SEMAPHORE): Don't set if <semaphore.h> does not
exist.