summaryrefslogtreecommitdiff
path: root/time
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2018-12-27 19:31:37 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-12-27 19:31:37 +0000
commit74a412373b66a38b6ce8156f027ce26f89a7462f (patch)
treea59ce0af7ffd48641ca9124d697f7a6b57b26931 /time
parent2004eeba8fb2a92105bbf95b280fff6dc1d84144 (diff)
parent4cbfda396f7cd9e83116c28965ade73d80c1cb82 (diff)
Merge commit 'refs/top-bases/t/ONSTACK' into t/ONSTACK
Diffstat (limited to 'time')
-rw-r--r--time/Makefile24
-rw-r--r--time/adjtime.c2
-rw-r--r--time/alt_digit.c5
-rw-r--r--time/asctime.c2
-rw-r--r--time/bits/types/clock_t.h9
-rw-r--r--time/bits/types/clockid_t.h9
-rw-r--r--time/bits/types/struct_itimerspec.h14
-rw-r--r--time/bits/types/struct_timespec.h15
-rw-r--r--time/bits/types/struct_timeval.h13
-rw-r--r--time/bits/types/struct_tm.h28
-rw-r--r--time/bits/types/time_t.h9
-rw-r--r--time/bits/types/timer_t.h9
-rw-r--r--time/bug-getdate1.c24
-rw-r--r--time/clock.c2
-rw-r--r--time/clocktest.c1
-rw-r--r--time/ctime.c2
-rw-r--r--time/ctime_r.c2
-rw-r--r--time/difftime.c2
-rw-r--r--time/dysize.c2
-rw-r--r--time/era.c6
-rw-r--r--time/ftime.c2
-rw-r--r--time/getdate.c6
-rw-r--r--time/getitimer.c2
-rw-r--r--time/gettimeofday.c2
-rw-r--r--time/gmtime.c2
-rw-r--r--time/lc-time-cleanup.c4
-rw-r--r--time/localtime.c2
-rw-r--r--time/mktime.c2
-rw-r--r--time/offtime.c2
-rw-r--r--time/setitimer.c2
-rw-r--r--time/settimeofday.c2
-rw-r--r--time/stime.c2
-rw-r--r--time/strftime.c2
-rw-r--r--time/strftime_l.c51
-rw-r--r--time/strptime.c2
-rw-r--r--time/strptime_l.c55
-rw-r--r--time/sys/time.h11
-rw-r--r--time/sys/timeb.h6
-rw-r--r--time/test_time.c2
-rw-r--r--time/time.c2
-rw-r--r--time/time.h251
-rw-r--r--time/timegm.c2
-rw-r--r--time/timespec_get.c2
-rw-r--r--time/tst-ftime.c2
-rw-r--r--time/tst-getdate.c2
-rw-r--r--time/tst-posixtz.c1
-rw-r--r--time/tst-strptime-whitespace.c2
-rw-r--r--time/tst-strptime.c24
-rw-r--r--time/tst-strptime2.c11
-rw-r--r--time/tst-tzname.c2
-rw-r--r--time/tst-y2039.c46
-rw-r--r--time/tzfile.c155
-rw-r--r--time/tzset.c67
-rw-r--r--time/wcsftime.c2
-rw-r--r--time/wcsftime_l.c2
55 files changed, 470 insertions, 442 deletions
diff --git a/time/Makefile b/time/Makefile
index e052c0765d..ec3e39dcea 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2016 Free Software Foundation, Inc.
+# Copyright (C) 1991-2018 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -22,7 +22,12 @@ subdir := time
include ../Makeconfig
-headers := time.h sys/time.h sys/timeb.h bits/time.h
+headers := time.h sys/time.h sys/timeb.h bits/time.h \
+ bits/types/clockid_t.h bits/types/clock_t.h \
+ bits/types/struct_itimerspec.h \
+ bits/types/struct_timespec.h bits/types/struct_timeval.h \
+ bits/types/struct_tm.h bits/types/timer_t.h \
+ bits/types/time_t.h
routines := offtime asctime clock ctime ctime_r difftime \
gmtime localtime mktime time \
@@ -38,12 +43,13 @@ tests := test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
tst-getdate tst-mktime tst-mktime2 tst-ftime_l tst-strftime \
tst-mktime3 tst-strptime2 bug-asctime bug-asctime_r bug-mktime1 \
tst-strptime3 bug-getdate1 tst-strptime-whitespace tst-ftime \
- tst-tzname
+ tst-tzname tst-y2039
include ../Rules
ifeq ($(run-built-tests),yes)
-LOCALES := de_DE.ISO-8859-1 en_US.ISO-8859-1 ja_JP.EUC-JP
+LOCALES := de_DE.ISO-8859-1 en_US.ISO-8859-1 ja_JP.EUC-JP fr_FR.UTF-8 \
+ es_ES.UTF-8 pl_PL.UTF-8 ru_RU.UTF-8
include ../gen-locales.mk
$(objpfx)tst-ftime_l.out: $(gen-locales)
@@ -54,17 +60,17 @@ tz-cflags = -DTZDIR='"$(zonedir)"' \
-DTZDEFAULT='"$(localtime-file)"' \
-DTZDEFRULES='"$(posixrules-file)"'
-CFLAGS-tzfile.c = $(tz-cflags)
-CFLAGS-tzset.c = $(tz-cflags)
-CFLAGS-getdate.c = -fexceptions
+CFLAGS-tzfile.c += $(tz-cflags)
+CFLAGS-tzset.c += $(tz-cflags)
+CFLAGS-getdate.c += -fexceptions
# Don't warn about Y2k problem in strftime format string.
-CFLAGS-test_time.c = -Wno-format
+CFLAGS-test_time.c += -Wno-format
tst-getdate-ENV= DATEMSK=datemsk TZDIR=${common-objpfx}timezone/testdata
test_time-ARGS= EST5EDT CST
tst-tzname-ENV = TZDIR=${common-objpfx}timezone/testdata
-CPPFLAGS-tst-tzname.c = -DTZDEFRULES='"$(posixrules-file)"'
+CPPFLAGS-tst-tzname.c += -DTZDEFRULES='"$(posixrules-file)"'
bug-getdate1-ARGS = ${objpfx}bug-getdate1-fmt
diff --git a/time/adjtime.c b/time/adjtime.c
index 5114eadf85..4a972d66cd 100644
--- a/time/adjtime.c
+++ b/time/adjtime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/alt_digit.c b/time/alt_digit.c
index 2167be304a..3b78384ddf 100644
--- a/time/alt_digit.c
+++ b/time/alt_digit.c
@@ -1,5 +1,5 @@
/* Helper functions used by strftime/strptime to handle alternate digits.
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -69,7 +69,6 @@ _nl_init_alt_digit (struct __locale_data *current)
}
const char *
-internal_function
_nl_get_alt_digit (unsigned int number, struct __locale_data *current)
{
const char *result;
@@ -95,7 +94,6 @@ _nl_get_alt_digit (unsigned int number, struct __locale_data *current)
const wchar_t *
-internal_function
_nl_get_walt_digit (unsigned int number, struct __locale_data *current)
{
const wchar_t *result = NULL;
@@ -148,7 +146,6 @@ _nl_get_walt_digit (unsigned int number, struct __locale_data *current)
int
-internal_function
_nl_parse_alt_digit (const char **strp, struct __locale_data *current)
{
const char *str = *strp;
diff --git a/time/asctime.c b/time/asctime.c
index 763f12e88e..ed9286f64e 100644
--- a/time/asctime.c
+++ b/time/asctime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/bits/types/clock_t.h b/time/bits/types/clock_t.h
new file mode 100644
index 0000000000..ce97248f88
--- /dev/null
+++ b/time/bits/types/clock_t.h
@@ -0,0 +1,9 @@
+#ifndef __clock_t_defined
+#define __clock_t_defined 1
+
+#include <bits/types.h>
+
+/* Returned by `clock'. */
+typedef __clock_t clock_t;
+
+#endif
diff --git a/time/bits/types/clockid_t.h b/time/bits/types/clockid_t.h
new file mode 100644
index 0000000000..b17c7da853
--- /dev/null
+++ b/time/bits/types/clockid_t.h
@@ -0,0 +1,9 @@
+#ifndef __clockid_t_defined
+#define __clockid_t_defined 1
+
+#include <bits/types.h>
+
+/* Clock ID used in clock and timer functions. */
+typedef __clockid_t clockid_t;
+
+#endif
diff --git a/time/bits/types/struct_itimerspec.h b/time/bits/types/struct_itimerspec.h
new file mode 100644
index 0000000000..17cc1ac86d
--- /dev/null
+++ b/time/bits/types/struct_itimerspec.h
@@ -0,0 +1,14 @@
+#ifndef __itimerspec_defined
+#define __itimerspec_defined 1
+
+#include <bits/types.h>
+#include <bits/types/struct_timespec.h>
+
+/* POSIX.1b structure for timer start values and intervals. */
+struct itimerspec
+ {
+ struct timespec it_interval;
+ struct timespec it_value;
+ };
+
+#endif
diff --git a/time/bits/types/struct_timespec.h b/time/bits/types/struct_timespec.h
new file mode 100644
index 0000000000..5b77c52b4f
--- /dev/null
+++ b/time/bits/types/struct_timespec.h
@@ -0,0 +1,15 @@
+/* NB: Include guard matches what <linux/time.h> uses. */
+#ifndef _STRUCT_TIMESPEC
+#define _STRUCT_TIMESPEC 1
+
+#include <bits/types.h>
+
+/* POSIX.1b structure for a time value. This is like a `struct timeval' but
+ has nanoseconds instead of microseconds. */
+struct timespec
+{
+ __time_t tv_sec; /* Seconds. */
+ __syscall_slong_t tv_nsec; /* Nanoseconds. */
+};
+
+#endif
diff --git a/time/bits/types/struct_timeval.h b/time/bits/types/struct_timeval.h
new file mode 100644
index 0000000000..70394ce886
--- /dev/null
+++ b/time/bits/types/struct_timeval.h
@@ -0,0 +1,13 @@
+#ifndef __timeval_defined
+#define __timeval_defined 1
+
+#include <bits/types.h>
+
+/* A time value that is accurate to the nearest
+ microsecond but also has a range of years. */
+struct timeval
+{
+ __time_t tv_sec; /* Seconds. */
+ __suseconds_t tv_usec; /* Microseconds. */
+};
+#endif
diff --git a/time/bits/types/struct_tm.h b/time/bits/types/struct_tm.h
new file mode 100644
index 0000000000..b13b631228
--- /dev/null
+++ b/time/bits/types/struct_tm.h
@@ -0,0 +1,28 @@
+#ifndef __struct_tm_defined
+#define __struct_tm_defined 1
+
+#include <bits/types.h>
+
+/* ISO C `broken-down time' structure. */
+struct tm
+{
+ int tm_sec; /* Seconds. [0-60] (1 leap second) */
+ int tm_min; /* Minutes. [0-59] */
+ int tm_hour; /* Hours. [0-23] */
+ int tm_mday; /* Day. [1-31] */
+ int tm_mon; /* Month. [0-11] */
+ int tm_year; /* Year - 1900. */
+ int tm_wday; /* Day of week. [0-6] */
+ int tm_yday; /* Days in year.[0-365] */
+ int tm_isdst; /* DST. [-1/0/1]*/
+
+# ifdef __USE_MISC
+ long int tm_gmtoff; /* Seconds east of UTC. */
+ const char *tm_zone; /* Timezone abbreviation. */
+# else
+ long int __tm_gmtoff; /* Seconds east of UTC. */
+ const char *__tm_zone; /* Timezone abbreviation. */
+# endif
+};
+
+#endif
diff --git a/time/bits/types/time_t.h b/time/bits/types/time_t.h
new file mode 100644
index 0000000000..ab8287c6fe
--- /dev/null
+++ b/time/bits/types/time_t.h
@@ -0,0 +1,9 @@
+#ifndef __time_t_defined
+#define __time_t_defined 1
+
+#include <bits/types.h>
+
+/* Returned by `time'. */
+typedef __time_t time_t;
+
+#endif
diff --git a/time/bits/types/timer_t.h b/time/bits/types/timer_t.h
new file mode 100644
index 0000000000..d71a4130e2
--- /dev/null
+++ b/time/bits/types/timer_t.h
@@ -0,0 +1,9 @@
+#ifndef __timer_t_defined
+#define __timer_t_defined 1
+
+#include <bits/types.h>
+
+/* Timer ID returned by `timer_create'. */
+typedef __timer_t timer_t;
+
+#endif
diff --git a/time/bug-getdate1.c b/time/bug-getdate1.c
index 3d68cf2a79..9afafba5be 100644
--- a/time/bug-getdate1.c
+++ b/time/bug-getdate1.c
@@ -3,6 +3,8 @@
#include <stdio.h>
#include <stdlib.h>
+#include <support/temp_file.h>
+
static char *templ_filename;
// Writes template given as parameter to file,
@@ -133,14 +135,18 @@ do_test (int argc, char *argv[])
return res;
}
+#define TEST_FUNCTION_ARGV do_test
-#define PREPARE(argc, argv) \
- if (argc < 2) \
- { \
- puts ("Command line: progname template_filename_full_path"); \
- exit (1); \
- } \
- add_temp_file (argv[1])
+static void
+do_prepare (int argc, char **argv)
+{
+ if (argc < 2)
+ {
+ puts ("Command line: progname template_filename_full_path");
+ exit (1);
+ }
+ add_temp_file (argv[1]);
+}
+#define PREPARE do_prepare
-#define TEST_FUNCTION do_test (argc, argv)
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/time/clock.c b/time/clock.c
index 261abc6278..e5e896c5cb 100644
--- a/time/clock.c
+++ b/time/clock.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/clocktest.c b/time/clocktest.c
index 13b7420e2e..779c05d8d9 100644
--- a/time/clocktest.c
+++ b/time/clocktest.c
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
+#include <stdint.h>
volatile int gotit = 0;
diff --git a/time/ctime.c b/time/ctime.c
index 451d7b9fa9..1222614f29 100644
--- a/time/ctime.c
+++ b/time/ctime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/ctime_r.c b/time/ctime_r.c
index 0fcf9d8e8e..c111146d76 100644
--- a/time/ctime_r.c
+++ b/time/ctime_r.c
@@ -1,5 +1,5 @@
/* Return in BUF representation of time T in form of asctime
- Copyright (C) 1996-2016 Free Software Foundation, Inc.
+ Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
diff --git a/time/difftime.c b/time/difftime.c
index 98850795e3..7c5dd9898b 100644
--- a/time/difftime.c
+++ b/time/difftime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/dysize.c b/time/dysize.c
index 77f67a7ea3..6c511a70f2 100644
--- a/time/dysize.c
+++ b/time/dysize.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/era.c b/time/era.c
index 8c9927419a..4bae7077e1 100644
--- a/time/era.c
+++ b/time/era.c
@@ -1,5 +1,5 @@
/* Helper functions used by strftime/strptime to handle locale-specific "eras".
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -35,7 +35,7 @@ __libc_rwlock_define (extern, __libc_setlocale_lock attribute_hidden)
/* Look up the era information in CURRENT's locale strings and
cache it in CURRENT->private. */
-static void internal_function
+static void
_nl_init_era_entries (struct __locale_data *current)
{
size_t cnt;
@@ -139,7 +139,6 @@ _nl_init_era_entries (struct __locale_data *current)
}
struct era_entry *
-internal_function
_nl_get_era_entry (const struct tm *tp, struct __locale_data *current)
{
if (current->private.time == NULL || !current->private.time->era_initialized)
@@ -166,7 +165,6 @@ _nl_get_era_entry (const struct tm *tp, struct __locale_data *current)
struct era_entry *
-internal_function
_nl_select_era_entry (int cnt, struct __locale_data *current)
{
if (current->private.time == NULL || !current->private.time->era_initialized)
diff --git a/time/ftime.c b/time/ftime.c
index f816fbe667..622c6ce8e8 100644
--- a/time/ftime.c
+++ b/time/ftime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/getdate.c b/time/getdate.c
index 52a0d9e78a..e568149cdf 100644
--- a/time/getdate.c
+++ b/time/getdate.c
@@ -1,5 +1,5 @@
/* Convert a string representation of time to a time value.
- Copyright (C) 1997-2016 Free Software Foundation, Inc.
+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
@@ -198,7 +198,7 @@ __getdate_r (const char *string, struct tm *tp)
if (result && *result == '\0')
break;
}
- while (!feof_unlocked (fp));
+ while (!__feof_unlocked (fp));
free (instr);
@@ -206,7 +206,7 @@ __getdate_r (const char *string, struct tm *tp)
free (line);
/* Check for errors. */
- if (ferror_unlocked (fp))
+ if (__ferror_unlocked (fp))
{
fclose (fp);
return 5;
diff --git a/time/getitimer.c b/time/getitimer.c
index ac1d0d85ad..2ff832f84a 100644
--- a/time/getitimer.c
+++ b/time/getitimer.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/gettimeofday.c b/time/gettimeofday.c
index 87093c92e8..d1ab9acd17 100644
--- a/time/gettimeofday.c
+++ b/time/gettimeofday.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/gmtime.c b/time/gmtime.c
index b3b5d0d4d7..dc33b3e68a 100644
--- a/time/gmtime.c
+++ b/time/gmtime.c
@@ -1,5 +1,5 @@
/* Convert `time_t' to `struct tm' in UTC.
- Copyright (C) 1991-2016 Free Software Foundation, Inc.
+ Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/lc-time-cleanup.c b/time/lc-time-cleanup.c
index c909175915..6fa1024120 100644
--- a/time/lc-time-cleanup.c
+++ b/time/lc-time-cleanup.c
@@ -1,5 +1,5 @@
/* Cleanup code for data structures kept by strftime/strptime helper functions.
- Copyright (C) 2002-2016 Free Software Foundation, Inc.
+ Copyright (C) 2002-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -19,7 +19,7 @@
#include "../locale/localeinfo.h"
#include <stdlib.h>
-void internal_function
+void
_nl_cleanup_time (struct __locale_data *locale)
{
struct lc_time_data *const data = locale->private.time;
diff --git a/time/localtime.c b/time/localtime.c
index 8ec40cf333..8684a8a971 100644
--- a/time/localtime.c
+++ b/time/localtime.c
@@ -1,5 +1,5 @@
/* Convert `time_t' to `struct tm' in local time zone.
- Copyright (C) 1991-2016 Free Software Foundation, Inc.
+ Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/mktime.c b/time/mktime.c
index bc7ed5674b..5f038a212f 100644
--- a/time/mktime.c
+++ b/time/mktime.c
@@ -1,5 +1,5 @@
/* Convert a 'struct tm' to a time_t value.
- Copyright (C) 1993-2016 Free Software Foundation, Inc.
+ Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Paul Eggert <eggert@twinsun.com>.
diff --git a/time/offtime.c b/time/offtime.c
index b540b2f372..04c48389fc 100644
--- a/time/offtime.c
+++ b/time/offtime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/setitimer.c b/time/setitimer.c
index b99117ab44..468f86b6c2 100644
--- a/time/setitimer.c
+++ b/time/setitimer.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/settimeofday.c b/time/settimeofday.c
index f91caf02da..01bf4b032d 100644
--- a/time/settimeofday.c
+++ b/time/settimeofday.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/stime.c b/time/stime.c
index 0522335f00..0378e23888 100644
--- a/time/stime.c
+++ b/time/stime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/strftime.c b/time/strftime.c
index 92150d9205..65dda8ede1 100644
--- a/time/strftime.c
+++ b/time/strftime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/strftime_l.c b/time/strftime_l.c
index 1205035206..c71f9f47a9 100644
--- a/time/strftime_l.c
+++ b/time/strftime_l.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002-2016 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -106,6 +106,7 @@ extern char *tzname[];
# define UCHAR_T unsigned char
# define L_(Str) Str
# define NLW(Sym) Sym
+# define ABALTMON_1 _NL_ABALTMON_1
# if !defined STDC_HEADERS && !defined HAVE_MEMCPY
# define MEMCPY(d, s, n) bcopy ((s), (d), (n))
@@ -284,7 +285,7 @@ static const CHAR_T zeroes[16] = /* "0000000000000000" */
# undef _NL_CURRENT
# define _NL_CURRENT(category, item) \
(current->values[_NL_ITEM_INDEX (item)].string)
-# define LOCALE_PARAM , __locale_t loc
+# define LOCALE_PARAM , locale_t loc
# define LOCALE_ARG , loc
# define HELPER_LOCALE_ARG , current
#else
@@ -492,12 +493,19 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format,
# define f_month \
((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \
? "?" : _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon)))
+# define a_altmonth \
+ ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \
+ ? "?" : _NL_CURRENT (LC_TIME, NLW(ABALTMON_1) + tp->tm_mon)))
+# define f_altmonth \
+ ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \
+ ? "?" : _NL_CURRENT (LC_TIME, NLW(ALTMON_1) + tp->tm_mon)))
# define ampm \
((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11 \
? NLW(PM_STR) : NLW(AM_STR)))
# define aw_len STRLEN (a_wkday)
# define am_len STRLEN (a_month)
+# define aam_len STRLEN (a_altmonth)
# define ap_len STRLEN (ampm)
#else
# if !HAVE_STRFTIME
@@ -507,10 +515,13 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format,
? "?" : month_name[tp->tm_mon])
# define a_wkday f_wkday
# define a_month f_month
+# define a_altmonth a_month
+# define f_altmonth f_month
# define ampm (L_("AMPM") + 2 * (tp->tm_hour > 11))
size_t aw_len = 3;
size_t am_len = 3;
+ size_t aam_len = 3;
size_t ap_len = 2;
# endif
#endif
@@ -715,12 +726,22 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format,
format_char = *f;
switch (format_char)
{
-#define DO_NUMBER(d, v) \
- digits = d > width ? d : width; \
- number_value = v; goto do_number
-#define DO_NUMBER_SPACEPAD(d, v) \
- digits = d > width ? d : width; \
- number_value = v; goto do_number_spacepad
+#define DO_NUMBER(d, v) \
+ do \
+ { \
+ digits = d > width ? d : width; \
+ number_value = v; \
+ goto do_number; \
+ } \
+ while (0)
+#define DO_NUMBER_SPACEPAD(d, v) \
+ do \
+ { \
+ digits = d > width ? d : width; \
+ number_value = v; \
+ goto do_number_spacepad; \
+ } \
+ while (0)
case L_('%'):
if (modifier != 0)
@@ -765,17 +786,20 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format,
to_uppcase = 1;
to_lowcase = 0;
}
- if (modifier != 0)
+ if (modifier == L_('E'))
goto bad_format;
#if defined _NL_CURRENT || !HAVE_STRFTIME
- cpy (am_len, a_month);
+ if (modifier == L_('O'))
+ cpy (aam_len, a_altmonth);
+ else
+ cpy (am_len, a_month);
break;
#else
goto underlying_strftime;
#endif
case L_('B'):
- if (modifier != 0)
+ if (modifier == L_('E'))
goto bad_format;
if (change_case)
{
@@ -783,7 +807,10 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format,
to_lowcase = 0;
}
#if defined _NL_CURRENT || !HAVE_STRFTIME
- cpy (STRLEN (f_month), f_month);
+ if (modifier == L_('O'))
+ cpy (STRLEN (f_altmonth), f_altmonth);
+ else
+ cpy (STRLEN (f_month), f_month);
break;
#else
goto underlying_strftime;
diff --git a/time/strptime.c b/time/strptime.c
index 7e0726fe62..bbc5239aa1 100644
--- a/time/strptime.c
+++ b/time/strptime.c
@@ -1,5 +1,5 @@
/* Convert a string representation of time to a time value.
- Copyright (C) 1996-2016 Free Software Foundation, Inc.
+ Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
diff --git a/time/strptime_l.c b/time/strptime_l.c
index 3a56947127..cd901c2606 100644
--- a/time/strptime_l.c
+++ b/time/strptime_l.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002-2016 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -124,6 +124,10 @@ extern const struct __locale_data _nl_C_LC_TIME attribute_hidden;
(&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABDAY_1)].string)
# define month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (MON_1)].string)
# define ab_month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABMON_1)].string)
+# define alt_month_name \
+ (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ALTMON_1)].string)
+# define ab_alt_month_name \
+ (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (_NL_ABALTMON_1)].string)
# define HERE_D_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_T_FMT)].string)
# define HERE_D_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_FMT)].string)
# define HERE_AM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (AM_STR)].string)
@@ -181,7 +185,7 @@ static const unsigned short int __mon_yday[2][13] =
# undef _NL_CURRENT_WORD
# define _NL_CURRENT_WORD(category, item) \
(current->values[_NL_ITEM_INDEX (item)].word)
-# define LOCALE_PARAM , __locale_t locale
+# define LOCALE_PARAM , locale_t locale
# define LOCALE_ARG , locale
# define HELPER_LOCALE_ARG , current
# define ISSPACE(Ch) __isspace_l (Ch, locale)
@@ -231,7 +235,6 @@ day_of_the_year (struct tm *tm)
#ifdef _LIBC
char *
-internal_function
#else
static char *
#endif
@@ -320,10 +323,9 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp,
while (*fmt >= '0' && *fmt <= '9')
++fmt;
-#ifndef _NL_CURRENT
- /* We need this for handling the `E' modifier. */
+ /* In some cases, modifiers are handled by adjusting state and
+ then restarting the switch statement below. */
start_over:
-#endif
/* Make back up of current processing pointer. */
rp_backup = rp;
@@ -424,13 +426,46 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp,
ab_month_name[cnt]))
decided_longest = loc;
}
+#ifdef _LIBC
+ /* Now check the alt month. */
+ trp = rp;
+ if (match_string (_NL_CURRENT (LC_TIME, ALTMON_1 + cnt), trp)
+ && trp > rp_longest)
+ {
+ rp_longest = trp;
+ cnt_longest = cnt;
+ if (s.decided == not
+ && strcmp (_NL_CURRENT (LC_TIME, ALTMON_1 + cnt),
+ alt_month_name[cnt]))
+ decided_longest = loc;
+ }
+ trp = rp;
+ if (match_string (_NL_CURRENT (LC_TIME, _NL_ABALTMON_1 + cnt),
+ trp)
+ && trp > rp_longest)
+ {
+ rp_longest = trp;
+ cnt_longest = cnt;
+ if (s.decided == not
+ && strcmp (_NL_CURRENT (LC_TIME, _NL_ABALTMON_1 + cnt),
+ alt_month_name[cnt]))
+ decided_longest = loc;
+ }
+#endif
}
#endif
if (s.decided != loc
&& (((trp = rp, match_string (month_name[cnt], trp))
&& trp > rp_longest)
|| ((trp = rp, match_string (ab_month_name[cnt], trp))
- && trp > rp_longest)))
+ && trp > rp_longest)
+#ifdef _LIBC
+ || ((trp = rp, match_string (alt_month_name[cnt], trp))
+ && trp > rp_longest)
+ || ((trp = rp, match_string (ab_alt_month_name[cnt], trp))
+ && trp > rp_longest)
+#endif
+ ))
{
rp_longest = trp;
cnt_longest = cnt;
@@ -1016,6 +1051,12 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp,
case 'O':
switch (*fmt++)
{
+ case 'b':
+ case 'B':
+ case 'h':
+ /* Match month name. Reprocess as plain 'B'. */
+ fmt--;
+ goto start_over;
case 'd':
case 'e':
/* Match day of month using alternate numeric symbols. */
diff --git a/time/sys/time.h b/time/sys/time.h
index 545de6f3d8..4166a5b10f 100644
--- a/time/sys/time.h
+++ b/time/sys/time.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,18 +21,15 @@
#include <features.h>
#include <bits/types.h>
-#define __need_time_t
-#include <time.h>
-#define __need_timeval
-#include <bits/time.h>
-
-#include <sys/select.h>
+#include <bits/types/time_t.h>
+#include <bits/types/struct_timeval.h>
#ifndef __suseconds_t_defined
typedef __suseconds_t suseconds_t;
# define __suseconds_t_defined
#endif
+#include <sys/select.h>
__BEGIN_DECLS
diff --git a/time/sys/timeb.h b/time/sys/timeb.h
index 41d71bf9e9..e9b4a37f1b 100644
--- a/time/sys/timeb.h
+++ b/time/sys/timeb.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,9 +20,7 @@
#include <features.h>
-#define __need_time_t
-#include <time.h>
-
+#include <bits/types/time_t.h>
__BEGIN_DECLS
diff --git a/time/test_time.c b/time/test_time.c
index b0abd68480..4bed27996d 100644
--- a/time/test_time.c
+++ b/time/test_time.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/time.c b/time/time.c
index ec49e990fe..4996d26f13 100644
--- a/time/time.c
+++ b/time/time.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/time.h b/time/time.h
index cc93917b82..4b55e34402 100644
--- a/time/time.h
+++ b/time/time.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,172 +20,55 @@
*/
#ifndef _TIME_H
+#define _TIME_H 1
-#if (! defined __need_time_t && !defined __need_clock_t && \
- ! defined __need_timespec)
-# define _TIME_H 1
-# include <features.h>
+#include <features.h>
-__BEGIN_DECLS
-
-#endif
-
-#ifdef _TIME_H
-/* Get size_t and NULL from <stddef.h>. */
-# define __need_size_t
-# define __need_NULL
-# include <stddef.h>
+#define __need_size_t
+#define __need_NULL
+#include <stddef.h>
/* This defines CLOCKS_PER_SEC, which is the number of processor clock
- ticks per second. */
-# include <bits/time.h>
-
-/* This is the obsolete POSIX.1-1988 name for the same constant. */
-# if !defined __STRICT_ANSI__ && !defined __USE_XOPEN2K
-# ifndef CLK_TCK
-# define CLK_TCK CLOCKS_PER_SEC
-# endif
-# endif
-
-#endif /* <time.h> included. */
-
-#if !defined __clock_t_defined && (defined _TIME_H || defined __need_clock_t)
-# define __clock_t_defined 1
-
-# include <bits/types.h>
-
-__BEGIN_NAMESPACE_STD
-/* Returned by `clock'. */
-typedef __clock_t clock_t;
-__END_NAMESPACE_STD
-#if defined __USE_XOPEN || defined __USE_POSIX
-__USING_NAMESPACE_STD(clock_t)
-#endif
-
-#endif /* clock_t not defined and <time.h> or need clock_t. */
-#undef __need_clock_t
-
-#if !defined __time_t_defined && (defined _TIME_H || defined __need_time_t)
-# define __time_t_defined 1
+ ticks per second, and possibly a number of other constants. */
+#include <bits/time.h>
-# include <bits/types.h>
+/* Many of the typedefs and structs whose official home is this header
+ may also need to be defined by other headers. */
+#include <bits/types/clock_t.h>
+#include <bits/types/time_t.h>
+#include <bits/types/struct_tm.h>
-__BEGIN_NAMESPACE_STD
-/* Returned by `time'. */
-typedef __time_t time_t;
-__END_NAMESPACE_STD
-#ifdef __USE_POSIX
-__USING_NAMESPACE_STD(time_t)
+#if defined __USE_POSIX199309 || defined __USE_ISOC11
+# include <bits/types/struct_timespec.h>
#endif
-#endif /* time_t not defined and <time.h> or need time_t. */
-#undef __need_time_t
-
-#if !defined __clockid_t_defined && \
- ((defined _TIME_H && defined __USE_POSIX199309) || defined __need_clockid_t)
-# define __clockid_t_defined 1
-
-# include <bits/types.h>
-
-/* Clock ID used in clock and timer functions. */
-typedef __clockid_t clockid_t;
-
-#endif /* clockid_t not defined and <time.h> or need clockid_t. */
-#undef __clockid_time_t
-
-#if !defined __timer_t_defined && \
- ((defined _TIME_H && defined __USE_POSIX199309) || defined __need_timer_t)
-# define __timer_t_defined 1
-
-# include <bits/types.h>
-
-/* Timer ID returned by `timer_create'. */
-typedef __timer_t timer_t;
-
-#endif /* timer_t not defined and <time.h> or need timer_t. */
-#undef __need_timer_t
-
-
-#if (!defined __timespec_defined \
- && ((defined _TIME_H \
- && (defined __USE_POSIX199309 \
- || defined __USE_ISOC11)) \
- || defined __need_timespec))
-# define __timespec_defined 1
-
-# include <bits/types.h> /* This defines __time_t for us. */
-
-/* POSIX.1b structure for a time value. This is like a `struct timeval' but
- has nanoseconds instead of microseconds. */
-struct timespec
- {
- __time_t tv_sec; /* Seconds. */
- __syscall_slong_t tv_nsec; /* Nanoseconds. */
- };
-
-#endif /* timespec not defined and <time.h> or need timespec. */
-#undef __need_timespec
-
-
-#ifdef _TIME_H
-__BEGIN_NAMESPACE_STD
-/* Used by other time functions. */
-struct tm
-{
- int tm_sec; /* Seconds. [0-60] (1 leap second) */
- int tm_min; /* Minutes. [0-59] */
- int tm_hour; /* Hours. [0-23] */
- int tm_mday; /* Day. [1-31] */
- int tm_mon; /* Month. [0-11] */
- int tm_year; /* Year - 1900. */
- int tm_wday; /* Day of week. [0-6] */
- int tm_yday; /* Days in year.[0-365] */
- int tm_isdst; /* DST. [-1/0/1]*/
-
-# ifdef __USE_MISC
- long int tm_gmtoff; /* Seconds east of UTC. */
- const char *tm_zone; /* Timezone abbreviation. */
-# else
- long int __tm_gmtoff; /* Seconds east of UTC. */
- const char *__tm_zone; /* Timezone abbreviation. */
-# endif
-};
-__END_NAMESPACE_STD
-#if defined __USE_XOPEN || defined __USE_POSIX
-__USING_NAMESPACE_STD(tm)
-#endif
-
-
-# ifdef __USE_POSIX199309
-/* POSIX.1b structure for timer start values and intervals. */
-struct itimerspec
- {
- struct timespec it_interval;
- struct timespec it_value;
- };
-
-/* We can use a simple forward declaration. */
+#ifdef __USE_POSIX199309
+# include <bits/types/clockid_t.h>
+# include <bits/types/timer_t.h>
+# include <bits/types/struct_itimerspec.h>
struct sigevent;
+#endif
-# endif /* POSIX.1b */
-
-# ifdef __USE_XOPEN2K
-# ifndef __pid_t_defined
+#ifdef __USE_XOPEN2K
+# ifndef __pid_t_defined
typedef __pid_t pid_t;
-# define __pid_t_defined
-# endif
+# define __pid_t_defined
# endif
+#endif
+#ifdef __USE_XOPEN2K8
+# include <bits/types/locale_t.h>
+#endif
-# ifdef __USE_ISOC11
+#ifdef __USE_ISOC11
/* Time base values for timespec_get. */
# define TIME_UTC 1
-# endif
+#endif
+__BEGIN_DECLS
-__BEGIN_NAMESPACE_STD
/* Time used by the program so far (user time + system time).
- The result / CLOCKS_PER_SECOND is program time in seconds. */
+ The result / CLOCKS_PER_SEC is program time in seconds. */
extern clock_t clock (void) __THROW;
/* Return the current time and put it in *TIMER if TIMER is not NULL. */
@@ -205,35 +88,32 @@ extern time_t mktime (struct tm *__tp) __THROW;
extern size_t strftime (char *__restrict __s, size_t __maxsize,
const char *__restrict __format,
const struct tm *__restrict __tp) __THROW;
-__END_NAMESPACE_STD
-# ifdef __USE_XOPEN
+#ifdef __USE_XOPEN
/* Parse S according to FORMAT and store binary time information in TP.
The return value is a pointer to the first unparsed character in S. */
extern char *strptime (const char *__restrict __s,
const char *__restrict __fmt, struct tm *__tp)
__THROW;
-# endif
+#endif
-# ifdef __USE_XOPEN2K8
+#ifdef __USE_XOPEN2K8
/* Similar to the two functions above but take the information from
the provided locale and not the global locale. */
-# include <xlocale.h>
extern size_t strftime_l (char *__restrict __s, size_t __maxsize,
const char *__restrict __format,
const struct tm *__restrict __tp,
- __locale_t __loc) __THROW;
-# endif
+ locale_t __loc) __THROW;
+#endif
-# ifdef __USE_GNU
+#ifdef __USE_GNU
extern char *strptime_l (const char *__restrict __s,
const char *__restrict __fmt, struct tm *__tp,
- __locale_t __loc) __THROW;
-# endif
+ locale_t __loc) __THROW;
+#endif
-__BEGIN_NAMESPACE_STD
/* Return the `struct tm' representation of *TIMER
in Universal Coordinated Time (aka Greenwich Mean Time). */
extern struct tm *gmtime (const time_t *__timer) __THROW;
@@ -241,9 +121,8 @@ extern struct tm *gmtime (const time_t *__timer) __THROW;
/* Return the `struct tm' representation
of *TIMER in the local timezone. */
extern struct tm *localtime (const time_t *__timer) __THROW;
-__END_NAMESPACE_STD
-# ifdef __USE_POSIX
+#ifdef __USE_POSIX
/* Return the `struct tm' representation of *TIMER in UTC,
using *TP to store the result. */
extern struct tm *gmtime_r (const time_t *__restrict __timer,
@@ -253,18 +132,16 @@ extern struct tm *gmtime_r (const time_t *__restrict __timer,
using *TP to store the result. */
extern struct tm *localtime_r (const time_t *__restrict __timer,
struct tm *__restrict __tp) __THROW;
-# endif /* POSIX */
+#endif /* POSIX */
-__BEGIN_NAMESPACE_STD
/* Return a string of the form "Day Mon dd hh:mm:ss yyyy\n"
that is the representation of TP in this format. */
extern char *asctime (const struct tm *__tp) __THROW;
/* Equivalent to `asctime (localtime (timer))'. */
extern char *ctime (const time_t *__timer) __THROW;
-__END_NAMESPACE_STD
-# ifdef __USE_POSIX
+#ifdef __USE_POSIX
/* Reentrant versions of the above functions. */
/* Return in BUF a string of the form "Day Mon dd hh:mm:ss yyyy\n"
@@ -275,7 +152,7 @@ extern char *asctime_r (const struct tm *__restrict __tp,
/* Equivalent to `asctime_r (localtime_r (timer, *TMP*), buf)'. */
extern char *ctime_r (const time_t *__restrict __timer,
char *__restrict __buf) __THROW;
-# endif /* POSIX */
+#endif /* POSIX */
/* Defined in localtime.c. */
@@ -284,34 +161,34 @@ extern int __daylight; /* If daylight-saving time is ever in use. */
extern long int __timezone; /* Seconds west of UTC. */
-# ifdef __USE_POSIX
+#ifdef __USE_POSIX
/* Same as above. */
extern char *tzname[2];
/* Set time conversion information from the TZ environment variable.
If TZ is not defined, a locale-dependent default is used. */
extern void tzset (void) __THROW;
-# endif
+#endif
-# if defined __USE_MISC || defined __USE_XOPEN
+#if defined __USE_MISC || defined __USE_XOPEN
extern int daylight;
extern long int timezone;
-# endif
+#endif
-# ifdef __USE_MISC
+#ifdef __USE_MISC
/* Set the system time to *WHEN.
This call is restricted to the superuser. */
extern int stime (const time_t *__when) __THROW;
-# endif
+#endif
/* Nonzero if YEAR is a leap year (every 4 years,
except every 100th isn't, and every 400th is). */
-# define __isleap(year) \
+#define __isleap(year) \
((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
-# ifdef __USE_MISC
+#ifdef __USE_MISC
/* Miscellaneous functions many Unices inherited from the public domain
localtime package. These are included only for compatibility. */
@@ -323,10 +200,10 @@ extern time_t timelocal (struct tm *__tp) __THROW;
/* Return the number of days in YEAR. */
extern int dysize (int __year) __THROW __attribute__ ((__const__));
-# endif
+#endif
-# ifdef __USE_POSIX199309
+#ifdef __USE_POSIX199309
/* Pause execution for a number of nanoseconds.
This function is a cancellation point and therefore not marked with
@@ -345,7 +222,7 @@ extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
__THROW;
-# ifdef __USE_XOPEN2K
+# ifdef __USE_XOPEN2K
/* High-resolution sleep with the specified clock.
This function is a cancellation point and therefore not marked with
@@ -356,7 +233,7 @@ extern int clock_nanosleep (clockid_t __clock_id, int __flags,
/* Return clock ID for CPU-time clock. */
extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __THROW;
-# endif
+# endif
/* Create new per-process timer using CLOCK_ID. */
@@ -378,17 +255,17 @@ extern int timer_gettime (timer_t __timerid, struct itimerspec *__value)
/* Get expiration overrun for timer TIMERID. */
extern int timer_getoverrun (timer_t __timerid) __THROW;
-# endif
+#endif
-# ifdef __USE_ISOC11
+#ifdef __USE_ISOC11
/* Set TS to calendar time based in time base BASE. */
extern int timespec_get (struct timespec *__ts, int __base)
__THROW __nonnull ((1));
-# endif
+#endif
-# ifdef __USE_XOPEN_EXTENDED
+#ifdef __USE_XOPEN_EXTENDED
/* Set to one of the following values to indicate an error.
1 the DATEMSK environment variable is null or undefined,
2 the template file cannot be opened for reading,
@@ -410,9 +287,9 @@ extern int getdate_err;
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern struct tm *getdate (const char *__string);
-# endif
+#endif
-# ifdef __USE_GNU
+#ifdef __USE_GNU
/* Since `getdate' is not reentrant because of the use of `getdate_err'
and the static buffer to return the result in, we provide a thread-safe
variant. The functionality is the same. The result is returned in
@@ -425,10 +302,8 @@ extern struct tm *getdate (const char *__string);
therefore not marked with __THROW. */
extern int getdate_r (const char *__restrict __string,
struct tm *__restrict __resbufp);
-# endif
+#endif
__END_DECLS
-#endif /* <time.h> included. */
-
-#endif /* <time.h> not already included. */
+#endif /* time.h. */
diff --git a/time/timegm.c b/time/timegm.c
index c5656e84dc..fb720e2d7d 100644
--- a/time/timegm.c
+++ b/time/timegm.c
@@ -1,6 +1,6 @@
/* Convert UTC calendar time to simple time. Like mktime but assumes UTC.
- Copyright (C) 1994-2016 Free Software Foundation, Inc.
+ Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/timespec_get.c b/time/timespec_get.c
index fb9cc07a87..50843f9b58 100644
--- a/time/timespec_get.c
+++ b/time/timespec_get.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2016 Free Software Foundation, Inc.
+/* Copyright (C) 2011-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/tst-ftime.c b/time/tst-ftime.c
index 9b8cb7856d..74e6d1cea3 100644
--- a/time/tst-ftime.c
+++ b/time/tst-ftime.c
@@ -1,5 +1,5 @@
/* Verify that ftime is sane.
- Copyright (C) 2014-2016 Free Software Foundation, Inc.
+ Copyright (C) 2014-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/tst-getdate.c b/time/tst-getdate.c
index 7709acdc1c..53843602b1 100644
--- a/time/tst-getdate.c
+++ b/time/tst-getdate.c
@@ -1,5 +1,5 @@
/* Test for getdate.
- Copyright (C) 2000-2016 Free Software Foundation, Inc.
+ Copyright (C) 2000-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Andreas Jaeger <aj@suse.de>, 2000.
diff --git a/time/tst-posixtz.c b/time/tst-posixtz.c
index 16aa19d654..9bec7ae4bb 100644
--- a/time/tst-posixtz.c
+++ b/time/tst-posixtz.c
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include <stdint.h>
struct
{
diff --git a/time/tst-strptime-whitespace.c b/time/tst-strptime-whitespace.c
index f1442de8e8..6cfcc2f806 100644
--- a/time/tst-strptime-whitespace.c
+++ b/time/tst-strptime-whitespace.c
@@ -1,6 +1,6 @@
/* Verify that strptime accepts arbitrary whitespace between tokens.
- Copyright (C) 2013-2016 Free Software Foundation, Inc.
+ Copyright (C) 2013-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/tst-strptime.c b/time/tst-strptime.c
index 3b94c2eb53..441e04b454 100644
--- a/time/tst-strptime.c
+++ b/time/tst-strptime.c
@@ -1,5 +1,5 @@
/* Test for strptime.
- Copyright (C) 1998-2016 Free Software Foundation, Inc.
+ Copyright (C) 1998-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -51,6 +51,28 @@ static const struct
6, 0, 0, 1 },
{ "ja_JP.EUC-JP", "2001 20 \xb7\xee", "%Y %U %a", 1, 140, 4, 21 },
{ "ja_JP.EUC-JP", "2001 21 \xb7\xee", "%Y %W %a", 1, 140, 4, 21 },
+ /* Most of the languages do not need the declension of the month names
+ and do not distinguish between %B and %OB. */
+ { "en_US.ISO-8859-1", "November 17, 2017", "%B %e, %Y", 5, 320, 10, 17 },
+ { "de_DE.ISO-8859-1", "18. Nov 2017", "%d. %b %Y", 6, 321, 10, 18 },
+ { "fr_FR.UTF-8", "19 novembre 2017", "%d %OB %Y", 0, 322, 10, 19 },
+ { "es_ES.UTF-8", "20 de nov de 2017", "%d de %Ob de %Y", 1, 323, 10, 20 },
+ /* Some languages do need the declension of the month names. */
+ { "pl_PL.UTF-8", "21 lis 2017", "%d %b %Y", 2, 324, 10, 21 },
+ { "pl_PL.UTF-8", "22 LIS 2017", "%d %B %Y", 3, 325, 10, 22 },
+ { "pl_PL.UTF-8", "23 listopada 2017", "%d %B %Y", 4, 326, 10, 23 },
+ /* The nominative case is incorrect here but it is parseable. */
+ { "pl_PL.UTF-8", "24 listopad 2017", "%d %OB %Y", 5, 327, 10, 24 },
+ { "pl_PL.UTF-8", "25 lis 2017", "%d %Ob %Y", 6, 328, 10, 25 },
+ /* ноя - pronounce: 'noya' - "Nov" (abbreviated "November") in Russian. */
+ { "ru_RU.UTF-8", "26 ноя 2017", "%d %b %Y", 0, 329, 10, 26 },
+ /* мая - pronounce: 'maya' - "of May" (the genitive case, both full and
+ abbreviated) in Russian. */
+ { "ru_RU.UTF-8", "19 мая 2018", "%d %b %Y", 6, 138, 4, 19 },
+ /* май - pronounce: 'may' - "May" (the nominative case, both full and
+ abbreviated) in Russian.
+ The nominative case is incorrect here but it is parseable. */
+ { "ru_RU.UTF-8", "20 май 2018", "%d %Ob %Y", 0, 139, 4, 20 },
};
diff --git a/time/tst-strptime2.c b/time/tst-strptime2.c
index 7fe7350024..8019e7f5d8 100644
--- a/time/tst-strptime2.c
+++ b/time/tst-strptime2.c
@@ -4,6 +4,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <time.h>
+#include <libc-diag.h>
/* Dummy string is used to match strptime's %s specifier. */
@@ -67,10 +68,20 @@ mkbuf (char *buf, bool neg, bool colon, unsigned int hhmm, size_t ndigits)
long int expect = LONG_MAX;
i = sprintf (buf, "%s %c", dummy_string, sign);
+#if __GNUC_PREREQ (7, 0)
+ /* GCC issues a warning when it thinks the snprintf buffer may be too short.
+ This test is explicitly using short buffers to force snprintf to truncate
+ the output so we ignore the warnings. */
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (7.0, "-Wformat-truncation");
+#endif
if (colon)
snprintf (buf + i, ndigits + 2, "%02u:%02u", hh, mm);
else
snprintf (buf + i, ndigits + 1, "%04u", hhmm);
+#if __GNUC_PREREQ (7, 0)
+ DIAG_POP_NEEDS_COMMENT;
+#endif
if (mm <= mm_max && (ndigits == 2 || ndigits == 4))
{
diff --git a/time/tst-tzname.c b/time/tst-tzname.c
index ea7ec927b2..f3c3757060 100644
--- a/time/tst-tzname.c
+++ b/time/tst-tzname.c
@@ -1,5 +1,5 @@
/* Test that tzset sets tzname correctly (BZ #19253).
- Copyright (C) 2015 Free Software Foundation, Inc.
+ Copyright (C) 2015-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/tst-y2039.c b/time/tst-y2039.c
new file mode 100644
index 0000000000..cdc6bca54b
--- /dev/null
+++ b/time/tst-y2039.c
@@ -0,0 +1,46 @@
+/* Test for localtime bug in year 2039 (bug 22639).
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <time.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <support/check.h>
+
+static int
+do_test (void)
+{
+ TEST_VERIFY_EXIT (setenv ("TZ", "PST8PDT,M3.2.0,M11.1.0", 1) == 0);
+ tzset ();
+ if (sizeof (time_t) > 4)
+ {
+ time_t ouch = (time_t) 2187810000LL;
+ char buf[500];
+ struct tm *tm = localtime (&ouch);
+ TEST_VERIFY_EXIT (tm != NULL);
+ TEST_VERIFY_EXIT (strftime (buf, sizeof buf, "%Y-%m-%d %H:%M:%S %Z", tm)
+ > 0);
+ puts (buf);
+ TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
+ }
+ else
+ FAIL_UNSUPPORTED ("32-bit time_t");
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/time/tzfile.c b/time/tzfile.c
index 9049878399..2a385b92bc 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -26,7 +26,6 @@
#include <sys/stat.h>
#include <stdint.h>
-#define NOID
#include <timezone/tzfile.h>
int __use_tzfile;
@@ -45,14 +44,12 @@ struct ttinfo
struct leap
{
- time_t transition; /* Time the transition takes effect. */
+ internal_time_t transition; /* Time the transition takes effect. */
long int change; /* Seconds of correction to apply. */
};
-static void compute_tzname_max (size_t) internal_function;
-
static size_t num_transitions;
-libc_freeres_ptr (static time_t *transitions);
+libc_freeres_ptr (static internal_time_t *transitions);
static unsigned char *type_idxs;
static size_t num_types;
static struct ttinfo *types;
@@ -116,8 +113,8 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
size_t tzspec_len;
char *new = NULL;
- if (sizeof (time_t) != 4 && sizeof (time_t) != 8)
- abort ();
+ _Static_assert (sizeof (internal_time_t) == 8,
+ "internal_time_t must be eight bytes");
__use_tzfile = 0;
@@ -203,9 +200,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
if (__glibc_unlikely (num_isstd > num_types || num_isgmt > num_types))
goto lose;
- /* For platforms with 64-bit time_t we use the new format if available. */
- if (sizeof (time_t) == 8 && trans_width == 4
- && tzhead.tzh_version[0] != '\0')
+ if (trans_width == 4 && tzhead.tzh_version[0] != '\0')
{
/* We use the 8-byte format. */
trans_width = 8;
@@ -225,9 +220,9 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
if (__builtin_expect (num_transitions
> ((SIZE_MAX - (__alignof__ (struct ttinfo) - 1))
- / (sizeof (time_t) + 1)), 0))
+ / (sizeof (internal_time_t) + 1)), 0))
goto lose;
- total_size = num_transitions * (sizeof (time_t) + 1);
+ total_size = num_transitions * (sizeof (internal_time_t) + 1);
total_size = ((total_size + __alignof__ (struct ttinfo) - 1)
& ~(__alignof__ (struct ttinfo) - 1));
types_idx = total_size;
@@ -249,7 +244,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
goto lose;
total_size += num_leaps * sizeof (struct leap);
tzspec_len = 0;
- if (sizeof (time_t) == 8 && trans_width == 8)
+ if (trans_width == 8)
{
off_t rem = st.st_size - __ftello (f);
if (__builtin_expect (rem < 0
@@ -279,23 +274,23 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
/* Allocate enough memory including the extra block requested by the
caller. */
- transitions = (time_t *) malloc (total_size + tzspec_len + extra);
+ transitions = malloc (total_size + tzspec_len + extra);
if (transitions == NULL)
goto lose;
type_idxs = (unsigned char *) transitions + (num_transitions
- * sizeof (time_t));
+ * sizeof (internal_time_t));
types = (struct ttinfo *) ((char *) transitions + types_idx);
zone_names = (char *) types + num_types * sizeof (struct ttinfo);
leaps = (struct leap *) ((char *) transitions + leaps_idx);
- if (sizeof (time_t) == 8 && trans_width == 8)
+ if (trans_width == 8)
tzspec = (char *) leaps + num_leaps * sizeof (struct leap) + extra;
else
tzspec = NULL;
if (extra > 0)
*extrap = (char *) &leaps[num_leaps];
- if (sizeof (time_t) == 4 || __builtin_expect (trans_width == 8, 1))
+ if (__builtin_expect (trans_width == 8, 1))
{
if (__builtin_expect (__fread_unlocked (transitions, trans_width + 1,
num_transitions, f)
@@ -318,19 +313,17 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
if (__glibc_unlikely (type_idxs[i] >= num_types))
goto lose;
- if ((BYTE_ORDER != BIG_ENDIAN && (sizeof (time_t) == 4 || trans_width == 4))
- || (BYTE_ORDER == BIG_ENDIAN && sizeof (time_t) == 8
- && trans_width == 4))
+ if (trans_width == 4)
{
/* Decode the transition times, stored as 4-byte integers in
- network (big-endian) byte order. We work from the end of
- the array so as not to clobber the next element to be
- processed when sizeof (time_t) > 4. */
+ network (big-endian) byte order. We work from the end of the
+ array so as not to clobber the next element to be
+ processed. */
i = num_transitions;
while (i-- > 0)
transitions[i] = decode ((char *) transitions + i * 4);
}
- else if (BYTE_ORDER != BIG_ENDIAN && sizeof (time_t) == 8)
+ else if (BYTE_ORDER != BIG_ENDIAN)
{
/* Decode the transition times, stored as 8-byte integers in
network (big-endian) byte order. */
@@ -346,11 +339,11 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
sizeof (x), f) != sizeof (x),
0))
goto lose;
- c = getc_unlocked (f);
+ c = __getc_unlocked (f);
if (__glibc_unlikely ((unsigned int) c > 1u))
goto lose;
types[i].isdst = c;
- c = getc_unlocked (f);
+ c = __getc_unlocked (f);
if (__glibc_unlikely ((size_t) c > chars))
/* Bogus index in data file. */
goto lose;
@@ -367,10 +360,10 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
if (__builtin_expect (__fread_unlocked (x, 1, trans_width, f)
!= trans_width, 0))
goto lose;
- if (sizeof (time_t) == 4 || trans_width == 4)
- leaps[i].transition = (time_t) decode (x);
+ if (trans_width == 4)
+ leaps[i].transition = decode (x);
else
- leaps[i].transition = (time_t) decode64 (x);
+ leaps[i].transition = decode64 (x);
if (__glibc_unlikely (__fread_unlocked (x, 1, 4, f) != 4))
goto lose;
@@ -379,7 +372,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
for (i = 0; i < num_isstd; ++i)
{
- int c = getc_unlocked (f);
+ int c = __getc_unlocked (f);
if (__glibc_unlikely (c == EOF))
goto lose;
types[i].isstd = c != 0;
@@ -389,7 +382,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
for (i = 0; i < num_isgmt; ++i)
{
- int c = getc_unlocked (f);
+ int c = __getc_unlocked (f);
if (__glibc_unlikely (c == EOF))
goto lose;
types[i].isgmt = c != 0;
@@ -398,62 +391,16 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
types[i++].isgmt = 0;
/* Read the POSIX TZ-style information if possible. */
- if (sizeof (time_t) == 8 && tzspec != NULL)
+ if (tzspec != NULL)
{
/* Skip over the newline first. */
- if (getc_unlocked (f) != '\n'
+ if (__getc_unlocked (f) != '\n'
|| (__fread_unlocked (tzspec, 1, tzspec_len - 1, f)
!= tzspec_len - 1))
tzspec = NULL;
else
tzspec[tzspec_len - 1] = '\0';
}
- else if (sizeof (time_t) == 4 && tzhead.tzh_version[0] != '\0')
- {
- /* Get the TZ string. */
- if (__builtin_expect (__fread_unlocked ((void *) &tzhead,
- sizeof (tzhead), 1, f) != 1, 0)
- || (memcmp (tzhead.tzh_magic, TZ_MAGIC, sizeof (tzhead.tzh_magic))
- != 0))
- goto lose;
-
- size_t num_transitions2 = (size_t) decode (tzhead.tzh_timecnt);
- size_t num_types2 = (size_t) decode (tzhead.tzh_typecnt);
- size_t chars2 = (size_t) decode (tzhead.tzh_charcnt);
- size_t num_leaps2 = (size_t) decode (tzhead.tzh_leapcnt);
- size_t num_isstd2 = (size_t) decode (tzhead.tzh_ttisstdcnt);
- size_t num_isgmt2 = (size_t) decode (tzhead.tzh_ttisgmtcnt);
-
- /* Position the stream before the second header. */
- size_t to_skip = (num_transitions2 * (8 + 1)
- + num_types2 * 6
- + chars2
- + num_leaps2 * 12
- + num_isstd2
- + num_isgmt2);
- off_t off;
- if (fseek (f, to_skip, SEEK_CUR) != 0
- || (off = __ftello (f)) < 0
- || st.st_size < off + 2)
- goto lose;
-
- tzspec_len = st.st_size - off - 1;
- if (tzspec_len == 0)
- goto lose;
- char *tzstr = malloc (tzspec_len);
- if (tzstr == NULL)
- goto lose;
- if (getc_unlocked (f) != '\n'
- || (__fread_unlocked (tzstr, 1, tzspec_len - 1, f)
- != tzspec_len - 1))
- {
- free (tzstr);
- goto lose;
- }
- tzstr[tzspec_len - 1] = '\0';
- tzspec = __tzstring (tzstr);
- free (tzstr);
- }
/* Don't use an empty TZ string. */
if (tzspec != NULL && tzspec[0] == '\0')
@@ -495,8 +442,6 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
if (__tzname[1] == NULL)
__tzname[1] = __tzname[0];
- compute_tzname_max (chars);
-
if (num_transitions == 0)
/* Use the first rule (which should also be the only one). */
rule_stdoff = rule_dstoff = types[0].offset;
@@ -627,8 +572,6 @@ __tzfile_default (const char *std, const char *dst,
/* Set the timezone. */
__timezone = -types[0].offset;
- compute_tzname_max (stdlen + dstlen);
-
/* Invalidate the tzfile attribute cache to force rereading
TZDEFRULES the next time it is used. */
tzfile_dev = 0;
@@ -637,7 +580,7 @@ __tzfile_default (const char *std, const char *dst,
}
void
-__tzfile_compute (time_t timer, int use_localtime,
+__tzfile_compute (internal_time_t timer, int use_localtime,
long int *leap_correct, int *leap_hit,
struct tm *tp)
{
@@ -692,10 +635,16 @@ __tzfile_compute (time_t timer, int use_localtime,
/* Convert to broken down structure. If this fails do not
use the string. */
- if (__glibc_unlikely (! __offtime (&timer, 0, tp)))
- goto use_last;
-
- /* Use the rules from the TZ string to compute the change. */
+ {
+ time_t truncated = timer;
+ if (__glibc_unlikely (truncated != timer
+ || ! __offtime (&truncated, 0, tp)))
+ goto use_last;
+ }
+
+ /* Use the rules from the TZ string to compute the change.
+ timer fits into time_t due to the truncation check
+ above. */
__tz_compute (timer, tp, 1);
/* If tzspec comes from posixrules loaded by __tzfile_default,
@@ -716,10 +665,12 @@ __tzfile_compute (time_t timer, int use_localtime,
then pick the type of the transition before it. */
size_t lo = 0;
size_t hi = num_transitions - 1;
- /* Assume that DST is changing twice a year and guess initial
- search spot from it.
- Half of a gregorian year has on average 365.2425 * 86400 / 2
- = 15778476 seconds. */
+ /* Assume that DST is changing twice a year and guess
+ initial search spot from it. Half of a gregorian year
+ has on average 365.2425 * 86400 / 2 = 15778476 seconds.
+ The value i can be truncated if size_t is smaller than
+ internal_time_t, but this is harmless because it is just
+ a guess. */
i = (transitions[num_transitions - 1] - timer) / 15778476;
if (i < num_transitions)
{
@@ -837,21 +788,3 @@ __tzfile_compute (time_t timer, int use_localtime,
}
}
}
-
-static void
-internal_function
-compute_tzname_max (size_t chars)
-{
- const char *p;
-
- p = zone_names;
- do
- {
- const char *start = p;
- while (*p != '\0')
- ++p;
- if ((size_t) (p - start) > __tzname_cur_max)
- __tzname_cur_max = p - start;
- }
- while (++p < &zone_names[chars]);
-}
diff --git a/time/tzset.c b/time/tzset.c
index f65116ce24..a828b9fb75 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -25,10 +25,10 @@
#include <string.h>
#include <time.h>
-
-#define NOID
#include <timezone/tzfile.h>
+#define SECSPERDAY ((time_t) 86400)
+
char *__tzname[2] = { (char *) "GMT", (char *) "GMT" };
int __daylight = 0;
long int __timezone = 0L;
@@ -40,12 +40,6 @@ weak_alias (__timezone, timezone)
/* This locks all the state variables in tzfile.c and this file. */
__libc_lock_define_initialized (static, tzset_lock)
-
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#define max(a, b) ((a) > (b) ? (a) : (b))
-#define sign(x) ((x) < 0 ? -1 : 1)
-
-
/* This structure contains all the information about a
timezone given in the POSIX standard TZ envariable. */
typedef struct
@@ -69,9 +63,8 @@ typedef struct
static tz_rule tz_rules[2];
-static void compute_change (tz_rule *rule, int year) __THROW internal_function;
-static void tzset_internal (int always, int explicit)
- __THROW internal_function;
+static void compute_change (tz_rule *rule, int year) __THROW;
+static void tzset_internal (int always);
/* List of buffers containing time zone strings. */
struct tzstring_l
@@ -128,50 +121,29 @@ __tzstring (const char *s)
{
return __tzstring_len (s, strlen (s));
}
-
-/* Maximum length of a timezone name. tzset_internal keeps this up to date
- (never decreasing it) when ! __use_tzfile.
- tzfile.c keeps it up to date when __use_tzfile. */
-size_t __tzname_cur_max;
-
-long int
-__tzname_max (void)
-{
- __libc_lock_lock (tzset_lock);
-
- tzset_internal (0, 0);
-
- __libc_lock_unlock (tzset_lock);
- return __tzname_cur_max;
-}
-
static char *old_tz;
static void
-internal_function
update_vars (void)
{
__daylight = tz_rules[0].offset != tz_rules[1].offset;
__timezone = -tz_rules[0].offset;
__tzname[0] = (char *) tz_rules[0].name;
__tzname[1] = (char *) tz_rules[1].name;
-
- /* Keep __tzname_cur_max up to date. */
- size_t len0 = strlen (__tzname[0]);
- size_t len1 = strlen (__tzname[1]);
- if (len0 > __tzname_cur_max)
- __tzname_cur_max = len0;
- if (len1 > __tzname_cur_max)
- __tzname_cur_max = len1;
}
static unsigned int
-__attribute_noinline__
compute_offset (unsigned int ss, unsigned int mm, unsigned int hh)
{
- return min (ss, 59) + min (mm, 59) * 60 + min (hh, 24) * 60 * 60;
+ if (ss > 59)
+ ss = 59;
+ if (mm > 59)
+ mm = 59;
+ if (hh > 24)
+ hh = 24;
+ return ss + mm * 60 + hh * 60 * 60;
}
/* Parses the time zone name at *TZP, and writes a pointer to an
@@ -393,8 +365,7 @@ __tzset_parse_tz (const char *tz)
/* Interpret the TZ envariable. */
static void
-internal_function
-tzset_internal (int always, int explicit)
+tzset_internal (int always)
{
static int is_initialized;
const char *tz;
@@ -405,12 +376,6 @@ tzset_internal (int always, int explicit)
/* Examine the TZ environment variable. */
tz = getenv ("TZ");
- if (tz == NULL && !explicit)
- /* Use the site-wide default. This is a file name which means we
- would not see changes to the file if we compare only the file
- name for change. We want to notice file changes if tzset() has
- been called explicitly. Leave TZ as NULL in this case. */
- tz = TZDEFAULT;
if (tz && *tz == '\0')
/* User specified the empty string; use UTC explicitly. */
tz = "Universal";
@@ -463,7 +428,6 @@ tzset_internal (int always, int explicit)
when the change described by RULE will occur and
put it in RULE->change, saving YEAR in RULE->computed_for. */
static void
-internal_function
compute_change (tz_rule *rule, int year)
{
time_t t;
@@ -552,7 +516,6 @@ compute_change (tz_rule *rule, int year)
/* Figure out the correct timezone for TM and set `__tzname',
`__timezone', and `__daylight' accordingly. */
void
-internal_function
__tz_compute (time_t timer, struct tm *tm, int use_localtime)
{
compute_change (&tz_rules[0], 1900 + tm->tm_year);
@@ -586,7 +549,7 @@ __tzset (void)
{
__libc_lock_lock (tzset_lock);
- tzset_internal (1, 1);
+ tzset_internal (1);
if (!__use_tzfile)
{
@@ -618,7 +581,7 @@ __tz_convert (const time_t *timer, int use_localtime, struct tm *tp)
/* Update internal database according to current TZ setting.
POSIX.1 8.3.7.2 says that localtime_r is not required to set tzname.
This is a good idea since this allows at least a bit more parallelism. */
- tzset_internal (tp == &_tmbuf && use_localtime, 1);
+ tzset_internal (tp == &_tmbuf && use_localtime);
if (__use_tzfile)
__tzfile_compute (*timer, use_localtime, &leap_correction,
diff --git a/time/wcsftime.c b/time/wcsftime.c
index a8f06f1d62..5a3afeabfc 100644
--- a/time/wcsftime.c
+++ b/time/wcsftime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/time/wcsftime_l.c b/time/wcsftime_l.c
index f7714174a7..b667893b71 100644
--- a/time/wcsftime_l.c
+++ b/time/wcsftime_l.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002-2016 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or