+2017-03-07 Florian Weimer <fweimer@redhat.com>
+
+ [BZ #15576]
+ Remove TZNAME_MAX limit from sysconf.
+ * include/time.h (__tzname_cur_max, __tzname_max): Remove
+ declaration.
+ * time/tzfile.c (__tzfile_read, __tzfile_default): Do not call
+ compute_tzname_max.
+ (compute_tzname_max): Remove.
+ * time/tzset.c (__tzname_cur_max, __tzname_max): Remove.
+ (update_vars): Do not update __tzname_cur_max.
+ (tzset_internal): Remove argument.
+ (__tzset): Adjust call to tzset_internal.
+ (__tz_convert): Likewise.
+ * posix/sysconf.c (__sysconf): Return -1 for _SC_TZNAME_MAX.
+ * sysdeps/posix/sysconf.c (__sysconf): Likewise.
+ * manual/conf.texi (Sysconf Definition): Update comment.
+
2017-03-07 Siddhesh Poyarekar <siddhesh@sourceware.org>
[BZ #21209]
/* Defined in tzset.c. */
extern char *__tzstring (const char *string);
-/* Defined in tzset.c. */
-extern size_t __tzname_cur_max attribute_hidden;
-
-
extern int __use_tzfile attribute_hidden;
extern void __tzfile_read (const char *file, size_t extra,
/* Prototype for the internal function to get information based on TZ. */
extern struct tm *__tz_convert (const time_t *timer, int use_localtime, struct tm *tp);
-/* Return the maximum length of a timezone name.
- This is what `sysconf (_SC_TZNAME_MAX)' does. */
-extern long int __tzname_max (void);
-
extern int __nanosleep (const struct timespec *__requested_time,
struct timespec *__remaining);
libc_hidden_proto (__nanosleep)
@safety{@prelim{}@mtsafe{@mtsenv{}}@asunsafe{@asulock{} @ascuheap{}}@acunsafe{@aculock{} @acsmem{} @acsfd{}}}
@c Some parts of the implementation open /proc and /sys files and dirs
@c to collect system details, using fd and stream I/O depending on the
-@c case. _SC_TZNAME_MAX calls __tzname_max, that (while holding a lock)
-@c calls tzset_internal, that calls getenv if it's called the first
-@c time; there are free and strdup calls in there too. The returned max
-@c value may change over time for TZNAME_MAX, depending on selected
-@c timezones; NPROCS, NPROCS_CONF, PHYS_PAGES, AVPHYS_PAGES,
-@c NGROUPS_MAX, SIGQUEUE_MAX, depending on variable values read from
-@c /proc at each call, and from rlimit-obtained values CHILD_MAX,
-@c OPEN_MAX, ARG_MAX, SIGQUEUE_MAX.
+@c case. The returned max value may change over time for NPROCS,
+@c NPROCS_CONF, PHYS_PAGES, AVPHYS_PAGES, NGROUPS_MAX, SIGQUEUE_MAX,
+@c depending on variable values read from /proc at each call, and from
+@c rlimit-obtained values CHILD_MAX, OPEN_MAX, ARG_MAX, SIGQUEUE_MAX.
This function is used to inquire about runtime system parameters. The
@var{parameter} argument should be one of the @samp{_SC_} symbols listed
below.
return -1;
case _SC_TZNAME_MAX:
- return MAX (__tzname_max (), _POSIX_TZNAME_MAX);
+ return -1;
case _SC_CHARCLASS_NAME_MAX:
#ifdef CHARCLASS_NAME_MAX
#endif
case _SC_TZNAME_MAX:
- return MAX (__tzname_max (), _POSIX_TZNAME_MAX);
+ return -1;
case _SC_JOB_CONTROL:
#if CONF_IS_DEFINED_SET (_POSIX_JOB_CONTROL)
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);
static unsigned char *type_idxs;
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;
/* 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;
}
}
}
-\f
-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]);
-}
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 tzset_internal (int always);
\f
/* List of buffers containing time zone strings. */
struct tzstring_l
{
return __tzstring_len (s, strlen (s));
}
-\f
-/* 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;
-}
-\f
static char *old_tz;
static void
__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;
}
/* 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;
/* 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";
{
__libc_lock_lock (tzset_lock);
- tzset_internal (1, 1);
+ tzset_internal (1);
if (!__use_tzfile)
{
/* 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,