Commit graph

668 commits

Author SHA1 Message Date
Joseph Myers d614a75396 Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
Joseph Myers 80a5f8b156 Declare asctime_r, ctime_r, gmtime_r, localtime_r for C2X.
C2X adds the asctime_r, ctime_r, gmtime_r and localtime_r functions.
This patch duly adds __GLIBC_USE (ISOC2X) to the conditions under
which <time.h> declares them.

Tested for x86_64.
2019-11-11 15:04:48 +00:00
Adhemerval Zanella 3537ecb49c Refactor nanosleep in terms of clock_nanosleep
The generic version is straightforward.  For Hurd, its nanosleep
implementation is moved to clock_nanosleep with adjustments from
generic unix implementation.

The generic clock_nanosleep unix version is also removed since
it calls nanosleep.

Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2019-11-06 14:47:02 -03:00
Adhemerval Zanella 79a547b162 nptl: Move nanosleep implementation to libc
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.  I also checked
the libpthread.so .gnu.version_d entries for every ABI affected and
all of them contains the required versions (including for architectures
which exports __nanosleep with a different version).

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2019-11-06 14:36:07 -03:00
Paul Eggert f8042536dc Sync time/mktime.c with gnulib
This syncs with gnulib commit 9e78024bad107fe786cc3e5e328a475921ea0873.
* time/mktime.c: Update URL in comment.
2019-10-31 13:17:00 -07:00
Zack Weinberg 2f2c76e1c8 Make second argument of gettimeofday as 'void *'
Also make the public prototype of gettimeofday declare its second
argument with type "void *" unconditionally, consistent with POSIX.

It is also consistent with POSIX.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.

Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
2019-10-30 17:11:10 -03:00
Adhemerval Zanella 5e46749c64 Use clock_gettime to implement gettimeofday.
Consolidate generic gettimeofday implementation to use clock_gettime.
Linux ports that still provide gettimeofday through vDSO are not
changed.

Remove sysdeps/unix/clock_gettime.c, which implemented clock_gettime
using gettimeofday; new OS ports must provide a real implementation of
clock_gettime.

Rename sysdeps/mach/gettimeofday.c to sysdeps/mach/clock_gettime.c and
convert into an implementation of clock_gettime.  It only supports
CLOCK_REALTIME; Mach does not appear to have any support for monotonic
clocks.  It uses __host_get_time, which provides at best microsecond
resolution.  Hurd is currently using sysdeps/posix/clock_getres.c for
clock_getres; its output for CLOCK_REALTIME is based on
sysconf (_SC_CLK_TCK), and I do not know whether that gives the
correct result.

Unlike settimeofday, there are no known uses of gettimeofday's
vestigial "get time zone" feature that are not bugs.  (The per-process
timezone support in localtime and friends is unrelated, and the
programs that set the kernel's offset between the hardware clock and
UTC do not need to read it back.)  Therefore, this feature is dummied
out.  Henceforth, if gettimeofday's "struct timezone" argument is not
NULL, it will write zeroes to both fields.  Any program that is
actually looking at this data will thus think it is running in UTC,
which is probably more correct than whatever it was doing before.

[__]gettimeofday no longer has any internal callers, so we can now
remove its internal prototype and PLT bypass aliases.  The
__gettimeofday@GLIBC_2.0 export remains, in case it is used by any
third-party code.

It also allows to simplify the arch-specific implementation on x86 and
powerpc to remove the hack to disable the internal route to non iFUNC
variant for internal symbol.

This patch also fixes a missing optimization on aarch64, powerpc, and
x86 where the code used on static build do not use the vDSO.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.

Co-authored-by: Zack Weinberg <zackw@panix.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
2019-10-30 17:11:10 -03:00
Zack Weinberg 40a36935ff Use clock_gettime to implement timespec_get.
timespec_get is the same function as clock_gettime, with an obnoxious
coating of NIH painted on it by the ISO C committee.  In addition to
the rename, it takes its arguments in a different order, it returns 0
on *failure* or a positive number on *success*, and it requires that
all of its TIME_* constants be positive.  This last means we cannot
directly reuse the existing CLOCK_* constants for it, because
those have been allocated starting with CLOCK_REALTIME = 0 on all
existing platforms.

This patch simply promotes the sysdeps/posix implementation to
universal, and removes the Linux-specific implementation, whose
apparent reason for existing was to cut out one function call's worth
of overhead.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
2019-10-30 17:11:10 -03:00
Zack Weinberg 2b5fea833b Consolidate and deprecate ftime
ftime is an obsolete variation on gettimeofday, offering only
millisecond time resolution; it was probably a system call in ooold
versions of BSD Unix.  For historic reasons, we had three
implementations of it.  These are all consolidated into time/ftime.c,
and then the function is deprecated.

For some reason, the implementation of ftime in terms of gettimeofday
was rounding rather than truncating microseconds to milliseconds.  In
all the other places where we use a higher-resolution time function to
implement a lower-resolution one, we truncate.  ftime is changed to
match, just for tidiness' sake.

Like gettimeofday, ftime tries to report the time zone, and using that
information is always a bug.  This patch dummies out the reported
timezone information; the timezone and dstflag fields of the
returned "struct timeb" will always be zero.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, and powerpc-linux-gnu.

Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
2019-10-30 17:11:10 -03:00
Adhemerval Zanella f9a7554009 Change most internal uses of time to __clock_gettime.
As for gettimeofday, time will be implemented based on clock_gettime
on all platforms and internal code should use clock_gettime
directly.  In addition to removing a layer of indirection, this will
allow us to remove the PLT-bypass gunk for gettimeofday.

The changed code always assumes __clock_gettime (CLOCK_REALTIME)
or __clock_gettime (CLOCK_REALTIME_COARSE) (for Linux case) cannot
fail, using the same rationale for gettimeofday change.  And internal
helper was added (time_now).

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, and powerpc-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
2019-10-30 17:11:10 -03:00
Adhemerval Zanella 0d56378349 Use clock_gettime to implement time.
Change the default implementation of time to call clock_gettime,
to align with new Linux ports that are expected to only implement
__NR_clock_gettime.  Arch-specific implementation that either call
the time vDSO or route to gettimeofday vDSO are not removed.

Also for Linux, CLOCK_REALTIME_COARSE is used instead of generic
CLOCK_REALTIME clockid.  This takes less CPU time and its behavior
better matches what the current glibc does.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.

Co-authored-by: Zack Weinberg <zackw@panix.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
2019-10-30 17:05:14 -03:00
Zack Weinberg c3f9aef063 Use clock_settime to implement settimeofday.
Unconditionally, on all ports, use clock_settime to implement
settimeofday.  Remove sysdeps/unix/clock_settime.c, which implemented
clock_settime by calling settimeofday; new OS ports must henceforth
provide a real implementation of clock_settime.

Hurd had a real implementation of settimeofday but not of
clock_settime; this patch converts it into an implementation of
clock_settime.  It only supports CLOCK_REALTIME and microsecond
resolution; Hurd/Mach does not appear to have any support for
finer-resolution clocks.

The vestigial "set time zone" feature of settimeofday complicates the
generic settimeofday implementation a little.  The only remaining uses
of this feature that aren't just bugs, are using it to inform the
Linux kernel of the offset between the hardware clock and UTC, on
systems where the hardware clock doesn't run in UTC (usually because
of dual-booting with Windows).  There currently isn't any other way to
do this.  However, the callers that do this call settimeofday with
_only_ the timezone argument non-NULL.  Therefore, glibc's new
behavior is: callers of settimeofday must supply one and only one of
the two arguments.  If both arguments are non-NULL, or both arguments
are NULL, the call fails and sets errno to EINVAL.

When only the timeval argument is supplied, settimeofday calls
__clock_settime(CLOCK_REALTIME), same as stime.

When only the timezone argument is supplied, settimeofday calls a new
internal function called __settimezone.  On Linux, only, this function
will pass the timezone structure to the settimeofday system call.  On
all other operating systems, and on Linux architectures that don't
define __NR_settimeofday, __settimezone is a stub that always sets
errno to ENOSYS and returns -1.

The settimeoday syscall is enabled on Linux by the flag
COMPAT_32BIT_TIME, which is an option to either 32-bits ABIs or COMPAT
builds (defined usually by 64-bit kernels that want to support 32-bit
 ABIs, such as x86).  The idea to future 64-bit time_t only ABIs
is to not provide settimeofday syscall.

The same semantics are implemented for Linux/Alpha's GLIBC_2.0 compat
symbol for settimeofday.

There are no longer any internal callers of __settimeofday, so the
internal prototype is removed.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
2019-10-30 17:05:14 -03:00
Zack Weinberg 12cbde1dae Use clock_settime to implement stime; withdraw stime.
Unconditionally, on all ports, use clock_settime to implement stime,
not settimeofday or a direct syscall.  Then convert stime into a
compatibility symbol and remove its prototype from time.h.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
2019-10-30 17:05:14 -03:00
Lukasz Majewski 4812365660 time: Introduce function to check correctness of nanoseconds value
The valid_nanoseconds () static inline function has been introduced to
check if nanoseconds value is in the correct range - greater or equal to
zero and less than 1000000000.

The explicit #include <time.h> has been added to files where it was
missing.

The __syscall_slong_t type for ns has been used to avoid issues on x32.

Tested with:
- scripts/build-many-glibcs.py
- make PARALLELMFLAGS="-j12" && make PARALLELMFLAGS="-j12" xcheck on x86_64
2019-10-27 21:49:25 +01:00
Gabriel F. T. Gomes 52151051b3 Make tst-strftime2 and tst-strftime3 depend on locale generation
Building the test cases in parallel might make tst-strftime2 and
tst-strftime3 fail.  Simply re-running the test case (or building
serially) makes the problem go away.  This patch adds the necessary
dependency to allow parallel builds in the time subdirectory.

Tested for powerpc64le.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2019-10-08 18:34:05 -03:00
Alistair Francis 69fd157a3d time: Add padding for the timespec if required
If we are running on a 32-bit system with a 64-bit time_t we need to
ensure there is padding around the tv_nsec variable. This is requried as
the timespec is #defined to the __timespec64 struct.

	* time/bits/types/struct_timespec.h: Add padding for the timespec if
	required.
