@@ -1917,9 +1917,11 @@ zoneinit(struct state *sp, char const *name, char tzloadflags)
19171917/* Like tzset(), but in a critical section.
19181918 If THREADED && THREAD_RWLOCK the caller has a read lock,
19191919 and this function might upgrade it to a write lock.
1920+ If WALL, act as if TZ is unset; although always false in this file,
1921+ a wrapper .c file's obsolete and ineffective tzsetwall function can use it.
19201922 If tz_change_interval is positive the time is NOW; otherwise ignore NOW. */
19211923static void
1922- tzset_unlocked (bool threaded , monotime_t now )
1924+ tzset_unlocked (bool threaded , bool wall , monotime_t now )
19231925{
19241926 char const * name ;
19251927 struct state * sp ;
@@ -1928,7 +1930,7 @@ tzset_unlocked(bool threaded, monotime_t now)
19281930 bool writing = false;
19291931
19301932 for (;;) {
1931- name = getenv ("TZ" );
1933+ name = wall ? NULL : getenv ("TZ" );
19321934 sp = lclptr ;
19331935 tzloadflags = TZLOAD_FROMENV | TZLOAD_TZSTRING ;
19341936 namelen = sizeof lcl_TZname + 1 ; /* placeholder for no name */
@@ -2016,7 +2018,7 @@ tzset(void)
20162018 errno = err ;
20172019 return ;
20182020 }
2019- tzset_unlocked (!err , now );
2021+ tzset_unlocked (!err , false, now );
20202022 unlock (!err );
20212023}
20222024#endif
@@ -2207,7 +2209,7 @@ localtime_tzset(time_t const *timep, struct tm *tmp, bool setname)
22072209 return NULL ;
22082210 }
22092211 if (0 <= tz_change_interval || setname || !lcl_is_set )
2210- tzset_unlocked (!err , now );
2212+ tzset_unlocked (!err , false, now );
22112213 tmp = localsub (lclptr , timep , setname , tmp );
22122214 unlock (!err );
22132215 return tmp ;
@@ -2874,7 +2876,7 @@ mktime(struct tm *tmp)
28742876 errno = err ;
28752877 return -1 ;
28762878 }
2877- tzset_unlocked (!err , now );
2879+ tzset_unlocked (!err , false, now );
28782880 t = mktime_tzname (lclptr , tmp , true);
28792881 unlock (!err );
28802882 return t ;
@@ -2992,7 +2994,7 @@ time2posix(time_t t)
29922994 return -1 ;
29932995 }
29942996 if (0 <= tz_change_interval || !lcl_is_set )
2995- tzset_unlocked (!err , now );
2997+ tzset_unlocked (!err , false, now );
29962998 if (lclptr )
29972999 t = time2posix_z (lclptr , t );
29983000 unlock (!err );
@@ -3038,7 +3040,7 @@ posix2time(time_t t)
30383040 return -1 ;
30393041 }
30403042 if (0 <= tz_change_interval || !lcl_is_set )
3041- tzset_unlocked (!err , now );
3043+ tzset_unlocked (!err , false, now );
30423044 if (lclptr )
30433045 t = posix2time_z (lclptr , t );
30443046 unlock (!err );
0 commit comments