2019-10-01 14:56:06 -07:00
Adhemerval Zanella b2b3b7598a Set the expects flags to clock_nanosleep
It moves the missing CFLAGS from rt/Makefile to time/Makefile missing
from 7b5af2d8f2 (Finish move of clock_* functions to libc. [BZ #24959]).

Checked on powerpc64le-linux-gnu.

	* rt/Makefile (CFLAGS-clock_nanosleep.c): Move to ...
	* time/Makefile (CFLAGS-clock_nanosleep.c): ... here.
2019-09-25 16:28:45 -07:00
Paul Eggert 5a82c74822 Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:

sed -ri '
  s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
  s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
  $(find $(git ls-files) -prune -type f \
      ! -name '*.po' \
      ! -name 'ChangeLog*' \
      ! -path COPYING ! -path COPYING.LIB \
      ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
      ! -path manual/texinfo.tex ! -path scripts/config.guess \
      ! -path scripts/config.sub ! -path scripts/install-sh \
      ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
      ! -path INSTALL ! -path  locale/programs/charmap-kw.h \
      ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
      ! '(' -name configure \
            -execdir test -f configure.ac -o -f configure.in ';' ')' \
      ! '(' -name preconfigure \
            -execdir test -f preconfigure.ac ';' ')' \
      -print)

and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:

  chmod a+x sysdeps/unix/sysv/linux/riscv/configure
  # Omit irrelevant whitespace and comment-only changes,
  # perhaps from a slightly-different Autoconf version.
  git checkout -f \
    sysdeps/csky/configure \
    sysdeps/hppa/configure \
    sysdeps/riscv/configure \
    sysdeps/unix/sysv/linux/csky/configure
  # Omit changes that caused a pre-commit check to fail like this:
  # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
  git checkout -f \
    sysdeps/powerpc/powerpc64/ppc-mcount.S \
    sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
  # Omit change that caused a pre-commit check to fail like this:
  # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
  git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 02:43:31 -07:00
Zack Weinberg 7b5af2d8f2 Finish move of clock_* functions to libc. [BZ #24959]
In glibc 2.17, the functions clock_getcpuclockid, clock_getres,
clock_gettime, clock_nanosleep, and clock_settime were moved from
librt.so to libc.so, leaving compatibility stubs behind.  Now that the
dynamic linker no longer insists on finding versioned symbols in the
same library that originally defined them, we do not need the stubs
anymore, and this means we don't need GLIBC_PRIVATE __-prefix aliases
for most of the functions anymore either.  (clock_gettime still needs
one.)  For ports added before 2.17, libc.so needs to provide two
symbol versions for each, the default at GLIBC_2.17 plus a compat
version matching what librt had.

While I'm at it, move the clock_*.c files and their tests from rt/ to
time/.
2019-09-04 14:39:38 +02:00
Zack Weinberg 1baae4aa6f
Don't use the argument to time.
It doesn't make sense to remove all the internal uses of time.
It's still a standard ISO C function, and its callers don't need
sub-second resolution and would be unnecessarily complicated if
they had to declare a struct timespec instead of just a time_t.
However, a handful of places were using the vestigial "result"
argument instead of the return value, which is slightly less
efficient and also looks strange.  Correct this.

	* misc/syslog.c (__vsyslog_internal)
	* time/getdate.c (__getdate_r)
	* time/tst_wcsftime.c (main):
	Use return value of time, not its argument.

	* string/strfry.c (strfry)
	* sysdeps/mach/sleep.c (__sleep):
	Remove unnecessary casts of NULL in calls to time.
2019-08-21 08:26:36 -04:00
Paul Eggert 20aa581958 Make mktime etc. compatible with __time64_t
Keep these functions compatible with Gnulib while adding
__time64_t support.  The basic idea is to move private API
declarations from include/time.h to time/mktime-internal.h, since
the former file cannot easily be shared with Gnulib whereas the
latter can.
Also, do some other minor cleanup while in the neighborhood.
* include/time.h: Include stdbool.h, time/mktime-internal.h.
(__mktime_internal): Move this prototype to time/mktime-internal.h,
since Gnulib needs it.
(__localtime64_r, __gmtime64_r) [__TIMESIZE == 64]:
Move these macros to time/mktime-internal.h, since Gnulib needs them.
(__mktime64, __timegm64) [__TIMESIZE != 64]: New prototypes.
(in_time_t_range): New static function.
* posix/bits/types.h (__time64_t) [__TIMESIZE == 64 && !defined __LIBC]:
Do not define as a macro in this case, so that portable code is
less tempted to use __time64_t.
* time/mktime-internal.h: Rewrite so that it does both glibc
and Gnulib work.  Include time.h if not _LIBC.
(mktime_offset_t) [!_LIBC]: Define for gnulib.
(__time64_t, __gmtime64_r, __localtime64_r, __mktime64, __timegm64)
[!_LIBC || __TIMESIZE == 64]: New macros, mostly moved here
from include/time.h.
(__gmtime_r, __localtime_r, __mktime_internal) [!_LIBC]:
New macros, taken from GNulib.
(__mktime_internal): New prototype, moved here from include/time.h.
* time/mktime.c (mktime_min, mktime_max, convert_time)
(ranged_convert, __mktime_internal, __mktime64):
* time/timegm.c (__timegm64):
Use __time64_t, not time_t.
* time/mktime.c: Stop worrying about whether time_t is floating-point.
(__mktime64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from mktime.
(mktime) [_LIBC && __TIMESIZE != 64]: New function.
* time/timegm.c [!_LIBC]: Include libc-config.h, not config.h,
for libc_hidden_def.
Include errno.h.
(__timegm64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from timegm.
(timegm) [_LIBC && __TIMESIZE != 64]: New function.

First cut at publicizing __time64_t
2019-04-30 09:02:17 -07:00
DJ Delorie 8260f23616 time/tst-strftime3.c: Disable snprintf warning.
snprintf will only truncate the output if the data its given
is corrupted, but a truncated buffer will not match the
"pristine" data's buffer, which is all we need.  So just
disable the warning via the DIAG macros.
2019-04-03 17:49:43 -04:00
DJ Delorie 0bd545ee23 Add Reiwa era tests to time/tst-strftime3.c
Also fix printf warning
2019-04-02 10:40:17 -04:00
TAMUKI Shoichi 466afec308 ja_JP locale: Add entry for the new Japanese era [BZ #22964]
The Japanese era name will be changed on May 1, 2019.  The Japanese
government made a preliminary announcement on April 1, 2019.

The glibc ja_JP locale must be updated to include the new era name for
strftime's alternative year format support.

Checked on x86_64-linux-gnu.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

ChangeLog:

	[BZ #22964]
	* localedata/locales/ja_JP (LC_TIME): Add entry for the new Japanese
	era.
	* time/tst-strftime2.c (dates): Add 2019-04-30 and 2019-05-01.
	(mkreftable): Add rules for the new Japanese era and the new dates.
2019-04-02 16:46:55 +09:00
TAMUKI Shoichi 84aea16929 time: Add tests for Minguo calendar [BZ #24293]
Co-authored-by: Rafal Luzynski <digitalfreak@lingonborough.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>

ChangeLog:

	[BZ #24293]
	* time/Makefile (LOCALES): Add zh_TW.UTF-8, cmn_TW.UTF-8,
	hak_TW.UTF-8, nan_TW.UTF-8, and lzh_TW.UTF-8.
	* time/tst-strftime2.c (locales): Likewise.
	(dates): Add 1910-04-01, 1911-12-31, 1912-01-01, 1913-04-01,
	2010-04-01, and 2011-04-01.
	(mkreftable): Add rules for the new locales and the new dates.
2019-04-02 16:42:04 +09:00
TAMUKI Shoichi 2f1d61552d time/tst-strftime2.c: Make the file easier to maintain
Express the years as full Gregorian years (e.g., 1988 instead of 88)
and months with natural numbers (1-12 rather than 0-11).

Compare actual dates rather than indexes when selecting the era name.

Declare the local variable era as a string character pointer rather
than an array of chars where the actual string is copied which might
lead to potential buffer overflows in future.

Co-authored-by: Rafal Luzynski <digitalfreak@lingonborough.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>

ChangeLog:

	* time/tst-strftime2.c (date_t): Explicitly define the type.
	(dates): Use natural month and year numbers to express a date.
	(is_before): New function to compare dates.
	(mkreftable): Minor improvements to simplify maintenance.
	(do_test): Reflect the changes in dates array.
2019-04-02 16:37:03 +09:00
DJ Delorie e0e4c321c3 Fix strptime era handling, add more strftime tests [BZ #24394]
Test the transition points between all the currently listed Japanese
era name changes. This includes testing the transition between the
first year date and the second year date. This test will help test
the upcoming Japanese era name change.

Also fixes a fencepost error where the era name isn't properly parsed
by strptime in the last (partial) year of the era.

Example: if an era change happens in Feb 1990, and again in Aug 1995,
that's 5.5 years long, but the 0.5 year wasn't accounted for.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2019-04-01 14:19:16 -04:00
Paul Eggert 78919d3886 * time/mktime.c: Update obsolete URL in comment. 2019-03-17 16:26:07 -07:00
Joseph Myers c4f50205e1 Add some spaces before '('.
This patch fixes various places where a space should have been present
before '(' in accordance with the GNU Coding Standards.  Most but not
all of the fixes in this patch are for calls to sizeof (but it's not
exhaustive regarding such calls that should be fixed).

Tested for x86_64, and with build-many-glibcs.py.

	* benchtests/bench-strcpy.c (do_test): Use space before '('.
	* benchtests/bench-string.h (cmdline_process_function): Likewise.
	* benchtests/bench-strlen.c (do_test): Likewise.
	(test_main): Likewise.
	* catgets/gencat.c (read_old): Likewise.
	* elf/cache.c (load_aux_cache): Likewise.
	* iconvdata/bug-iconv8.c (do_test): Likewise.
	* math/test-tgmath-ret.c (do_test): Likewise.
	* nis/nis_call.c (rec_dirsearch): Likewise.
	* nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise.
	* nptl/tst-audit-threads.c (do_test): Likewise.
	* nptl/tst-cancel4-common.h (set_socket_buffer): Likewise.
	* nss/nss_test1.c (init): Likewise.
	* nss/test-netdb.c (test_hosts): Likewise.
	* posix/execvpe.c (maybe_script_execute): Likewise.
	* stdio-common/tst-fmemopen4.c (do_test): Likewise.
	* stdio-common/tst-printf.c (do_test): Likewise.
	* stdio-common/vfscanf-internal.c (__vfscanf_internal): Likewise.
	* stdlib/fmtmsg.c (NKEYWORDS): Likewise.
	* stdlib/qsort.c (STACK_SIZE): Likewise.
	* stdlib/test-canon.c (do_test): Likewise.
	* stdlib/tst-swapcontext1.c (do_test): Likewise.
	* string/memcmp.c (OPSIZ): Likewise.
	* string/test-strcpy.c (do_test): Likewise.
	(do_random_tests): Likewise.
	* string/test-strlen.c (do_test): Likewise.
	(test_main): Likewise.
	* string/test-strrchr.c (do_test): Likewise.
	(do_random_tests): Likewise.
	* string/tester.c (test_memrchr): Likewise.
	(test_memchr): Likewise.
	* sysdeps/generic/memcopy.h (OPSIZ): Likewise.
	* sysdeps/generic/unwind-dw2.c (execute_stack_op): Likewise.
	* sysdeps/generic/unwind-pe.h (read_sleb128): Likewise.
	(read_encoded_value_with_base): Likewise.
	* sysdeps/hppa/dl-machine.h (elf_machine_runtime_setup): Likewise.
	* sysdeps/hppa/fpu/feupdateenv.c (__feupdateenv): Likewise.
	* sysdeps/ia64/fpu/sfp-machine.h (TI_BITS): Likewise.
	* sysdeps/mach/hurd/spawni.c (__spawni): Likewise.
	* sysdeps/posix/spawni.c (maybe_script_execute): Likewise.
	* sysdeps/powerpc/fpu/tst-setcontext-fpscr.c (query_auxv):
	Likewise.
	* sysdeps/unix/sysv/linux/aarch64/bits/procfs.h (ELF_NGREG):
	Likewise.
	* sysdeps/unix/sysv/linux/arm/bits/procfs.h (ELF_NGREG): Likewise.
	* sysdeps/unix/sysv/linux/arm/ioperm.c (init_iosys): Likewise.
	* sysdeps/unix/sysv/linux/csky/bits/procfs.h (ELF_NGREG):
	Likewise.
	* sysdeps/unix/sysv/linux/m68k/bits/procfs.h (ELF_NGREG):
	Likewise.
	* sysdeps/unix/sysv/linux/nios2/bits/procfs.h (ELF_NGREG):
	Likewise.
	* sysdeps/unix/sysv/linux/spawni.c (maybe_script_execute):
	Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/procfs.h (ELF_NGREG): Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/sigcontext.h
	(FP_XSTATE_MAGIC2_SIZE): Likewise.
	* sysdeps/x86/fpu/sfp-machine.h (TI_BITS): Likewise.
	* time/test_time.c (main): Likewise.
2019-02-27 13:55:45 +00:00
Joseph Myers a04549c194 Break more lines before not after operators.
This patch makes further coding style fixes where code was breaking
lines after an operator, contrary to the GNU Coding Standards.  As
with the previous patch, it is limited to files following a reasonable
approximation to GNU style already, and is not exhaustive; more such
issues remain to be fixed.

Tested for x86_64, and with build-many-glibcs.py.

	* dirent/dirent.h [!_DIRENT_HAVE_D_NAMLEN
	&& _DIRENT_HAVE_D_RECLEN] (_D_ALLOC_NAMLEN): Break lines before
	rather than after operators.
	* elf/cache.c (print_cache): Likewise.
	* gshadow/fgetsgent_r.c (__fgetsgent_r): Likewise.
	* htl/pt-getattr.c (__pthread_getattr_np): Likewise.
	* hurd/hurdinit.c (_hurd_setproc): Likewise.
	* hurd/hurdkill.c (_hurd_sig_post): Likewise.
	* hurd/hurdlookup.c (__file_name_lookup_under): Likewise.
	* hurd/hurdsig.c (_hurd_internal_post_signal): Likewise.
	(reauth_proc): Likewise.
	* hurd/lookup-at.c (__file_name_lookup_at): Likewise.
	(__file_name_split_at): Likewise.
	(__directory_name_split_at): Likewise.
	* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise.
	* hurd/port2fd.c (_hurd_port2fd): Likewise.
	* iconv/gconv_dl.c (do_print): Likewise.
	* inet/netinet/in.h (struct sockaddr_in): Likewise.
	* libio/wstrops.c (_IO_wstr_seekoff): Likewise.
	* locale/setlocale.c (new_composite_name): Likewise.
	* malloc/memusagestat.c (main): Likewise.
	* misc/fstab.c (fstab_convert): Likewise.
	* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt):
	Likewise.
	* nss/nss_compat/compat-grp.c (getgrent_next_nss): Likewise.
	(getgrent_next_file): Likewise.
	(internal_getgrnam_r): Likewise.
	(internal_getgrgid_r): Likewise.
	* nss/nss_compat/compat-initgroups.c (getgrent_next_nss):
	Likewise.
	(internal_getgrent_r): Likewise.
	* nss/nss_compat/compat-pwd.c (getpwent_next_nss_netgr): Likewise.
	(getpwent_next_nss): Likewise.
	(getpwent_next_file): Likewise.
	(internal_getpwnam_r): Likewise.
	(internal_getpwuid_r): Likewise.
	* nss/nss_compat/compat-spwd.c (getspent_next_nss_netgr):
	Likewise.
	(getspent_next_nss): Likewise.
	(internal_getspnam_r): Likewise.
	* pwd/fgetpwent_r.c (__fgetpwent_r): Likewise.
	* shadow/fgetspent_r.c (__fgetspent_r): Likewise.
	* string/strchr.c (STRCHR): Likewise.
	* string/strchrnul.c (STRCHRNUL): Likewise.
	* sysdeps/aarch64/fpu/fpu_control.h (_FPU_FPCR_IEEE): Likewise.
	* sysdeps/aarch64/sfp-machine.h (_FP_CHOOSENAN): Likewise.
	* sysdeps/csky/dl-machine.h (elf_machine_rela): Likewise.
	* sysdeps/generic/memcopy.h (PAGE_COPY_FWD_MAYBE): Likewise.
	* sysdeps/generic/symbol-hacks.h (__stack_chk_fail_local):
	Likewise.
	* sysdeps/gnu/netinet/ip_icmp.h (ICMP_INFOTYPE): Likewise.
	* sysdeps/gnu/updwtmp.c (TRANSFORM_UTMP_FILE_NAME): Likewise.
	* sysdeps/gnu/utmp_file.c (TRANSFORM_UTMP_FILE_NAME): Likewise.
	* sysdeps/hppa/jmpbuf-unwind.h (_JMPBUF_UNWINDS): Likewise.
	* sysdeps/mach/hurd/bits/stat.h (S_ISPARE): Likewise.
	* sysdeps/mach/hurd/dl-sysdep.c (_dl_sysdep_start): Likewise.
	(open_file): Likewise.
	* sysdeps/mach/hurd/htl/pt-mutexattr-setprotocol.c
	(pthread_mutexattr_setprotocol): Likewise.
	* sysdeps/mach/hurd/ioctl.c (__ioctl): Likewise.
	* sysdeps/mach/hurd/mmap.c (__mmap): Likewise.
	* sysdeps/mach/hurd/ptrace.c (ptrace): Likewise.
	* sysdeps/mach/hurd/spawni.c (__spawni): Likewise.
	* sysdeps/microblaze/dl-machine.h (elf_machine_type_class):
	Likewise.
	(elf_machine_rela): Likewise.
	* sysdeps/mips/mips32/sfp-machine.h (_FP_CHOOSENAN): Likewise.
	* sysdeps/mips/mips64/sfp-machine.h (_FP_CHOOSENAN): Likewise.
	* sysdeps/mips/sys/asm.h (multiple #if conditionals): Likewise.
	* sysdeps/posix/rename.c (rename): Likewise.
	* sysdeps/powerpc/novmx-sigjmp.c (__novmx__sigjmp_save): Likewise.
	* sysdeps/powerpc/sigjmp.c (__vmx__sigjmp_save): Likewise.
	* sysdeps/s390/fpu/fenv_libc.h (FPC_VALID_MASK): Likewise.
	* sysdeps/s390/utf8-utf16-z9.c (gconv_end): Likewise.
	* sysdeps/unix/grantpt.c (grantpt): Likewise.
	* sysdeps/unix/sysv/linux/a.out.h (N_TXTOFF): Likewise.
	* sysdeps/unix/sysv/linux/updwtmp.c (TRANSFORM_UTMP_FILE_NAME):
	Likewise.
	* sysdeps/unix/sysv/linux/utmp_file.c (TRANSFORM_UTMP_FILE_NAME):
	Likewise.
	* sysdeps/x86/cpu-features.c (get_common_indices): Likewise.
	* time/tzfile.c (__tzfile_compute): Likewise.
2019-02-25 13:19:19 +00:00
Joseph Myers 34a5a1460e Break some lines before not after operators.
The GNU Coding Standards specify that line breaks in expressions
should go before an operator, not after one.  This patch fixes various
code to do this.  It only changes code that appears to be mostly
following GNU style anyway, not files and directories with
substantially different formatting.  It is not exhaustive even for
files using GNU style (for example, changes to sysdeps files are
deferred for subsequent cleanups).  Some files changed are shared with
gnulib, but most are specific to glibc.  Changes were made manually,
with places to change found by grep (so some cases, e.g. where the
operator was followed by a comment at end of line, are particularly
liable to have been missed by grep, but I did include cases where the
operator was followed by backslash-newline).

This patch generally does not attempt to address other coding style
issues in the expressions changed (for example, missing spaces before
'(', or lack of parentheses to ensure indentation of continuation
lines properly reflects operator precedence).

Tested for x86_64, and with build-many-glibcs.py.

	* benchtests/bench-memmem.c (simple_memmem): Break lines before
	rather than after operators.
	* benchtests/bench-skeleton.c (TIMESPEC_AFTER): Likewise.
	* crypt/md5.c (md5_finish_ctx): Likewise.
	* crypt/sha256.c (__sha256_finish_ctx): Likewise.
	* crypt/sha512.c (__sha512_finish_ctx): Likewise.
	* elf/cache.c (load_aux_cache): Likewise.
	* elf/dl-load.c (open_verify): Likewise.
	* elf/get-dynamic-info.h (elf_get_dynamic_info): Likewise.
	* elf/readelflib.c (process_elf_file): Likewise.
	* elf/rtld.c (dl_main): Likewise.
	* elf/sprof.c (generate_call_graph): Likewise.
	* hurd/ctty-input.c (_hurd_ctty_input): Likewise.
	* hurd/ctty-output.c (_hurd_ctty_output): Likewise.
	* hurd/dtable.c (reauth_dtable): Likewise.
	* hurd/getdport.c (__getdport): Likewise.
	* hurd/hurd/signal.h (_hurd_interrupted_rpc_timeout): Likewise.
	* hurd/hurd/sigpreempt.h (HURD_PREEMPT_SIGNAL_P): Likewise.
	* hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise):
	Likewise.
	* hurd/hurdioctl.c (fioctl): Likewise.
	* hurd/hurdselect.c (_hurd_select): Likewise.
	* hurd/hurdsig.c (_hurdsig_abort_rpcs): Likewise.
	(STOPSIGS): Likewise.
	* hurd/hurdstartup.c (_hurd_startup): Likewise.
	* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Likewise.
	* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise.
	* hurd/msgportdemux.c (msgport_server): Likewise.
	* hurd/setauth.c (_hurd_setauth): Likewise.
	* include/features.h (__GLIBC_USE_DEPRECATED_SCANF): Likewise.
	* libio/libioP.h [IO_DEBUG] (CHECK_FILE): Likewise.
	* locale/programs/ld-ctype.c (set_class_defaults): Likewise.
	* localedata/tests-mbwc/tst_swscanf.c (tst_swscanf): Likewise.
	* login/tst-utmp.c (do_check): Likewise.
	(simulate_login): Likewise.
	* mach/lowlevellock.h (lll_lock): Likewise.
	(lll_trylock): Likewise.
	* math/test-fenv.c (ALL_EXC): Likewise.
	* math/test-fenvinline.c (ALL_EXC): Likewise.
	* misc/sys/cdefs.h (__attribute_deprecated_msg__): Likewise.
	* nis/nis_call.c (__do_niscall3): Likewise.
	* nis/nis_callback.c (cb_prog_1): Likewise.
	* nis/nis_defaults.c (searchaccess): Likewise.
	* nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise.
	* nis/nis_ismember.c (internal_ismember): Likewise.
	* nis/nis_local_names.c (nis_local_principal): Likewise.
	* nis/nss_nis/nis-rpc.c (_nss_nis_getrpcbyname_r): Likewise.
	* nis/nss_nisplus/nisplus-netgrp.c (_nss_nisplus_getnetgrent_r):
	Likewise.
	* nis/ypclnt.c (yp_match): Likewise.
	(yp_first): Likewise.
	(yp_next): Likewise.
	(yp_master): Likewise.
	(yp_order): Likewise.
	* nscd/hstcache.c (cache_addhst): Likewise.
	* nscd/initgrcache.c (addinitgroupsX): Likewise.
	* nss/nss_compat/compat-pwd.c (copy_pwd_changes): Likewise.
	(internal_getpwuid_r): Likewise.
	* nss/nss_compat/compat-spwd.c (copy_spwd_changes): Likewise.
	* posix/glob.h (__GLOB_FLAGS): Likewise.
	* posix/regcomp.c (peek_token): Likewise.
	(peek_token_bracket): Likewise.
	(parse_expression): Likewise.
	* posix/regexec.c (sift_states_iter_mb): Likewise.
	(check_node_accept_bytes): Likewise.
	* posix/tst-spawn3.c (do_test): Likewise.
	* posix/wordexp-test.c (testit): Likewise.
	* posix/wordexp.c (parse_tilde): Likewise.
	(exec_comm): Likewise.
	* posix/wordexp.h (__WRDE_FLAGS): Likewise.
	* resource/vtimes.c (TIMEVAL_TO_VTIMES): Likewise.
	* setjmp/sigjmp.c (__sigjmp_save): Likewise.
	* stdio-common/printf_fp.c (__printf_fp_l): Likewise.
	* stdio-common/tst-fileno.c (do_test): Likewise.
	* stdio-common/vfprintf-internal.c (vfprintf): Likewise.
	* stdlib/strfmon_l.c (__vstrfmon_l_internal): Likewise.
	* stdlib/strtod_l.c (round_and_return): Likewise.
	(____STRTOF_INTERNAL): Likewise.
	* stdlib/tst-strfrom.h (TEST_STRFROM): Likewise.
	* string/strcspn.c (STRCSPN): Likewise.
	* string/test-memmem.c (simple_memmem): Likewise.
	* termios/tcsetattr.c (tcsetattr): Likewise.
	* time/alt_digit.c (_nl_parse_alt_digit): Likewise.
	* time/asctime.c (asctime_internal): Likewise.
	* time/strptime_l.c (__strptime_internal): Likewise.
	* time/sys/time.h (timercmp): Likewise.
	* time/tzfile.c (__tzfile_compute): Likewise.
2019-02-22 01:32:36 +00:00
TAMUKI Shoichi fb25b1356a Fix a few whitespace arrangement inconsistencies in time/strftime_l.c
Having checked the arrangement of whitespace in time/strftime_l.c
using "unexpand" and "unexpand -a" command, three inconsistencies are
detected.  So fix them for consistency.

ChangeLog:

	* time/strftime_l.c: Fix a few whitespace arrangement inconsistencies.
2019-02-11 12:13:55 +09:00
TAMUKI Shoichi 144a794e0a tst-strftime2: Use array_length macros instead of magic numbers
ChangeLog:

	* time/tst-strftime2.c: Use array_length macros instead of magic
	numbers.
2019-02-08 22:03:14 +09:00
Florian Weimer 221baae001 time: Avoid alignment gaps in __tzfile_read
By ordering the suballocations by decreasing alignment, alignment
gaps can be avoided.

Also use __glibc_unlikely for reading the transitions and type
indexes.  In the 8-byte case, two reads are now needed because the
transitions and type indexes are no longer adjacent.  The separate
call to __fread_unlocked does not matter from a performance point of
view because __tzfile_read is only invoked rarely.
2019-02-04 10:01:29 +01:00
Florian Weimer b8c7238167 time: Use struct alloc_buffer in __tzfile_read
The computation of tzspec_len is moved in front of the total_size
computation, so that the allocation size computation and the
suballocations are next to each other.  Also add an assert that
tzspec_len is positive when it is actually used later.
2019-02-03 22:14:33 +01:00
Florian Weimer 77c7d55ece time: Use int, not long int, for internal GMT offsets
The GMT offset can be outside the range of a 16-bit int type, which
is presumably the reason why long int was used in struct tm.  We
cannot change struct tm, but we can change the internal type for
the offset.
2019-02-03 09:55:41 +01:00
TAMUKI Shoichi 32f600a272 strftime: Pass the additional flags from "%EY" to "%Ey" [BZ #24096]
The full representation of the alternative calendar year (%EY)
typically includes an internal use of "%Ey".  As a GNU extension,
apply any flags on "%EY" (e.g. "%_EY", "%-EY") to the internal "%Ey",
allowing users of "%EY" to control how the year is padded.

Reviewed-by: Rafal Luzynski <digitalfreak@lingonborough.com>
Reviewed-by: Zack Weinberg <zackw@panix.com>

ChangeLog:

	[BZ #24096]
	* manual/time.texi (strftime): Document "%EC" and "%EY".
	* time/Makefile (tests): Add tst-strftime2.
	(LOCALES): Add ja_JP.UTF-8, lo_LA.UTF-8, and th_TH.UTF-8.
	* time/strftime_l.c (__strftime_internal): Add argument yr_spec to
	override padding for "%Ey".
	If an optional flag ('_' or '-') is specified to "%EY", interpret the
	"%Ey" in the subformat as if decorated with that flag.
	* time/tst-strftime2.c: New file.
2019-01-24 23:04:12 +09:00
TAMUKI Shoichi b22eed3710 strftime: Set the default width of "%Ey" to 2 [BZ #23758]
In Japanese locales, strftime's alternative year format (%Ey) produces
a year numbered within a time period called an _era_.  A new era
typically begins when a new emperor is enthroned.  The result of "%Ey"
is therefore usually a one- or two-digit number.

Many programs that display Japanese era dates assume that the era year
is two digits wide.  To improve how these programs display dates
during the first nine years of a new era, change "%Ey" to pad one-
digit numbers on the left with a zero.  This change applies to all
locales.  It is expected to be harmless for other locales that use the
alternative year format (e.g. lo_LA and th_TH, in which "%Ey" produces
the year of the Buddhist calendar) as those calendars' year numbers
are already more than two digits wide, and this is not expected to
change.

This change needs to be in place before 2019-05-01 CE, as a new era is
scheduled to begin on that date.

Reviewed-by: Zack Weinberg <zackw@panix.com>
Reviewed-by: Rafal Luzynski <digitalfreak@lingonborough.com>

ChangeLog:

	[BZ #23758]
	* manual/time.texi (strftime): Document "%Ey".
	* time/strftime_l.c (__strftime_internal): Set the default width
	padding with zero of "%Ey" to 2.
2019-01-24 23:00:53 +09:00
Dmitry V. Levin a1b02ae763 Fix a few typos in comments
Apply the following spelling fixes:
$ git grep -F -l 'relevent' |
  xargs sed -i 's/relevent/relevant/g'
$ git grep -F -l 'checked fot' |
  xargs sed -i 's/checked fot/checked for/g'
$ git grep -F -l "could't" |
  xargs sed -i "s/could't/couldn't/g"
$ git grep -F -l 'wheter' | grep -Fv ChangeLog.old |
  xargs sed -i 's/wheter/whether/g'
$ git grep -F -l 'neccessary' | grep -Fv ChangeLog.old |
  xargs sed -i 's/neccessary/necessary/g'
$ git grep -F -l 'ouput' |
  xargs sed -i 's/ouput/output/g'
$ git grep -F -w -l 'iput' |
  xargs sed -i 's/iput/input/g'

This is inspired by a gnulib bug report at
https://lists.gnu.org/archive/html/bug-gnulib/2019-01/msg00081.html

* argp/argp-help.c: Fix typo in comment.
* misc/sys/cdefs.h: Likewise.
* posix/regexec.c (sift_states_iter_mb): Likewise.
* socket/sockatmark.c: Likewise.
* socket/sys/socket.h: Likewise.
* sysdeps/ia64/fpu/libm_sincos_large.S: Likewise.
* sysdeps/ia64/fpu/libm_sincosl.S: Likewise.
* sysdeps/ia64/fpu/s_cosl.S: Likewise.
* sysdeps/ieee754/dbl-64/k_rem_pio2.c: Likewise.
* sysdeps/unix/sockatmark.c: Likewise.
* time/strptime_l.c: Likewise.
2019-01-12 13:44:51 +00:00
TAMUKI Shoichi 5cbbf01ebe strftime: Consequently use the "L_" macro with character literals
ChangeLog:

	* time/strftime_l.c (__strftime_internal): Use "L_" macros, also add a
	missing space after the cast of "_NL_CURRENT".
2019-01-11 23:54:37 +01:00
Joseph Myers 04277e02d7 Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2019-01-01 00:11:28 +00:00
Albert ARIBAUD (3ADEV) ac253355ba Y2038: make __difftime compatible with 64-bit time
Provide a 64-bit-time version of __difftime (but do not assume
__time64_t is a signed int so that Gnulib can reuse the code)
and make the 32-bit version a wrapper of it.

Current difftime expects two time_t arguments and returns a
double. To preserve source-code compatibility, its 64-bit-time
equivalent expects two __time64_t arguments but still returns
a double.

This patch was tested by running 'make check' on branch
master then applying this patch and its two predecessors and
running 'make check' again, and checking that both 'make check'
yield identical results. This was done on x86_64-linux-gnu and
i686-linux-gnu.

This patch was also functionally tested with an ad hoc userland
C program which checks the result of difftime for various pairs
of 32-bit and, for 64-bit builds, of 64-bit time_t values too.
The program was built and run against a glibc with and without
the patch, and the results compared to ensure the patch does
not change the behavior of difftime.

* include/time.h (__difftime64): Add.
* time/difftime.c (subtract): convert to 64-bit time.
* time/difftime.c (__difftime64): Add.
* time/difftime.c (__difftime): Wrap around __difftime64.
2018-12-20 22:16:55 +01:00
Albert ARIBAUD (3ADEV) c4c2836ada Y2038: add function __ctime64_r
Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu.

	* include/time.h
	(__ctime64_r): Add.
	* time/ctime_r.c
	(__ctime64_r): Add.
	[__TIMESIZE != 64] (__ctime_r): Turn into a wrapper.
2018-12-18 23:13:55 +01:00
Albert ARIBAUD (3ADEV) 7755e50411 Y2038: add function __ctime64
Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu.

	* include/time.h
	(__ctime64): Add.
	* time/gmtime.c
	(__ctime64): Add.
	[__TIMESIZE != 64] (ctime): Turn into a wrapper.
2018-12-18 23:13:24 +01:00
Albert ARIBAUD (3ADEV) a1d346ce0d Y2038: add function __gmtime64_r
Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu.

	* include/time.h
	(__gmtime64_r): Add.
	* time/gmtime.c
	(__gmtime64_r): Add.
	[__TIMESIZE != 64] (__gmtime): Turn into a wrapper.
2018-12-18 23:12:30 +01:00
Albert ARIBAUD (3ADEV) 131db8b0c8 Y2038: add function __gmtime64
Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu.

	* include/time.h
	(__gmtime64): Add.
	* time/gmtime.c
	(__gmtime64): Add.
	[__TIMESIZE != 64] (__gmtime): Turn into a wrapper.
2018-12-18 23:11:40 +01:00
Albert ARIBAUD (3ADEV) 64c2277d2e Y2038: add function __localtime64_r
Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu.

	* include/time.h
	(__localtime64_r): Add.
	* time/localtime.c
	(__localtime64_r): Add.
	[__TIMESIZE != 64] (__localtime_r): Turn into a wrapper.
2018-12-18 23:11:08 +01:00
Albert ARIBAUD (3ADEV) 6e15f3e26b Y2038: add function __localtime64
Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu.

	* include/time.h
	(__localtime64): Add.
	* manual/maint.texi: Document Y2038 symbol handling.
	* time/localtime.c
	(__localtime64): Add.
	[__TIMERSIZE != 64] (__localtime): Turn into a wrapper.
2018-12-17 22:56:15 +01:00
Albert ARIBAUD (3ADEV) 72b8692d7e Y2038: make __tz_convert compatible with 64-bit-time
Now that __time64_t exists, we can switch internal function
__tz_convert from 32-bit to 64-bit time. This involves switching
some other internal functions as well, namely __tz_compute and
__offtime.

Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu.

	* include/time.h
	(__tz_compute): Replace time_t with __time64_t.
	(__tz_convert): Replace time_t* with __time64_t.
	(__offtime): Replace time_t* with __time64_t.
	* time/gmtime.c
	(__gmtime_r): Adjust call to __tz_convert.
	(gmtime): Likewise.
	* time/localtime.c
	(__localtime_r): Likewise.
	(localtime): Likewise.
	* time/offtime.c: Replace time_t with __time64_t.
	* time/tzset.c: Likewise.
2018-12-05 21:01:22 +01:00
Paul Eggert 5d8af1566b mktime: DEBUG_MKTIME cleanup
The DEBUG_MKTIME code no longer works in glibc or in Gnulib.
And it’s no longer needed now that glibc and Gnulib both have
their own testing mechanisms for mktime.
* time/mktime.c (DEBUG_MKTIME): Remove.  All uses removed.
2018-11-15 22:59:33 +01:00
Paul Eggert 86aece3bfb mktime: fix non-EOVERFLOW errno handling
[BZ#23789]
mktime was not properly reporting failures when the underlying
localtime_r fails with errno != EOVERFLOW; it incorrectly treated
them like EOVERFLOW failures, and set errno to EOVERFLOW.
The problem could happen on non-glibc platforms, with Gnulib.
* time/mktime.c (guess_time_tm): Remove, replacing with ...
(tm_diff): ... this simpler function, which does not change errno.
All callers changed to deal with errno themselves.
(ranged_convert, __mktime_internal): Return failure immediately if
the underlying function reports any failure other than EOVERFLOW.
(__mktime_internal): Set errno to EOVERFLOW if the spring-forward
gap code fails.
2018-11-15 22:59:33 +01:00
Paul Eggert f6b3331bba mktime: fix bug with Y2038 DST transition
[BZ#23789]
* time/mktime.c (ranged_convert): On 32-bit platforms, don’t
mishandle a DST transition that jumps over the Y2038 boundary.
No such DST transitions are known so this is only a theoretical
bug, but we might as well do things right.
2018-11-15 22:59:33 +01:00
Paul Eggert efbdddc381 mktime: make more room for overflow
[BZ#23789]
* time/mktime.c (long_int): Now 4⨯ int, not just 3⨯.
This is so that we can add tm_diff results to a previous guess,
which will be useful in a later patch.
2018-11-15 22:59:33 +01:00
Paul Eggert 6c90d759f6 mktime: simplify offset guess
[BZ#23789]
* time/mktime.c (__mktime_internal): Omit excess precision.
2018-11-15 22:59:33 +01:00
Paul Eggert 32c12f3f7a mktime: new test for mktime failure
[BZ#23789]
Based on a test suggested by Albert Aribaud in:
https://www.sourceware.org/ml/libc-alpha/2018-10/msg00662.html
* time/Makefile (tests): Add bug-mktime4.
* time/bug-mktime4.c: New file.
2018-11-15 22:59:33 +01:00
Paul Eggert de20b81a03 mktime: fix EOVERFLOW bug
[BZ#23789]
* time/mktime.c [!_LIBC && !DEBUG_MKTIME]:
Include libc-config.h, not config.h, for __set_errno.
(guess_time_tm, __mktime_internal): Set errno to EOVERFLOW on overflow.
2018-11-15 22:59:33 +01:00
Albert ARIBAUD (3ADEV) d51f99ce80 Y2038: Add 64-bit time for all architectures
glibc support for 64-bit time_t on 32-bit architectures
will involve:

- Using 64-bit times inside glibc, with conversions
  to and from 32-bit times taking place as necessary
  for interfaces using such times.

- Adding 64-bit-time support in the glibc public API.
  This support should be dynamic, i.e. glibc should
  provide both 32-bit and 64-bit implementations and
   let user code choose at compile time whether to use
   the 32-bit or 64-bit interfaces.

This requires a glibc-internal name for a type for times
that are always 64-bit.

Based on __TIMESIZE, a new macro is defined, __TIME64_T_TYPE,
 which is always the right __*_T_TYPE to hold a 64-bit-time.
__TIME64_T_TYPE equals __TIME_T_TYPE if __TIMESIZE equals 64
and equals __SQUAD_T_TYPE otherwise.

__time64_t can then replace uses of internal_time_t.

This patch was tested by running 'make check' on branch
master then applying this patch and its predecessor and
running 'make check' again, and checking that both 'make
check' yield identical results. This was done on
x86_64-linux-gnu and i686-linux-gnu.

	* bits/time64.h: New file.
	* include/time.h: Replace internal_time_t with __time64_t.
	* posix/bits/types (__time64_t): Add.
	* stdlib/Makefile: Add bits/time64.h to includes.
	* time/tzfile.c: Replace internal_time_t with __time64_t.
2018-10-24 22:09:34 +02:00
Florian Weimer f1034472e2 time/tst-mktime2: Improve test error reporting 2018-10-23 11:25:05 +02:00
Andreas Schwab ce5a7de6cd Don't reduce test timeout to less than default
This removes all overrides of TIMEOUT that are less than or equal to the
default timeout.
2018-10-17 09:34:13 +02:00
Paul Eggert 5a58064311 mktime fix for Gnulib + coreutils
[BZ#23745]
This fix affects only Gnulib.  Problem discovered when
mktime.c was used as part of Gnulib in bleeding-edge Coreutils.
* time/mktime.c:
(my_tzset) [!_LIBC && !NEED_MKTIME_WORKING && !NEED_MKTIME_WINDOWS]:
Do not define since it is not used.  Defining an unused static
function prompts a warning from GCC when Coreutils is configured
with --enable-gcc-warnings.
2018-10-08 11:28:25 -07:00
Paul Eggert e1080e7e5f Fix mktime localtime offset confusion
[BZ #23603]
* include/time.h (__mktime_internal): The localtime offset is now
of type long int instead of time_t.  This is the longstanding type
in glibc, and it is more than enough to represent difference
between localtime and gmtime even if it is 32 bits and time_t is
64.  Changing it now will let us avoid an unnecessary change when
time_t is widened to 64 bits on 32-bit platforms.
* time/mktime-internal.h (mktime_offset_t): Now long int.
2018-09-19 17:09:08 -07:00
Paul Eggert 8e6fd2bdb2 Merge mktime, timegm from upstream Gnulib
[BZ #23603][BZ #16346]
This fixes some obscure problems with integer overflow.
Although it looks scary, it is almost all a byte-for-byte copy
from Gnulib, and the Gnulib code has been tested reasonably well.
* include/intprops.h: New file, copied from Gnulib.
* include/verify.h, time/mktime-internal.h:
New tiny files, simplified from Gnulib.
* time/mktime.c: Copy from Gnulib.  This has the following changes:
Do not include config.h if DEBUG_MKTIME is nonzero.
Include stdbool.h, intprops.h, verify.h.
Include string.h only if needed.
Include stdlib.h on MS-Windows.
Include mktime-internal.h.
(DEBUG_MKTIME): Default to 0, and simplify later uses.
(NEED_MKTIME_INTERNAL, NEED_MKTIME_WINDOWS)
(NEED_MKTIME_WORKING): Give default values to pacify -Wundef,
which glibc uses.  Default NEED_MKTIME_WORKING to DEBUG_MKTIME, to
simplify later conditionals; default the others to zero.  Use
these conditionals to express only the code needed on the current
platform.  In uses of these conditionals, explicitly spell out how
_LIBC affects things, so it’s easier to review from a glibc
viewpoint.
(WRAPV): Remove; no longer needed now that we have
systematic overflow checking.
(my_tzset, __tzset) [!_LIBC]: New function and macro, to better
compartmentalize tzset issues.  Move system-dependent tzsettish
code here from mktime.
(verify): Remove; now done by verify.h.  All uses changed.
(long_int): Use a more-conservative definition, to avoid
integer overflow.
(SHR): Remove, replacing with ...
(shr): New function, which means we needn’t worry about side
effects in args, and conversion analysis is simpler.
(TYPE_IS_INTEGER, TYPE_TWOS_COMPLEMENT, TYPE_SIGNED, TYPE_MINIMUM)
(TYPE_MAXIMUM, TIME_T_MIN, TIME_T_MAX, TIME_T_MIDPOINT)
(time_t_avg, time_t_add_ok): Remove.
(mktime_min, mktime_max): New constants.
(leapyear, isdst_differ): Use bool for booleans.
(ydhms_diff, guess_time_tm, ranged_convert, __mktime_internal):
Use long_int, not time_t, for mktime differences.
(long_int_avg): New function, replacing time_t_avg.
INT_ADD_WRAPV replaces time_t_add_ok.
(guess_time_tm): 6th arg is now long_int, not time_t const *.
All uses changed.
(convert_time): New function.
(ranged_convert): Use it.
(__mktime_internal): Last arg now points to mktime_offset_t, not
time_t.  All uses changed.  This is a no-op on glibc, where
mktime_offset_t is always time_t.  Use int, not time_t, for UTC
offset guess.  Directly check for integer overflow instead of
using a heuristic that works only 99.9...% of the time.
Access *OFFSET only once, to avoid an unlikely race if the
compiler delays a load and if this cascades into a signed integer
overflow.
(mktime): Move tzsettish code to my_tzset, and move
localtime_offset to within mktime so that it doesn’t
need a separate ifdef.
(main) [DEBUG_MKTIME]: Speed up by using localtime_r
instead of localtime.
* time/timegm.c: Copy from Gnulib.  This has the following changes:
Include mktime-internal.h.
[!_LIBC]: Include config.h and time.h.  Do not include
timegm.h or time_r.h.  Make __mktime_internal a macro,
and include mktime-internal.h to get its declaration.
(timegm): Temporary is now mktime_offset_t, not time_t.
This affects only Gnulib.
2018-09-19 17:09:08 -07:00
Paul Eggert dab9c3488e Simplify tzfile fstat failure code
[BZ #21716]
* time/tzfile.c (__tzfile_read): Simplify slightly.
2018-09-18 15:09:01 -07:00
Paul Eggert e4e4fde51a Fix tzfile low-memory assertion failure
[BZ #21716]
* time/tzfile.c (__tzfile_read): Check for memory exhaustion
when registering time zone abbreviations.
2018-09-18 15:09:01 -07:00
Florian Weimer c1c2848b57 Use _STRUCT_TIMESPEC as guard in <bits/types/struct_timespec.h> [BZ #23349]
After commit d76d370355 ("Fix missing
timespec definition for sys/stat.h (BZ #21371)") in combination with
kernel UAPI changes, GCC sanitizer builds start to fail due to a
conflicting definition of struct timespec in <linux/time.h>.  Use
_STRUCT_TIMESPEC as the header file inclusion guard, which is already
checked in the kernel header, to support including <linux/time.h> and
<sys/stat.h> in the same translation unit.
2018-06-28 13:12:16 +02:00
Joseph Myers 78274dc8ce Fix year 2039 bug for localtime with 64-bit time_t (bug 22639).
Bug 22639 reports localtime failing to handle time offset transitions
correctly in 2039 and later on platforms with 64-bit time_t.

The problem is the use of SECSPERDAY (constant 86400) in calculations
such as

    t = ((year - 1970) * 365
	 + /* Compute the number of leapdays between 1970 and YEAR
	      (exclusive).  There is a leapday every 4th year ...  */
	 + ((year - 1) / 4 - 1970 / 4)
	 /* ... except every 100th year ... */
	 - ((year - 1) / 100 - 1970 / 100)
	 /* ... but still every 400th year.  */
	 + ((year - 1) / 400 - 1970 / 400)) * SECSPERDAY;

where t is of type time_t and year is of type int.  Before my commit
92bd70fb85 (an update from tzcode,
included in 2.26 and later releases), SECSPERDAY was obtained from a
file imported from tzcode, where the value included a cast to
int_fast32_t.  On 64-bit platforms, glibc defines int_fast32_t to be
long int, so 64-bit, but my patch resulted in it changing to int.
(The bug would probably have existed even before my patch for x32,
which has 64-bit time_t but 32-bit int_fast32_t, but I haven't
verified that.)

This patch fixes the problem by including a cast to time_t in the
definition of SECSPERDAY.  (64-bit time support for 32-bit systems
should move such code that isn't a public interface to using the
internal 64-bit version of time_t throughout.)

Tested for x86_64 and x86.

	[BZ #22639]
	* time/tzset.c (SECSPERDAY): Cast to time_t.
	* time/tst-y2039.c: New file.
	* time/Makefile (tests): Add tst-y2039.
2018-05-18 11:57:15 +00:00
Florian Weimer fc79706a32 time: Use 64-bit time values for time zone parsing 2018-05-11 16:30:30 +02:00
Joseph Myers 30ac923dbe Fix -Os getc_unlocked linknamespace, localplt issues (bug 15105, bug 19463).
Continuing the fixes for linknamespace and localplt test failures with
-Os that arise from functions not being inlined in that case, this
patch fixes such failures for getc_unlocked.

__getc_unlocked already exists; this patch makes it explicitly hidden,
calls it where needed for namespace reasons, adds an inline function
for it when inline functions are used and adds libc_hidden_proto /
libc_hidden_weak for getc_unlocked.

Tested for x86_64 (both without -Os to make sure that case continues
to work, and with -Os to make sure all the relevant linknamespace and
localplt test failures are resolved).  Because of other such failures
that remain after this patch, neither of the bugs can yet be closed.

	[BZ #15105]
	[BZ #19463]
	* libio/getc_u.c (getc_unlocked): Use libc_hidden_weak.
	* include/stdio.h [!_ISOMAC] (__getc_unlocked): Use
	attribute_hidden, and define inline if [__USE_EXTERN_INLINES].
	[!_ISOMAC] (getc_unlocked): Use libc_hidden_proto.
	* misc/getttyent.c (__getttyent): Call __getc_unlocked instead of
	getc_unlocked.
	* time/tzfile.c (__tzfile_read): Likewise.
2018-02-21 18:01:11 +00:00
Joseph Myers ec481ad81b Fix -Os ferror_unlocked linknamespace, localplt issues (bug 15105, bug 19463).
Continuing the fixes for linknamespace and localplt test failures with
-Os that arise from functions not being inlined in that case, this
patch fixes such failures for ferror_unlocked.

The usual approach is followed of adding __ferror_unlocked (inlined
when ferror_unlocked is), making calls use it when required for
namespace reasons (only one such call), and using libc_hidden_proto /
libc_hidden_weak for the ferror_unlocked weak alias when only localplt
but not namespace issues are involved.

Tested for x86_64 (both without -Os to make sure that case continues
to work, and with -Os to make sure all the relevant linknamespace and
localplt test failures are resolved).  Because of other such failures
that remain after this patch, neither of the bugs can yet be closed.

	[BZ #15105]
	[BZ #19463]
	* libio/ferror_u.c (ferror_unlocked): Rename to __ferror_unlocked
	and define as weak alias of __ferror_unlocked.  Use
	libc_hidden_weak.
	* include/stdio.h [!_ISOMAC] (ferror_unlocked): Use
	libc_hidden_proto.
	[!_ISOMAC] (__ferror_unlocked) New declaration, and inline
	function if [__USE_EXTERN_INLINES].
	* time/getdate.c (__getdate_r): Call __ferror_unlocked instead of
	ferror_unlocked.
2018-02-19 17:32:34 +00:00
Joseph Myers 7fc03cf320 Fix -Os feof_unlocked linknamespace, localplt issues (bug 15105, bug 19463).
Continuing the fixes for linknamespace and localplt test failures with
-Os that arise from functions not being inlined in that case, this
patch fixes such failures for feof_unlocked.

The usual approach is followed of adding __feof_unlocked (inlined when
feof_unlocked is), making calls use it when required for namespace
reasons, and using libc_hidden_proto / libc_hidden_weak for the
feof_unlocked weak alias when only localplt but not namespace issues
are involved.  In the case of getaddrinfo.c, use of __feof_unlocked
needs to be conditional since that code is also used in nscd (where
__feof_unlocked is not available).

Tested for x86_64 (both without -Os to make sure that case continues
to work, and with -Os to make sure all the relevant linknamespace and
localplt test failures are resolved).  Because of other such failures
that remain after this patch, neither of the bugs can yet be closed.

	[BZ #15105]
	[BZ #19463]
	* libio/feof_u.c (feof_unlocked): Rename to __feof_unlocked and
	define as weak alias of __feof_unlocked.  Use libc_hidden_weak.
	* include/stdio.h (feof_unlocked): Use libc_hidden_proto.
	(__feof_unlocked): New declaration, and inline function if
	[__USE_EXTERN_INLINES].
	* iconv/gconv_conf.c (read_conf_file): Call __feof_unlocked
	instead of feof_unlocked.
	* intl/localealias.c [_LIBC] (FEOF): Likewise.
	* nss/nsswitch.c (nss_parse_file): Likewise.
	* sysdeps/unix/sysv/linux/readonly-area.c (__readonly_area):
	Likewise.
	* time/getdate.c (__getdate_r): Likewise.
	* sysdeps/posix/getaddrinfo.c [IS_IN (libc)] (feof_unlocked):
	Define as macro to call __feof_unlocked.
2018-02-15 20:57:15 +00:00
Sean McKean 09e56b9e18 time: Reference CLOCKS_PER_SEC in clock comment [BZ #22735] 2018-02-02 11:59:31 +01:00
Rafal Luzynski f7bdf30d15 ru_RU, ru_UA: Add alternative month names (bug 10871).
[BZ #10871]
	* localedata/locales/ru_RU (mon): Rename to...
	(alt_mon): This.
	(abmon): Rename to...
	(ab_alt_mon): This.
	(mon): Import from CLDR (genitive case).
	(abmon): Copy from the old content except the 5th month which is
	now in the genitive case, even when abbreviated.
	* localedata/locales/ru_UA: Likewise.
	* time/tst-strptime.c (day_tests): Add an actual example of
	a difference between %b and %Ob in Russian.
2018-01-29 13:14:45 +01:00
Rafal Luzynski 2aa8009d21 pl_PL: Add alternative month names (bug 10871).
[BZ #10871]
	* localedata/locales/pl_PL: Alternative month names added,
	primary month names are genitive now.
	* time/tst-strptime.c (day_tests): Actually use a genitive case
	of a month name in Polish language.
2018-01-22 11:27:09 +01:00
Rafal Luzynski 761a585ce9 Abbreviated alternative month names (%Ob) also added (bug 10871).
All the previous changes also repeated to support abbreviated
alternative month names.  In most languages which have declension and
need nominative/genitive month names the abbreviated forms for both
cases are the same.  An example where they do differ is May in Russian:
this name is too short to be abbreviated so even the abbreviated form
features the declension suffixes.

	[BZ #10871]
	* locale/C-time.c (_nl_C_LC_TIME): Add abbreviated alternative month
	names, define them as the same as abbreviated month names explicitly.
	* locale/categories.def (LC_TIME): Add ab_alt_mon and wide-ab_alt_mon.
	* locale/langinfo.h: (_NL_ABALTMON_1, _NL_ABALTMON_2, _NL_ABALTMON_3,
	_NL_ABALTMON_4, _NL_ABALTMON_5, _NL_ABALTMON_6, _NL_ABALTMON_7,
	_NL_ABALTMON_8, _NL_ABALTMON_9, _NL_ABALTMON_10, _NL_ABALTMON_11,
	_NL_ABALTMON_12, _NL_WABALTMON_1, _NL_WABALTMON_2, _NL_WABALTMON_3,
	_NL_WABALTMON_4, _NL_WABALTMON_5, _NL_WABALTMON_6, _NL_WABALTMON_7,
	_NL_WABALTMON_8, _NL_WABALTMON_9, _NL_WABALTMON_10, _NL_WABALTMON_11,
	_NL_WABALTMON_12): New enum constants.
	* locale/programs/ld-time.c (struct locale_time_t): Add ab_alt_mon,
	wab_alt_mon, and ab_alt_mon_defined members.
	(time_output): Output ab_alt_mon and wab_alt_mon members.
	(time_read): Read them, initialize them as copies of abmon and wabmon
	respectively if they are missing, initialize ab_alt_mon_defined.
	* locale/programs/locfile-kw.gperf (ab_alt_mon): Define.
	* locale/programs/locfile-kw.h: Regenerate.
	* locale/programs/locfile-token.h (tok_ab_alt_mon): New enum constant.
	* time/Makefile [$(run-built-tests) = yes] (LOCALES): Add es_ES.UTF-8
	and ru_RU.UTF-8.
	* time/strftime_l.c (a_altmonth, aam_len): New macros.
	[!COMPILE_WIDE] (ABALTMON_1): New macro.
	(__strftime_internal): Handle %Ob and %Oh formats.
	* time/strptime_l.c [_LIBC] (ab_alt_month_name): New macro.
	(__strptime_internal): Handle %Ob and %Oh formats.
	* time/tst-strptime.c (day_tests): Add more tests to parse different
	forms of month names including the new %Ob format specifier.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-01-22 11:26:55 +01:00
Rafal Luzynski 95cb863a1e Implement alternative month names (bug 10871).
Some languages (Slavic, Baltic, etc.) require a genitive case of the
month name when formatting a full date (with the day number) while
they require a nominative case when referring to the month standalone.
This requirement cannot be fulfilled without providing two forms for
each month name.  From now it is specified that nl_langinfo(MON_1)
series (up to MON_12) and strftime("%B") generate the month names in
the grammatical form used when the month is a part of a complete date.
If the grammatical form used when the month is named by itself is needed,
the new values nl_langinfo(ALTMON_1) (up to ALTMON_12) and
strftime("%OB") are supported.  This new feature is optional so the
languages which do not need it or do not yet provide the updated
locales simply do not use it and their behaviour is unchanged.

	[BZ #10871]
	* locale/C-time.c (_nl_C_LC_TIME): Add alternative month names,
	define them as the same as primary full month names explicitly.
	* locale/categories.def (LC_TIME): Add alt_mon and wide-alt_mon.
	* locale/langinfo.h (__ALTMON_1, __ALTMON_2, __ALTMON_3, __ALTMON_4,
	__ALTMON_5, __ALTMON_6, __ALTMON_7, __ALTMON_8, __ALTMON_9, __ALTMON_10,
	__ALTMON_11, __ALTMON_12, _NL_WALTMON_1, _NL_WALTMON_2, _NL_WALTMON_3,
	_NL_WALTMON_4, _NL_WALTMON_5, _NL_WALTMON_6, _NL_WALTMON_7,
	_NL_WALTMON_8, _NL_WALTMON_9, _NL_WALTMON_10, _NL_WALTMON_11,
	_NL_WALTMON_12): New enum constants.
	[__USE_GNU] (ALTMON_1, ALTMON_2, ALTMON_3, ALTMON_4, ALTMON_5, ALTMON_6,
	ALTMON_7, ALTMON_8, ALTMON_9, ALTMON_10, ALTMON_11, ALTMON_12): New
	macros.
	* locale/programs/ld-time.c (struct locale_time_t): Add alt_mon,
	walt_mon, and alt_mon_defined members.
	(time_output): Output alt_mon and walt_mon members.
	(time_read): Read them, initialize them as copies of mon and wmon
	respectively if they are missing, initialize alt_mon_defined.
	* locale/programs/locfile-kw.gperf (alt_mon): Define.
	* locale/programs/locfile-kw.h: Regenerate.
	* locale/programs/locfile-token.h (tok_alt_mon): New enum constant.
	* localedata/tst-langinfo.c (map): Add tests for the new constants
	ALTMON_1 .. ALTMON_12.
	* time/Makefile [$(run-built-tests) = yes] (LOCALES): Add fr_FR.UTF-8
	and pl_PL.UTF-8.
	* time/strftime_l.c (f_altmonth): New macro.
	(__strftime_internal): Handle %OB format.
	* time/strptime_l.c [_LIBC] (alt_month_name): New macro.
	(__strptime_internal): Handle %OB format.
	* time/tst-strptime.c (day_tests): Add tests to parse different forms
	of month names including the new %OB format specifier.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-01-22 11:26:55 +01:00
Joseph Myers 688903eb3e Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2018-01-01 00:32:25 +00:00
H.J. Lu 36975e8e7e Replace = with += in CFLAGS-xxx.c/CPPFLAGS-xxx.c
Replace = with += in CFLAGS-xxx.c and CPPFLAGS-xxx.c to allow Makefile
under sysdeps to define CFLAGS-xx.c and CPPFLAGS-xxx.c.

	* argp/Makefile (CFLAGS-argp-help.c): Replace = with +=.
	(CFLAGS-argp-parse.c): Likewise.
	(CFLAGS-argp-fmtstream.c): Likewise.
	* crypt/Makefile (CPPFLAGS-sha256-crypt.c): Likewise.
	(CPPFLAGS-sha512-crypt.c): Likewise.
	(CPPFLAGS-md5-crypt.c): Likewise.
	* debug/Makefile (CFLAGS-stack_chk_fail.c): Likewise.
	(CFLAGS-stack_chk_fail_local.c): Likewise.
	(CFLAGS-backtrace.c): Likewise.
	(CFLAGS-sprintf_chk.c): Likewise.
	(CFLAGS-snprintf_chk.c): Likewise.
	(CFLAGS-vsprintf_chk.c): Likewise.
	(CFLAGS-vsnprintf_chk.c): Likewise.
	(CFLAGS-asprintf_chk.c): Likewise.
	(CFLAGS-vasprintf_chk.c): Likewise.
	(CFLAGS-obprintf_chk.c): Likewise.
	(CFLAGS-dprintf_chk.c): Likewise.
	(CFLAGS-vdprintf_chk.c): Likewise.
	(CFLAGS-printf_chk.c): Likewise.
	(CFLAGS-fprintf_chk.c): Likewise.
	(CFLAGS-vprintf_chk.c): Likewise.
	(CFLAGS-vfprintf_chk.c): Likewise.
	(CFLAGS-gets_chk.c): Likewise.
	(CFLAGS-fgets_chk.c): Likewise.
	(CFLAGS-fgets_u_chk.c): Likewise.
	(CFLAGS-fread_chk.c): Likewise.
	(CFLAGS-fread_u_chk.c): Likewise.
	(CFLAGS-swprintf_chk.c): Likewise.
	(CFLAGS-vswprintf_chk.c): Likewise.
	(CFLAGS-wprintf_chk.c): Likewise.
	(CFLAGS-fwprintf_chk.c): Likewise.
	(CFLAGS-vwprintf_chk.c): Likewise.
	(CFLAGS-vfwprintf_chk.c): Likewise.
	(CFLAGS-fgetws_chk.c): Likewise.
	(CFLAGS-fgetws_u_chk.c): Likewise.
	(CFLAGS-read_chk.c): Likewise.
	(CFLAGS-pread_chk.c): Likewise.
	(CFLAGS-pread64_chk.c): Likewise.
	(CFLAGS-recv_chk.c): Likewise.
	(CFLAGS-recvfrom_chk.c): Likewise.
	(CFLAGS-tst-longjmp_chk.c): Likewise.
	(CPPFLAGS-tst-longjmp_chk.c): Likewise.
	(CFLAGS-tst-longjmp_chk2.c): Likewise.
	(CPPFLAGS-tst-longjmp_chk2.c): Likewise.
	(CFLAGS-tst-longjmp_chk3.c): Likewise.
	(CPPFLAGS-tst-longjmp_chk3.c): Likewise.
	(CFLAGS-tst-chk1.c): Likewise.
	(CFLAGS-tst-chk2.c): Likewise.
	(CFLAGS-tst-chk3.c): Likewise.
	(CFLAGS-tst-chk4.cc): Likewise.
	(CFLAGS-tst-chk5.cc): Likewise.
	(CFLAGS-tst-chk6.cc): Likewise.
	(CFLAGS-tst-lfschk1.c): Likewise.
	(CFLAGS-tst-lfschk2.c): Likewise.
	(CFLAGS-tst-lfschk3.c): Likewise.
	(CFLAGS-tst-lfschk4.cc): Likewise.
	(CFLAGS-tst-lfschk5.cc): Likewise.
	(CFLAGS-tst-lfschk6.cc): Likewise.
	(CFLAGS-tst-ssp-1.c): Likewise.
	* dirent/Makefile (CFLAGS-scandir.c): Likewise.
	(CFLAGS-scandir64.c): Likewise.
	(CFLAGS-scandir-tail.c): Likewise.
	(CFLAGS-scandir64-tail.c): Likewise.
	* elf/Makefile (CPPFLAGS-dl-tunables.c): Likewise.
	(CFLAGS-dl-tunables.c): Likewise.
	(CFLAGS-dl-runtime.c): Likewise.
	(CFLAGS-dl-lookup.c): Likewise.
	(CFLAGS-dl-iterate-phdr.c): Likewise.
	(CFLAGS-vismain.c): Likewise.
	(CFLAGS-tst-linkall-static.c): Likewise.
	(CFLAGS-tst-linkall-static.c): Likewise.
	(CPPFLAGS-dl-load.c): Likewise.
	(CFLAGS-ldconfig.c): Likewise.
	(CFLAGS-dl-cache.c): Likewise.
	(CFLAGS-cache.c): Likewise.
	(CFLAGS-rtld.c): Likewise.
	(CFLAGS-multiload.c): Likewise.
	(CFLAGS-filtmod1.c): Likewise.
	(CFLAGS-tst-align.c): Likewise.
	(CFLAGS-tst-align2.c): Likewise.
	(CFLAGS-tst-alignmod.c): Likewise.
	(CFLAGS-tst-alignmod2.c): Likewise.
	(CPPFLAGS-tst-execstack.c): Likewise.
	(CFLAGS-tst-ptrguard1-static.c): Likewise.
	(CFLAGS-tst-latepthreadmod.c): Likewise.
	* grp/Makefile (CFLAGS-getgrgid_r.c): Likewise.
	(CFLAGS-getgrnam_r.c): Likewise.
	(CFLAGS-getgrent_r.c): Likewise.
	(CFLAGS-getgrent.c): Likewise.
	(CFLAGS-fgetgrent.c): Likewise.
	(CFLAGS-fgetgrent_r.c): Likewise.
	(CFLAGS-putgrent.c): Likewise.
	(CFLAGS-initgroups.c): Likewise.
	(CFLAGS-getgrgid.c): Likewise.
	* gshadow/Makefile (CFLAGS-getsgent_r.c): Likewise.
	(CFLAGS-getsgent.c): Likewise.
	(CFLAGS-fgetsgent.c): Likewise.
	(CFLAGS-fgetsgent_r.c): Likewise.
	(CFLAGS-putsgent.c): Likewise.
	(CFLAGS-getsgnam.c): Likewise.
	(CFLAGS-getsgnam_r.c): Likewise.
	* iconv/Makefile (CFLAGS-iconv_prog.c): Likewise.
	(CFLAGS-iconv_charmap.c): Likewise.
	(CFLAGS-dummy-repertoire.c): Likewise.
	(CFLAGS-charmap.c): Likewise.
	(CFLAGS-linereader.c): Likewise.
	(CFLAGS-simple-hash.c): Likewise.
	(CFLAGS-gconv_conf.c): Likewise.
	(CFLAGS-iconvconfig.c): Likewise.
	* inet/Makefile (CFLAGS-gethstbyad_r.c): Likewise.
	(CFLAGS-gethstbyad.c): Likewise.
	(CFLAGS-gethstbynm_r.c): Likewise.
	(CFLAGS-gethstbynm.c): Likewise.
	(CFLAGS-gethstbynm2_r.c): Likewise.
	(CFLAGS-gethstbynm2.c): Likewise.
	(CFLAGS-gethstent_r.c): Likewise.
	(CFLAGS-gethstent.c): Likewise.
	(CFLAGS-rcmd.c): Likewise.
	(CFLAGS-getnetbynm_r.c): Likewise.
	(CFLAGS-getnetbynm.c): Likewise.
	(CFLAGS-getnetbyad_r.c): Likewise.
	(CFLAGS-getnetbyad.c): Likewise.
	(CFLAGS-getnetent_r.c): Likewise.
	(CFLAGS-getnetent.c): Likewise.
	(CFLAGS-getaliasent_r.c): Likewise.
	(CFLAGS-getaliasent.c): Likewise.
	(CFLAGS-getrpcent_r.c): Likewise.
	(CFLAGS-getrpcent.c): Likewise.
	(CFLAGS-getservent_r.c): Likewise.
	(CFLAGS-getservent.c): Likewise.
	(CFLAGS-getprtent_r.c): Likewise.
	(CFLAGS-getprtent.c): Likewise.
	(CFLAGS-either_ntoh.c): Likewise.
	(CFLAGS-either_hton.c): Likewise.
	(CFLAGS-getnetgrent.c): Likewise.
	(CFLAGS-getnetgrent_r.c): Likewise.
	(CFLAGS-tst-checks-posix.c): Likewise.
	(CFLAGS-tst-sockaddr.c): Likewise.
	* intl/Makefile (CFLAGS-tst-gettext.c): Likewise.
	(CFLAGS-tst-translit.c): Likewise.
	(CFLAGS-tst-gettext2.c): Likewise.
	(CFLAGS-tst-codeset.c): Likewise.
	(CFLAGS-tst-gettext3.c): Likewise.
	(CFLAGS-tst-gettext4.c): Likewise.
	(CFLAGS-tst-gettext5.c): Likewise.
	(CFLAGS-tst-gettext6.c): Likewise.
	* io/Makefile (CFLAGS-open.c): Likewise.
	(CFLAGS-open64.c): Likewise.
	(CFLAGS-creat.c): Likewise.
	(CFLAGS-creat64.c): Likewise.
	(CFLAGS-fcntl.c): Likewise.
	(CFLAGS-poll.c): Likewise.
	(CFLAGS-ppoll.c): Likewise.
	(CFLAGS-lockf.c): Likewise.
	(CFLAGS-statfs.c): Likewise.
	(CFLAGS-fstatfs.c): Likewise.
	(CFLAGS-statvfs.c): Likewise.
	(CFLAGS-fstatvfs.c): Likewise.
	(CFLAGS-fts.c): Likewise.
	(CFLAGS-fts64.c): Likewise.
	(CFLAGS-ftw.c): Likewise.
	(CFLAGS-ftw64.c): Likewise.
	(CFLAGS-lockf.c): Likewise.
	(CFLAGS-posix_fallocate.c): Likewise.
	(CFLAGS-posix_fallocate64.c): Likewise.
	(CFLAGS-fallocate.c): Likewise.
	(CFLAGS-fallocate64.c): Likewise.
	(CFLAGS-read.c): Likewise.
	(CFLAGS-write.c): Likewise.
	(CFLAGS-test-stat.c): Likewise.
	(CFLAGS-test-lfs.c): Likewise.
	* libio/Makefile (CFLAGS-fileops.c): Likewise.
	(CFLAGS-fputc.c): Likewise.
	(CFLAGS-fputwc.c): Likewise.
	(CFLAGS-freopen64.c): Likewise.
	(CFLAGS-freopen.c): Likewise.
	(CFLAGS-fseek.c): Likewise.
	(CFLAGS-fseeko64.c): Likewise.
	(CFLAGS-fseeko.c): Likewise.
	(CFLAGS-ftello64.c): Likewise.
	(CFLAGS-ftello.c): Likewise.
	(CFLAGS-fwide.c): Likewise.
	(CFLAGS-genops.c): Likewise.
	(CFLAGS-getc.c): Likewise.
	(CFLAGS-getchar.c): Likewise.
	(CFLAGS-getwc.c): Likewise.
	(CFLAGS-getwchar.c): Likewise.
	(CFLAGS-iofclose.c): Likewise.
	(CFLAGS-iofflush.c): Likewise.
	(CFLAGS-iofgetpos64.c): Likewise.
	(CFLAGS-iofgetpos.c): Likewise.
	(CFLAGS-iofgets.c): Likewise.
	(CFLAGS-iofgetws.c): Likewise.
	(CFLAGS-iofputs.c): Likewise.
	(CFLAGS-iofputws.c): Likewise.
	(CFLAGS-iofread.c): Likewise.
	(CFLAGS-iofsetpos64.c): Likewise.
	(CFLAGS-iofsetpos.c): Likewise.
	(CFLAGS-ioftell.c): Likewise.
	(CFLAGS-iofwrite.c): Likewise.
	(CFLAGS-iogetdelim.c): Likewise.
	(CFLAGS-iogetline.c): Likewise.
	(CFLAGS-iogets.c): Likewise.
	(CFLAGS-iogetwline.c): Likewise.
	(CFLAGS-ioputs.c): Likewise.
	(CFLAGS-ioseekoff.c): Likewise.
	(CFLAGS-ioseekpos.c): Likewise.
	(CFLAGS-iosetbuffer.c): Likewise.
	(CFLAGS-iosetvbuf.c): Likewise.
	(CFLAGS-ioungetc.c): Likewise.
	(CFLAGS-ioungetwc.c): Likewise.
	(CFLAGS-oldfileops.c): Likewise.
	(CFLAGS-oldiofclose.c): Likewise.
	(CFLAGS-oldiofgetpos64.c): Likewise.
	(CFLAGS-oldiofgetpos.c): Likewise.
	(CFLAGS-oldiofsetpos64.c): Likewise.
	(CFLAGS-oldiofsetpos.c): Likewise.
	(CFLAGS-peekc.c): Likewise.
	(CFLAGS-putc.c): Likewise.
	(CFLAGS-putchar.c): Likewise.
	(CFLAGS-putwc.c): Likewise.
	(CFLAGS-putwchar.c): Likewise.
	(CFLAGS-rewind.c): Likewise.
	(CFLAGS-wfileops.c): Likewise.
	(CFLAGS-wgenops.c): Likewise.
	(CFLAGS-oldiofopen.c): Likewise.
	(CFLAGS-iofopen.c): Likewise.
	(CFLAGS-iofopen64.c): Likewise.
	(CFLAGS-oldtmpfile.c): Likewise.
	(CFLAGS-tst_putwc.c): Likewise.
	* locale/Makefile (CFLAGS-md5.c): Likewise.
	(CFLAGS-charmap.c): Likewise.
	(CFLAGS-locfile.c): Likewise.
	(CFLAGS-charmap-dir.c): Likewise.
	* login/Makefile (CFLAGS-grantpt.c): Likewise.
	(CFLAGS-getpt.c): Likewise.
	(CFLAGS-pt_chown.c): Likewise.
	* malloc/Makefile (CFLAGS-mcheck-init.c): Likewise.
	(CFLAGS-obstack.c): Likewise.
	* math/Makefile (CFLAGS-test-tgmath3.c): Likewise.
	(CFLAGS-test-double-vlen4-wrappers.c): Likewise.
	(CFLAGS-test-double-vlen8-wrappers.c): Likewise.
	(CFLAGS-test-float-vlen8-wrappers.c): Likewise.
	(CFLAGS-test-float-vlen16-wrappers.c): Likewise.
	(CFLAGS-test-tgmath.c): Likewise.
	(CFLAGS-test-tgmath2.c): Likewise.
	(CFLAGS-test-tgmath-ret.c): Likewise.
	(CFLAGS-test-powl.c): Likewise.
	(CFLAGS-test-snan.c): Likewise.
	(CFLAGS-test-signgam-finite.c): Likewise.
	(CFLAGS-test-signgam-finite-c99.c): Likewise.
	(CFLAGS-test-signgam-finite-c11.c): Likewise.
	(CFLAGS-test-signgam-uchar.c): Likewise.
	(CFLAGS-test-signgam-uchar-init.c): Likewise.
	(CFLAGS-test-signgam-uchar-static.c): Likewise.
	(CFLAGS-test-signgam-uchar-init-static.c): Likewise.
	(CFLAGS-test-signgam-uint.c): Likewise.
	(CFLAGS-test-signgam-uint-init.c): Likewise.
	(CFLAGS-test-signgam-uint-static.c): Likewise.
	(CFLAGS-test-signgam-uint-init-static.c): Likewise.
	(CFLAGS-test-signgam-ullong.c): Likewise.
	(CFLAGS-test-signgam-ullong-init.c): Likewise.
	(CFLAGS-test-signgam-ullong-static.c): Likewise.
	(CFLAGS-test-signgam-ullong-init-static.c): Likewise.
	(CFLAGS-test-math-cxx11.cc): Likewise.
	(CFLAGS-test-math-isinff.cc): Likewise.
	(CFLAGS-test-math-iszero.cc): Likewise.
	(CFLAGS-test-math-issignaling.cc): Likewise.
	(CFLAGS-test-math-iscanonical.cc): Likewise.
	(CFLAGS-test-iszero-excess-precision.c): Likewise.
	(CFLAGS-test-iseqsig-excess-precision.c): Likewise.
	(CFLAGS-test-flt-eval-method.c): Likewise.
	(CFLAGS-test-fe-snans-always-signal.c): Likewise.
	(CFLAGS-test-finite-macros.c): Likewise.
	* misc/Makefile (CFLAGS-select.c): Likewise.
	(CFLAGS-tsearch.c): Likewise.
	(CFLAGS-lsearch.c): Likewise.
	(CFLAGS-pselect.c): Likewise.
	(CFLAGS-readv.c): Likewise.
	(CFLAGS-writev.c): Likewise.
	(CFLAGS-preadv.c): Likewise.
	(CFLAGS-preadv64.c): Likewise.
	(CFLAGS-pwritev.c): Likewise.
	(CFLAGS-pwritev64.c): Likewise.
	(CFLAGS-preadv2.c): Likewise.
	(CFLAGS-preadv64v2.c): Likewise.
	(CFLAGS-pwritev2.c): Likewise.
	(CFLAGS-pwritev64v2.c): Likewise.
	(CFLAGS-usleep.c): Likewise.
	(CFLAGS-syslog.c): Likewise.
	(CFLAGS-error.c): Likewise.
	(CFLAGS-getpass.c): Likewise.
	(CFLAGS-mkstemp.c): Likewise.
	(CFLAGS-mkstemp64.c): Likewise.
	(CFLAGS-getsysstats.c): Likewise.
	(CFLAGS-getusershell.c): Likewise.
	(CFLAGS-err.c): Likewise.
	(CFLAGS-tst-tsearch.c): Likewise.
	(CFLAGS-msync.c): Likewise.
	(CFLAGS-fdatasync.c): Likewise.
	(CFLAGS-fsync.c): Likewise.
	* nptl/Makefile (CFLAGS-nptl-init.c): Likewise.
	(CFLAGS-unwind.c): Likewise.
	(CFLAGS-unwind-forcedunwind.c): Likewise.
	(CFLAGS-pthread_cancel.c): Likewise.
	(CFLAGS-pthread_setcancelstate.c): Likewise.
	(CFLAGS-pthread_setcanceltype.c): Likewise.
	(CFLAGS-cancellation.c): Likewise.
	(CFLAGS-libc-cancellation.c): Likewise.
	(CFLAGS-pthread_exit.c): Likewise.
	(CFLAGS-forward.c): Likewise.
	(CFLAGS-pthread_testcancel.c): Likewise.
	(CFLAGS-pthread_join.c): Likewise.
	(CFLAGS-pthread_timedjoin.c): Likewise.
	(CFLAGS-pthread_once.c): Likewise.
	(CFLAGS-pthread_cond_wait.c): Likewise.
	(CFLAGS-sem_wait.c): Likewise.
	(CFLAGS-sem_timedwait.c): Likewise.
	(CFLAGS-fcntl.c): Likewise.
	(CFLAGS-lockf.c): Likewise.
	(CFLAGS-pread.c): Likewise.
	(CFLAGS-pread64.c): Likewise.
	(CFLAGS-pwrite.c): Likewise.
	(CFLAGS-pwrite64.c): Likewise.
	(CFLAGS-wait.c): Likewise.
	(CFLAGS-waitpid.c): Likewise.
	(CFLAGS-sigwait.c): Likewise.
	(CFLAGS-msgrcv.c): Likewise.
	(CFLAGS-msgsnd.c): Likewise.
	(CFLAGS-tcdrain.c): Likewise.
	(CFLAGS-open.c): Likewise.
	(CFLAGS-open64.c): Likewise.
	(CFLAGS-pause.c): Likewise.
	(CFLAGS-recv.c): Likewise.
	(CFLAGS-send.c): Likewise.
	(CFLAGS-accept.c): Likewise.
	(CFLAGS-sendto.c): Likewise.
	(CFLAGS-connect.c): Likewise.
	(CFLAGS-recvfrom.c): Likewise.
	(CFLAGS-recvmsg.c): Likewise.
	(CFLAGS-sendmsg.c): Likewise.
	(CFLAGS-close.c): Likewise.
	(CFLAGS-read.c): Likewise.
	(CFLAGS-write.c): Likewise.
	(CFLAGS-nanosleep.c): Likewise.
	(CFLAGS-sigsuspend.c): Likewise.
	(CFLAGS-msync.c): Likewise.
	(CFLAGS-fdatasync.c): Likewise.
	(CFLAGS-fsync.c): Likewise.
	(CFLAGS-pt-system.c): Likewise.
	(CFLAGS-tst-cleanup2.c): Likewise.
	(CFLAGS-tst-cleanupx2.c): Likewise.
	(CFLAGS-flockfile.c): Likewise.
	(CFLAGS-ftrylockfile.c): Likewise.
	(CFLAGS-funlockfile.c): Likewise.
	(CFLAGS-tst-initializers1.c): Likewise.
	(CFLAGS-tst-initializers1-c89.c): Likewise.
	(CFLAGS-tst-initializers1-c99.c): Likewise.
	(CFLAGS-tst-initializers1-c11.c): Likewise.
	(CFLAGS-tst-initializers1-gnu89.c): Likewise.
	(CFLAGS-tst-initializers1-gnu99.c): Likewise.
	(CFLAGS-tst-initializers1-gnu11.c): Likewise.
	* nscd/Makefile (CFLAGS-nscd_getpw_r.c): Likewise.
	(CFLAGS-nscd_getgr_r.c): Likewise.
	(CFLAGS-nscd_gethst_r.c): Likewise.
	(CFLAGS-nscd_getai.c): Likewise.
	(CFLAGS-nscd_initgroups.c): Likewise.
	* posix/Makefile (CFLAGS-getaddrinfo.c): Likewise.
	(CFLAGS-pause.c): Likewise.
	(CFLAGS-pread.c): Likewise.
	(CFLAGS-pread64.c): Likewise.
	(CFLAGS-pwrite.c): Likewise.
	(CFLAGS-pwrite64.c): Likewise.
	(CFLAGS-sleep.c): Likewise.
	(CFLAGS-wait.c): Likewise.
	(CFLAGS-waitid.c): Likewise.
	(CFLAGS-waitpid.c): Likewise.
	(CFLAGS-getopt.c): Likewise.
	(CFLAGS-wordexp.c): Likewise.
	(CFLAGS-sysconf.c): Likewise.
	(CFLAGS-pathconf.c): Likewise.
	(CFLAGS-fpathconf.c): Likewise.
	(CFLAGS-spawn.c): Likewise.
	(CFLAGS-spawnp.c): Likewise.
	(CFLAGS-spawni.c): Likewise.
	(CFLAGS-glob.c): Likewise.
	(CFLAGS-glob64.c): Likewise.
	(CFLAGS-getconf.c): Likewise.
	(CFLAGS-nanosleep.c): Likewise.
	* pwd/Makefile (CFLAGS-getpwent_r.c): Likewise.
	(CFLAGS-getpwent.c): Likewise.
	(CFLAGS-getpw.c): Likewise.
	(CFLAGS-fgetpwent_r.c): Likewise.
	* resolv/Makefile (CFLAGS-res_hconf.c): Likewise.
	* rt/Makefile (CFLAGS-aio_suspend.c): Likewise.
	(CFLAGS-mq_timedreceive.c): Likewise.
	(CFLAGS-mq_timedsend.c): Likewise.
	(CFLAGS-clock_nanosleep.c): Likewise.
	(CFLAGS-librt-cancellation.c): Likewise.
	* shadow/Makefile (CFLAGS-getspent_r.c): Likewise.
	(CFLAGS-getspent.c): Likewise.
	(CFLAGS-fgetspent.c): Likewise.
	(CFLAGS-fgetspent_r.c): Likewise.
	(CFLAGS-putspent.c): Likewise.
	(CFLAGS-getspnam.c): Likewise.
	(CFLAGS-getspnam_r.c): Likewise.
	* signal/Makefile (CFLAGS-sigpause.c): Likewise.
	(CFLAGS-sigsuspend.c): Likewise.
	(CFLAGS-sigtimedwait.c): Likewise.
	(CFLAGS-sigwait.c): Likewise.
	(CFLAGS-sigwaitinfo.c): Likewise.
	(CFLAGS-sigreturn.c): Likewise.
	* stdio-common/Makefile (CFLAGS-vfprintf.c): Likewise.
	(CFLAGS-vfwprintf.c): Likewise.
	(CFLAGS-tmpfile.c): Likewise.
	(CFLAGS-tmpfile64.c): Likewise.
	(CFLAGS-tempname.c): Likewise.
	(CFLAGS-psignal.c): Likewise.
	(CFLAGS-vprintf.c): Likewise.
	(CFLAGS-cuserid.c): Likewise.
	(CFLAGS-errlist.c): Likewise.
	(CFLAGS-siglist.c): Likewise.
	(CFLAGS-scanf15.c): Likewise.
	(CFLAGS-scanf17.c): Likewise.
	* stdlib/Makefile (CFLAGS-bsearch.c): Likewise.
	(CFLAGS-msort.c): Likewise.
	(CFLAGS-qsort.c): Likewise.
	(CFLAGS-system.c): Likewise.
	(CFLAGS-fmtmsg.c): Likewise.
	(CFLAGS-strfmon.c): Likewise.
	(CFLAGS-strfmon_l.c): Likewise.
	(CFLAGS-strfromd.c): Likewise.
	(CFLAGS-strfromf.c): Likewise.
	(CFLAGS-strfroml.c): Likewise.
	(CFLAGS-tst-bsearch.c): Likewise.
	(CFLAGS-tst-qsort.c): Likewise.
	(CFLAGS-tst-makecontext2.c): Likewise.
	* sunrpc/Makefile (CFLAGS-xbootparam_prot.c): Likewise.
	(CFLAGS-xnlm_prot.c): Likewise.
	(CFLAGS-xrstat.c): Likewise.
	(CFLAGS-xyppasswd.c): Likewise.
	(CFLAGS-xklm_prot.c): Likewise.
	(CFLAGS-xrex.c): Likewise.
	(CFLAGS-xsm_inter.c): Likewise.
	(CFLAGS-xmount.c): Likewise.
	(CFLAGS-xrusers.c): Likewise.
	(CFLAGS-xspray.c): Likewise.
	(CFLAGS-xnfs_prot.c): Likewise.
	(CFLAGS-xrquota.c): Likewise.
	(CFLAGS-xkey_prot.c): Likewise.
	(CFLAGS-auth_unix.c): Likewise.
	(CFLAGS-key_call.c): Likewise.
	(CFLAGS-pmap_rmt.c): Likewise.
	(CFLAGS-clnt_perr.c): Likewise.
	(CFLAGS-openchild.c): Likewise.
	* sysvipc/Makefile (CFLAGS-msgrcv.c): Likewise.
	(CFLAGS-msgsnd.c): Likewise.
	* termios/Makefile (CFLAGS-tcdrain.c): Likewise.
	* time/Makefile (CFLAGS-tzfile.c): Likewise.
	(CFLAGS-tzset.c): Likewise.
	(CFLAGS-getdate.c): Likewise.
	(CFLAGS-test_time.c): Likewise.
	(CPPFLAGS-tst-tzname.c): Likewise.
	* timezone/Makefile (CFLAGS-zdump.c): Likewise.
	(CFLAGS-zic.c): Likewise.
	* wcsmbs/Makefile (CFLAGS-wcwidth.c): Likewise.
	(CFLAGS-wcswidth.c): Likewise.
	(CFLAGS-wcstol.c): Likewise.
	(CFLAGS-wcstoul.c): Likewise.
	(CFLAGS-wcstoll.c): Likewise.
	(CFLAGS-wcstoull.c): Likewise.
	(CFLAGS-wcstod.c): Likewise.
	(CFLAGS-wcstold.c): Likewise.
	(CFLAGS-wcstof128.c): Likewise.
	(CFLAGS-wcstof.c): Likewise.
	(CFLAGS-wcstol_l.c): Likewise.
	(CFLAGS-wcstoul_l.c): Likewise.
	(CFLAGS-wcstoll_l.c): Likewise.
	(CFLAGS-wcstoull_l.c): Likewise.
	(CFLAGS-wcstod_l.c): Likewise.
	(CFLAGS-wcstold_l.c): Likewise.
	(CFLAGS-wcstof128_l.c): Likewise.
	(CFLAGS-wcstof_l.c): Likewise.
	(CPPFLAGS-tst-wchar-h.c): Likewise.
	(CPPFLAGS-wcstold_l.c): Likewise.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
2017-12-11 13:11:33 -08:00
Florian Weimer 7e01f080e8 time: Remove the internal_function attribute 2017-08-31 15:59:07 +02:00
Florian Weimer d7ccc6c983 iconv, intl, locale, wcsmbs: Remove internal_function
Also adjust parts of the time subdirectory.
2017-08-31 15:59:06 +02:00
Joseph Myers e4043b84c4 Fix strftime build with GCC 8.
Building with current GCC mainline fails with:

strftime_l.c: In function '__strftime_internal':
strftime_l.c:719:4: error: macro expands to multiple statements [-Werror=multistatement-macros]
    digits = d > width ? d : width;          \
    ^
strftime_l.c:1260:6: note: in expansion of macro 'DO_NUMBER'
      DO_NUMBER (1, tp->tm_year + TM_YEAR_BASE);
      ^~~~~~~~~
strftime_l.c:1259:4: note: some parts of macro expansion are not guarded by this 'else' clause
    else
    ^~~~

In fact this particular instance is harmless; the code looks like:

          if (modifier == L_('O'))
            goto bad_format;
          else
            DO_NUMBER (1, tp->tm_year + TM_YEAR_BASE);

and because of the goto, it doesn't matter that part of the expansion
isn't under the "else" conditional.  But it's also clearly bad style
to rely on that.  This patch changes DO_NUMBER and DO_NUMBER_SPACEPAD
to use do { } while (0) to avoid such problems.

Tested (full testsuite) for x86_64 (GCC 6), and with
build-many-glibcs.py with GCC mainline, in conjunction with my libgcc
patch <https://gcc.gnu.org/ml/gcc-patches/2017-06/msg02032.html>.

	* time/strftime_l.c (DO_NUMBER): Define using do { } while (0).
	(DO_NUMBER_SPACEPAD): Likewise.
2017-06-27 17:12:13 +00:00
Zack Weinberg af85385f31 Use locale_t, not __locale_t, throughout glibc
<locale.h> is specified to define locale_t in POSIX.1-2008, and so are
all of the headers that define functions that take locale_t arguments.
Under _GNU_SOURCE, the additional headers that define such functions
have also always defined locale_t.  Therefore, there is no need to use
__locale_t in public function prototypes, nor in any internal code.

	* ctype/ctype-c99_l.c, ctype/ctype.h, ctype/ctype_l.c
	* include/monetary.h, include/stdlib.h, include/time.h
	* include/wchar.h, locale/duplocale.c, locale/freelocale.c
	* locale/global-locale.c, locale/langinfo.h, locale/locale.h
	* locale/localeinfo.h, locale/newlocale.c
	* locale/nl_langinfo_l.c, locale/uselocale.c
	* localedata/bug-usesetlocale.c, localedata/tst-xlocale2.c
	* stdio-common/vfscanf.c, stdlib/monetary.h, stdlib/stdlib.h
	* stdlib/strfmon_l.c, stdlib/strtod_l.c, stdlib/strtof_l.c
	* stdlib/strtol.c, stdlib/strtol_l.c, stdlib/strtold_l.c
	* stdlib/strtoll_l.c, stdlib/strtoul_l.c, stdlib/strtoull_l.c
	* string/strcasecmp.c, string/strcoll_l.c, string/string.h
	* string/strings.h, string/strncase.c, string/strxfrm_l.c
	* sysdeps/ieee754/float128/strtof128_l.c
	* sysdeps/ieee754/float128/wcstof128.c
	* sysdeps/ieee754/float128/wcstof128_l.c
	* sysdeps/ieee754/ldbl-128ibm/strtold_l.c
	* sysdeps/ieee754/ldbl-64-128/strtold_l.c
	* sysdeps/ieee754/ldbl-opt/nldbl-compat.c
	* sysdeps/ieee754/ldbl-opt/nldbl-strfmon_l.c
	* sysdeps/ieee754/ldbl-opt/nldbl-strtold_l.c
	* sysdeps/ieee754/ldbl-opt/nldbl-wcstold_l.c
	* sysdeps/powerpc/powerpc32/power7/strcasecmp.S
	* sysdeps/powerpc/powerpc64/power7/strcasecmp.S
	* sysdeps/x86_64/strcasecmp_l-nonascii.c
	* sysdeps/x86_64/strncase_l-nonascii.c, time/strftime_l.c
	* time/strptime_l.c, time/time.h, wcsmbs/mbsrtowcs_l.c
	* wcsmbs/wchar.h, wcsmbs/wcscasecmp.c, wcsmbs/wcsncase.c
	* wcsmbs/wcstod.c, wcsmbs/wcstod_l.c, wcsmbs/wcstof.c
	* wcsmbs/wcstof_l.c, wcsmbs/wcstol_l.c, wcsmbs/wcstold.c
	* wcsmbs/wcstold_l.c, wcsmbs/wcstoll_l.c, wcsmbs/wcstoul_l.c
	* wcsmbs/wcstoull_l.c, wctype/iswctype_l.c
	* wctype/towctrans_l.c, wctype/wcfuncs_l.c
	* wctype/wctrans_l.c, wctype/wctype.h, wctype/wctype_l.c:
	Change all uses of __locale_t to locale_t.
2017-06-20 20:30:06 -04:00
Zack Weinberg f0be25b633 Rename xlocale.h to bits/types/__locale_t.h.
xlocale.h is already a single-type micro-header, defining struct
__locale_struct and the typedefs __locale_t and locale_t.  This patch
brings it into the bits/types/ scheme: there are now
bits/types/__locale_t.h which defines only __locale_struct and
__locale_t, and bits/types/locale_t.h which defines locale_t as well
as the other two.  None of *our* headers need __locale_t.h, but it
appears to me that libstdc++ could make use of it.

There are a lot of external uses of xlocale.h, but all the uses I
checked had an autoconf test or equivalent for its existence.  It has
never been available from other C libraries, and it has always
contained a comment reading "This file is not standardized, don't rely
on it, it can go away without warning" so I think dropping it is
pretty safe.

I also took the opportunity to clean up comments in various public
header files that still talk about the *_l interfaces as though they
were completely nonstandard.  There are a few of them, notably the
strtoX_l and wcstoX_l families, that haven't been standardized, but
the bulk are in POSIX.1-2008.

        * locale/xlocale.h: Rename to...
	* locale/bits/types/__locale_t.h: ...here.  Adjust commentary.
	Only define struct __locale_struct and __locale_t, not locale_t.
        * locale/bits/types/locale_t.h: New file; define locale_t here.
        * locale/Makefile (headers): Update to match.

        * include/xlocale.h: Delete wrapper.
        * include/bits/types/__locale_t.h: New wrapper.
        * include/bits/types/locale_t.h: New wrapper.

        * ctype/ctype.h, include/printf.h, include/time.h
        * locale/langinfo.h, locale/locale.h, stdlib/monetary.h
        * stdlib/stdlib.h, string/string.h, string/strings.h, time/time.h
        * wcsmbs/wchar.h, wctype/wctype.h: Use bits/types/locale_t.h.
        Correct outdated comments regarding the standardization status of
        the functions that take locale_t arguments.

        * stdlib/strtod_l.c, stdlib/strtof_l.c, stdlib/strtol_l.c
        * stdlib/strtold_l.c, stdlib/strtoul_l.c, stdlib/strtoull_l.c
        * sysdeps/ieee754/ldbl-128ibm/strtold_l.c
        * sysdeps/ieee754/ldbl-64-128/strtold_l.c
        * wcsmbs/wcstod.c, wcsmbs/wcstod_l.c, wcsmbs/wcstof.c
        * wcsmbs/wcstof_l.c, wcsmbs/wcstold.c, wcsmbs/wcstold_l.c:
        Don't include xlocale.h. If necessary, include locale.h instead.

        * stdlib/strtold_l.c: Unconditionally include wchar.h.
2017-06-20 20:28:11 -04:00
Joseph Myers 92bd70fb85 Update timezone code from tzcode 2017b.
This patch updates files coming from tzcode to the versions in tzcode
2017b.  A couple of changes to other glibc code are needed.
time/tzset.c was using the SECSPERDAY macro from tzfile.h, which no
longer defines that macro, so a local definition is added to tzset.c.
Because timezone/private.h now defines the _ macro whenever
HAVE_GETTEXT is true, even if it was previously defined, it is also
necessary to avoid a conflict with the definition in
include/libintl.h.  Defining _ISOMAC is the obvious way to avoid such
internal definitions being visible, together with defining TZ_DOMAIN
so that zic and zdump continue to get the messages from the libc
domain as desired.  However, zic and zdump rely on PKGVERSION and
REPORT_BUGS_TO from config.h, which is not included by default with
_ISOMAC, so -include config.h needs adding to the options for these
programs as well.  Together those changes allow unmodified tzcode
2017b sources to work in glibc.

Tested for x86_64.

	* timezone/private.h: Update from tzcode 2017b.
	* timezone/tzfile.h: Likewise.
	* timezone/tzselect.ksh: Likewise.
	* timezone/zdump.c: Likewise.
	* timezone/zic.c: Likewise.
	* timezone/Makefile (tz-cflags): Add -D_ISOMAC
	-DTZ_DOMAIN='"libc"' -include $(common-objpfx)config.h.
	* time/tzset.c (SECSPERDAY): New macro.
2017-06-16 11:09:21 +00:00
Joseph Myers 2072f5c34e Remove C++ namespace handling from glibc headers.
glibc headers include some code (not particularly consistent or
systematic) to put various declarations in C++ namespaces std and
__c99, if _GLIBCPP_USE_NAMESPACES is defined.

As noted in <https://gcc.gnu.org/ml/libstdc++/2017-03/msg00025.html>,
this macro was removed from libstdc++ in 2000.  I don't expect
compilation with such old versions of libstdc++ to work with current
glibc headers anyway (whereas old *binaries* are expected to stay
working with current glibc); this patch (which should be a no-op with
any libstdc++ version postdating that removal) removes all this code
from the glibc headers.

The begin-end-check.pl test, whose comments say it is about checking
these namespace macro calls, is also removed.  The code in that test
would have covered __BEGIN_DECLS / __END_DECLS as well, but if those
weren't properly matched it would show up with the
check-installed-headers-cxx tests, so I don't think there is an actual
use for keeping begin-end-check.pl with the namespace code removed.

Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).

	* misc/sys/cdefs.h (__BEGIN_NAMESPACE_STD): Remove macro.
	(__END_NAMESPACE_STD): Likewise.
	(__USING_NAMESPACE_STD): Likewise.
	(__BEGIN_NAMESPACE_C99): Likewise.
	(__END_NAMESPACE_C99): Likewise.
	(__USING_NAMESPACE_C99): Likewise.
	* math/math.h (_Mdouble_BEGIN_NAMESPACE): Do not define and
	undefine macro.
	(_Mdouble_END_NAMESPACE): Likewise.
	* ctype/ctype.h: Do not handle C++ namespaces.
	* libio/bits/stdio-ldbl.h: Likewise.
	* libio/stdio.h: Likewise.
	* locale/locale.h: Likewise.
	* math/bits/mathcalls.h: Likewise.
	* setjmp/setjmp.h: Likewise.
	* signal/signal.h: Likewise.
	* stdlib/bits/stdlib-float.h: Likewise.
	* stdlib/bits/stdlib-ldbl.h: Likewise.
	* stdlib/stdlib.h: Likewise.
	* string/string.h: Likewise.
	* sysdeps/x86/fpu/bits/mathinline.h: Likewise.
	* time/bits/types/clock_t.h: Likewise.
	* time/bits/types/struct_tm.h: Likewise.
	* time/bits/types/time_t.h: Likewise.
	* time/time.h: Likewise.
	* wcsmbs/bits/wchar-ldbl.h: Likewise.
	* wcsmbs/uchar.h: Likewise.
	* wcsmbs/wchar.h: Likewise.
	[_GLIBCPP_USE_NAMESPACES] (wint_t): Remove conditional definition.
	* wctype/wctype.h: Do not handle C++ namespaces.
	* scripts/begin-end-check.pl: Remove.
	* Makefile (installed-headers): Likewise.
	(tests-special): Do not add $(objpfx)begin-end-check.out.
	($(objpfx)begin-end-check.out): Remove.
2017-03-16 13:31:57 +00:00
Florian Weimer 6e3b52292a tzset: Clean up preprocessor macros min, max, sign 2017-03-07 17:45:39 +01:00
Florian Weimer 8492c4dd69 timezone: Remove TZNAME_MAX limit from sysconf [BZ #15576]
glibc does not impose a limit, and POSIX does not allow a
sysconf limit which changes during the lifetime of a process.
2017-03-07 17:45:38 +01:00
Florian Weimer 7eb5c06c35 tzset: Remove unused NOID macro 2017-03-03 11:25:44 +01:00
Florian Weimer b2f3c0c208 tzset: Remove __attribute_noinline__ from compute_offset
After commit 42261ad731,
compute_offset is only called once, so not inlining it
increases executable size.
2017-03-03 09:06:54 +01:00
Zack Weinberg e15f7de60c Split DIAG_* macros to new header libc-diag.h.
Quite a few tests include libc-internal.h just for the DIAG_* macros.
Split those macros to their own file, which can be included safely in
_ISOMAC mode.  I also moved ignore_value, since it seems logically
related, even though I didn't notice any tests needing it.

Also add -Wnonnull suppressions to two tests that _should_ have them,
but the error is masked when compiling against internal headers.

	* include/libc-diag.h: New file.  Define ignore_value,
	DIAG_PUSH_NEEDS_COMMENT, DIAG_POP_NEEDS_COMMENT,
	DIAG_IGNORE_NEEDS_COMMENT, and DIAG_IGNORE_Os_NEEDS_COMMENT here.

	* include/libc-internal.h: Definitions of above macros moved from
	here.  Include libc-diag.h.  Add copyright notice.

	* malloc/tst-malloc.c, malloc/tst-memcheck.c, malloc/tst-realloc.c
	* misc/tst-error1.c, posix/tst-dir.c, stdio-common/bug21.c
	* stdio-common/scanf14.c, stdio-common/scanf4.c, stdio-common/scanf7.c
	* stdio-common/test-vfprintf.c, stdio-common/tst-printf.c
	* stdio-common/tst-printfsz.c, stdio-common/tst-sprintf.c
	* stdio-common/tst-unlockedio.c, stdio-common/tstdiomisc.c
	* stdlib/bug-getcontext.c, string/tester.c, string/tst-endian.c
	* time/tst-strptime2.c, wcsmbs/tst-wcstof.c:
	Include libc-diag.h instead of libc-internal.h.

	* stdlib/tst-environ.c: Include libc-diag.h.  Suppress -Wnonnull for
	call to unsetenv (NULL).
	* nptl/tst-mutex1.c: Include libc-diag.h.  Suppress -Wnonnull for
	call to pthread_mutexattr_destroy (NULL).
2017-02-25 09:59:46 -05:00
Zack Weinberg ceaa98897c Add missing header files throughout the testsuite.
* crypt/md5.h: Test _LIBC with #if defined, not #if.
	* dirent/opendir-tst1.c: Include sys/stat.h.
	* dirent/tst-fdopendir.c: Include sys/stat.h.
	* dirent/tst-fdopendir2.c: Include stdlib.h.
	* dirent/tst-scandir.c: Include stdbool.h.
	* elf/tst-auditmod1.c: Include link.h and stddef.h.
	* elf/tst-tls15.c: Include stdlib.h.
	* elf/tst-tls16.c: Include stdlib.h.
	* elf/tst-tls17.c: Include stdlib.h.
	* elf/tst-tls18.c: Include stdlib.h.
	* iconv/tst-iconv6.c: Include endian.h.
	* iconvdata/bug-iconv11.c: Include limits.h.
	* io/test-utime.c: Include stdint.h.
	* io/tst-faccessat.c: Include sys/stat.h.
	* io/tst-fchmodat.c: Include sys/stat.h.
	* io/tst-fchownat.c: Include sys/stat.h.
	* io/tst-fstatat.c: Include sys/stat.h.
	* io/tst-futimesat.c: Include sys/stat.h.
	* io/tst-linkat.c: Include sys/stat.h.
	* io/tst-mkdirat.c: Include sys/stat.h and stdbool.h.
	* io/tst-mkfifoat.c: Include sys/stat.h and stdbool.h.
	* io/tst-mknodat.c: Include sys/stat.h and stdbool.h.
	* io/tst-openat.c: Include stdbool.h.
	* io/tst-readlinkat.c: Include sys/stat.h.
	* io/tst-renameat.c: Include sys/stat.h.
	* io/tst-symlinkat.c: Include sys/stat.h.
	* io/tst-unlinkat.c: Include stdbool.h.
	* libio/bug-memstream1.c: Include stdlib.h.
	* libio/bug-wmemstream1.c: Include stdlib.h.
	* libio/tst-fwrite-error.c: Include stdlib.h.
	* libio/tst-memstream1.c: Include stdlib.h.
	* libio/tst-memstream2.c: Include stdlib.h.
	* libio/tst-memstream3.c: Include stdlib.h.
	* malloc/tst-interpose-aux.c: Include stdint.h.
	* misc/tst-preadvwritev-common.c: Include sys/stat.h.
	* nptl/tst-basic7.c: Include limits.h.
	* nptl/tst-cancel25.c: Include pthread.h, not pthreadP.h.
	* nptl/tst-cancel4.c: Include stddef.h, limits.h, and sys/stat.h.
	* nptl/tst-cancel4_1.c: Include stddef.h.
	* nptl/tst-cancel4_2.c: Include stddef.h.
	* nptl/tst-cond16.c: Include limits.h.
	Use sysconf(_SC_PAGESIZE) instead of __getpagesize.
	* nptl/tst-cond18.c: Include limits.h.
	Use sysconf(_SC_PAGESIZE) instead of __getpagesize.
	* nptl/tst-cond4.c: Include stdint.h.
	* nptl/tst-cond6.c: Include stdint.h.
	* nptl/tst-stack2.c: Include limits.h.
	* nptl/tst-stackguard1.c: Include stddef.h.
	* nptl/tst-tls4.c: Include stdint.h. Don't include tls.h.
	* nptl/tst-tls4moda.c: Include stddef.h.
	Don't include stdio.h, unistd.h, or tls.h.
	* nptl/tst-tls4modb.c: Include stddef.h.
	Don't include stdio.h, unistd.h, or tls.h.
	* nptl/tst-tls5.h: Include stddef.h. Don't include stdlib.h or tls.h.
	* posix/tst-getaddrinfo2.c: Include stdio.h.
	* posix/tst-getaddrinfo5.c: Include stdio.h.
	* posix/tst-pathconf.c: Include sys/stat.h.
	* posix/tst-posix_fadvise-common.c: Include stdint.h.
	* posix/tst-preadwrite-common.c: Include sys/stat.h.
	* posix/tst-regex.c: Include stdint.h.
	Don't include spawn.h or spawn_int.h.
	* posix/tst-regexloc.c: Don't include spawn.h or spawn_int.h.
	* posix/tst-vfork3.c: Include sys/stat.h.
	* resolv/tst-bug18665-tcp.c: Include stdlib.h.
	* resolv/tst-res_hconf_reorder.c: Include stdlib.h.
	* resolv/tst-resolv-search.c: Include stdlib.h.
	* stdio-common/tst-fmemopen2.c: Include stdint.h.
	* stdio-common/tst-vfprintf-width-prec.c: Include stdlib.h.
	* stdlib/test-canon.c: Include sys/stat.h.
	* stdlib/tst-tls-atexit.c: Include stdbool.h.
	* string/test-memchr.c: Include stdint.h.
	* string/tst-cmp.c: Include stdint.h.
	* sysdeps/pthread/tst-timer.c: Include stdint.h.
	* sysdeps/unix/sysv/linux/tst-sync_file_range.c: Include stdint.h.
	* sysdeps/wordsize-64/tst-writev.c: Include limits.h and stdint.h.
	* sysdeps/x86_64/fpu/math-tests-arch.h: Include cpu-features.h.
	Don't include init-arch.h.
	* sysdeps/x86_64/multiarch/test-multiarch.h: Include cpu-features.h.
	Don't include init-arch.h.
	* sysdeps/x86_64/tst-auditmod10b.c: Include link.h and stddef.h.
	* sysdeps/x86_64/tst-auditmod3b.c: Include link.h and stddef.h.
	* sysdeps/x86_64/tst-auditmod4b.c: Include link.h and stddef.h.
	* sysdeps/x86_64/tst-auditmod5b.c: Include link.h and stddef.h.
	* sysdeps/x86_64/tst-auditmod6b.c: Include link.h and stddef.h.
	* sysdeps/x86_64/tst-auditmod6c.c: Include link.h and stddef.h.
	* sysdeps/x86_64/tst-auditmod7b.c: Include link.h and stddef.h.
	* time/clocktest.c: Include stdint.h.
	* time/tst-posixtz.c: Include stdint.h.
	* timezone/tst-timezone.c: Include stdint.h.
2017-02-16 17:33:18 -05:00
Joseph Myers 3c9378265a Fix testsuite build for GCC 7 -Wformat-truncation.
This patch fixes the glibc testsuite build for GCC 7
-Wformat-truncation, newly moved out of -Wformat-length and with some
further warnings that didn't previously appear.  Two tests that
previously disabled -Wformat-length are changed to disable
-Wformat-truncation instead; two others are made to disable that
option as well.

Tested (compilation only) with build-many-glibcs.py for aarch64 with
GCC mainline.

	* stdio-common/tst-printf.c [__GNUC_PREREQ (7, 0)]: Ignore
	-Wformat-truncation instead of -Wformat-length.
	* time/tst-strptime2.c (mkbuf) [__GNUC_PREREQ (7, 0)]: Likewise.
	* stdio-common/tstdiomisc.c (F): Ignore -Wformat-truncation for
	GCC 7.
	* wcsmbs/tst-wcstof.c: Include <libc-internal.h>.
	(do_test): Ignore -Wformat-truncation for GCC 7.
2017-01-11 14:02:23 +00:00
Joseph Myers bfff8b1bec Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Florian Weimer c23de0aacb support: Introduce new subdirectory for test infrastructure
The new test driver in <support/test-driver.c> has feature parity with
the old one.  The main difference is that its hooking mechanism is
based on functions and function pointers instead of macros.  This
commit also implements a new environment variable, TEST_COREDUMPS,
which disables the code which disables coredumps (that is, it enables
them if the invocation environment has not disabled them).

<test-skeleton.c> defines wrapper functions so that it is possible to
use existing macros with the new-style hook functionality.

This commit changes only a few test cases to the new test driver, to
make sure that it works as expected.
2016-12-09 08:18:27 +01:00
Steve Ellcey 26d7185d6f Fix -Wformat-length warning in time/tst-strptime2.c
* time/tst-strptime2.c: Ignore -Wformat-length warning.
2016-11-02 16:00:39 -07:00
Zack Weinberg 05b68e14b1 Installed-header hygiene (BZ#20366): time.h types.
Many headers are expected to expose a subset of the type definitions
in time.h.  time.h has a whole bunch of messy logic for conditionally
defining some its types and structs, but, as best I can tell, this
has never worked 100%.  In particular, __need_timespec is ineffective
if _TIME_H has already been defined, which means that if you compile

  #include <time.h>
  #include <sched.h>

with e.g. -fsyntax-only -std=c89 -Wall -Wsystem-headers, you will get

In file included from test.c:2:0:
/usr/include/sched.h:74:57: warning: "struct timespec" declared inside
  parameter list will not be visible outside of this definition or declaration
 extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW;
                                                         ^~~~~~~~

And if you want to _use_ sched_rr_get_interval in a TU compiled that
way, you're hosed.

This patch replaces all of that with small bits/types/TYPE.h headers
as introduced earlier.  time.h and bits/time.h are now *much* simpler,
and a lot of other headers are slightly simpler.

	* time/time.h, bits/time.h, sysdeps/unix/sysv/linux/bits/time.h:
	Remove all logic conditional on __need macros.  Move all the
	conditionally defined types to their own headers...
	* time/bits/types/clock_t.h: Define clock_t here.
	* time/bits/types/clockid_t.h: Define clockid_t here.
	* time/bits/types/struct_itimerspec.h: Define struct itimerspec here.
	* time/bits/types/struct_timespec.h: Define struct timespec here.
	* time/bits/types/struct_timeval.h: Define struct timeval here.
	* time/bits/types/struct_tm.h: Define struct tm here.
	* time/bits/types/time_t.h: Define time_t here.
	* time/bits/types/timer_t.h: Define timer_t here.
	* time/Makefile: Install the new headers.

	* bits/resource.h, io/fcntl.h, io/sys/poll.h, io/sys/stat.h
	* io/utime.h, misc/sys/select.h, posix/sched.h, posix/sys/times.h
	* posix/sys/types.h, resolv/netdb.h, rt/aio.h, rt/mqueue.h
	* signal/signal.h, pthread/semaphore.h, sysdeps/nptl/pthread.h
	* sysdeps/unix/sysv/linux/alpha/bits/resource.h
	* sysdeps/unix/sysv/linux/alpha/sys/acct.h
	* sysdeps/unix/sysv/linux/bits/resource.h
	* sysdeps/unix/sysv/linux/bits/timex.h
	* sysdeps/unix/sysv/linux/mips/bits/resource.h
	* sysdeps/unix/sysv/linux/net/ppp_defs.h
	* sysdeps/unix/sysv/linux/sparc/bits/resource.h
	* sysdeps/unix/sysv/linux/sys/acct.h
	* sysdeps/unix/sysv/linux/sys/timerfd.h
	* sysvipc/sys/msg.h, sysvipc/sys/sem.h, sysvipc/sys/shm.h
	* time/sys/time.h, time/sys/timeb.h
	Use the new bits/types headers.

	* include/time.h: Remove __need logic.
	* include/bits/time.h
	* include/bits/types/clock_t.h, include/bits/types/clockid_t.h
	* include/bits/types/time_t.h, include/bits/types/timer_t.h
	* include/bits/types/struct_itimerspec.h
	* include/bits/types/struct_timespec.h
	* include/bits/types/struct_timeval.h
	* include/bits/types/struct_tm.h:
	New wrapper headers.
2016-09-23 08:43:56 -04:00
Martin Sebor f2b3078e6a Fix build failures with -DDEBUG.
[BZ #19443]
        * crypt/crypt_util.c [DEBUG] (_ufc_prbits): Correct format string.
        [DEBUG] (_ufc_set_bits): Declare used.
        * iconv/gconv_dl.c [DEBUG]: Add a missing include directive.
        [DEBUG] (print_all): Declare used.
        * resolv/res_send.c [DEBUG] (__libc_res_nsend): Explicitly convert
        operands of the ternary ?: expression to target type.
        * stdlib/rshift.c [DEBUG] (mpn_rshift): Use assert() instead of
        calling the undeclared abort.
        * time/mktime.c [DEBUG] (DEBUG): Rename to DEBUG_MKTIME.
2016-01-15 11:07:41 -07:00
H.J. Lu 82c9a4f85e Use TIME_T_MAX and TIME_T_MIN in tst-mktime2.c
GCC 5.3 compiles

for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
    continue;

into an infinite loop with -Os.  We can copy TIME_T_MAX and TIME_T_MIN
from time/mktime.c.

	[BZ #19466]
	* time/tst-mktime2.c (time_t_max): Removed.
	(time_t_min): Likewise.
	(TYPE_SIGNED): New.
	(TYPE_MINIMUM): Likewise.
	(TYPE_MAXIMUM): Likewise.
	(TIME_T_MIN): Likewise.
	(TIME_T_MAX): Likewise.
	(mktime_test): Replace time_t_max and time_t_min with TIME_T_MAX
	and TIME_T_MIN.
	(do_test): Likewise.
2016-01-14 16:35:40 -08:00
Andreas Schwab c83196b0df Force rereading TZDEFRULES after it was used to set DST rules only (bug #19253)
If the TZDEFRULES file was used to set the DST rules when $TZ didn't
provide any we need to make sure that the next time it is used we
recompute everything as __tzfile_default changes some setting from what is
provided by TZDEFRULES.
2016-01-11 16:42:25 +01:00
Joseph Myers f7a9f785e5 Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Joseph Myers 80d9be8122 Convert miscellaneous function definitions to prototype style.
This patch converts various miscellaneous functions definitions in
glibc, found with grep and not covered by my previous scripted
conversions, from old-style K&R to prototype-style.  These changes
were made manually.  This is not necessarily exhaustive as formatting
variants may have prevented my grep from finding some such
definitions.

Regarding the changes to files from GMP, they may originally have been
omitted when removing __STDC__ conditionals because of the files
coming from another package, but (a) GMP no longer has __STDC__
conditionals there anyway and (b) we don't try to keep these files
verbatim in sync with GMP (and there are licensing differences), so
making the change to them in glibc seems reasonable.

Tested for x86_64 and x86 (testsuite - this patch affects files
containing assertions).

	* debug/fortify_fail.c (__fortify_fail): Convert to
	prototype-style function definition.  Use internal_function.
	* libio/genops.c (save_for_backup): Convert to prototype-style
	function definition.
	* libio/wgenops.c (save_for_wbackup): Likewise.
	* login/grantpt.c (grantpt): Likewise.
	* login/ptsname.c (ptsname): Likewise.
	(__ptsname_r): Likewise.
	* login/unlockpt.c (unlockpt): Likewise.
	* mach/msgserver.c (__mach_msg_server): Likewise.
	* misc/efgcvt.c (__APPEND (FUNC_PREFIX, fcvt)): Likewise.
	(__APPEND (FUNC_PREFIX, ecvt)): Likewise.
	(__APPEND (FUNC_PREFIX, gcvt)): Likewise.
	* misc/efgcvt_r.c (__APPEND (FUNC_PREFIX, fcvt_r)): Likewise.
	(__APPEND (FUNC_PREFIX, ecvt_r)): Likewise.
	* nptl/cleanup_compat.c (_pthread_cleanup_push): Likewise.
	* nptl/cleanup_defer_compat.c (_pthread_cleanup_push_defer):
	Likewise.
	* nptl/libc_pthread_init.c (__libc_pthread_init): Likewise.  Use
	internal_function.
	* nptl/pthread_atfork.c (__pthread_atfork): Convert to
	prototype-style function definition.
	* nptl/pthread_create.c (__pthread_create_2_1): Likewise.
	[SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1)]
	(__pthread_create_2_0): Likewise.
	* nptl/pthread_key_create.c (__pthread_key_create): Likewise.
	* nptl/register-atfork.c (__register_atfork): Likewise.
	* posix/glob.c (glob): Likewise.
	* posix/regcomp.c (re_comp): Likewise.
	* posix/regexec.c (re_exec): Likewise.
	* stdlib/add_n.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/cmp.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/divmod_1.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/divrem.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/lshift.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/mod_1.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/mul.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/mul_n.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/rshift.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/strtod.c (INTERNAL (STRTOF)): Convert to prototype-style
	function definition.
	(STRTOF): Likewise.
	* stdlib/strtod_l.c (__STRTOF): Likewise.
	* stdlib/strtol.c (INTERNAL (strtol)): Likewise.
	* stdlib/strtol_l.c (INTERNAL (__strtol_l)): Likewise.
	(__strtol_l): Likewise.
	* stdlib/sub_n.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* string/memrchr.c (MEMRCHR): Convert to prototype-style function
	definition.
	* string/strcasecmp.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__strcasecmp): Convert to prototype-style function definition.
	* string/strncase.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__strncasecmp): Convert to prototype-style function definition.
	* sunrpc/pm_getport.c (__libc_rpc_getport): Likewise.
	* sunrpc/xdr.c (xdr_union): Likewise.
	* sunrpc/xdr_array.c (xdr_array): Likewise.
	* sunrpc/xdr_ref.c (xdr_reference): Likewise.
	* sysdeps/m68k/m680x0/fpu/s_atan.c (__CONCATX(__,FUNC)): Likewise.
	* sysdeps/m68k/m680x0/fpu/s_isinf.c (__CONCATX(__,FUNC)):
	Likewise.
	* sysdeps/m68k/m680x0/fpu/s_scalbn.c (__CONCATX(__scalbn,suffix):
	Likewise.
	* sysdeps/m68k/m680x0/fpu/s_sincos.c (CONCATX(__,FUNC)): Likewise.
	* sysdeps/unix/sysv/linux/i386/scandir64.c (__old_scandir64):
	Likewise.
	* time/strftime_l.c (LOCALE_PARAM_DECL): Remove macro.
	(LOCALE_PARAM_PROTO): Likewise.
	[_LIBC && USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include
	argument type.
	(ut_argument_spec): Remove macro.
	(ut_argument_spec_iso): Rename to ut_argument_spec.
	(memcpy_lowcase): Use LOCALE_PARAM in declaration.  Convert to
	prototype-style function definition.
	(memcpy_uppcase): Likewise.
	(__strftime_internal): Likewise.
	(my_strftime): Likewise.
	* time/strptime_l.c (LOCALE_PARAM_PROTO): Remove macro.
	(LOCALE_PARAM_DECL): Likewise.
	[_LIBC] (LOCALE_PARAM): Include argument type.
	(__strptime_internal): Convert to prototype-style function
	definition.
	(strptime): Likewise.
	* wcsmbs/wcscasecmp.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__wcscasecmp): Convert to prototype-style function definition.
	* wcsmbs/wcsncase.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__wcsncasecmp): Convert to prototype-style function definition.
2015-10-20 21:27:22 +00:00