https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=5f4e1e895cf92b25ff59de19215ce41eca5b15a0

commit 5f4e1e895cf92b25ff59de19215ce41eca5b15a0
Author: Corinna Vinschen <cori...@vinschen.de>
Date:   Tue Mar 31 11:14:22 2015 +0200

    Add _tzset_unlocked and _tzset_unlocked_r
    
    newlib:
    
        * libc/time/local.h (_tzset_unlocked_r): Add prototype.
        (_tzset_unlocked): Ditto.
        * libc/time/tzset.c (_tzset_unlocked): New function, call
        _tzset_unlocked_r.
        (tzset): Lock and call _tzset_unlocked_r.
        * libc/time/tzset_r (_tzset_unlocked_r): Remove locking and rename
        from _tzset_r.
        (_tzset_r): Lock and call _tzset_unlocked_r.
    
    cygwin:
    
        * localtime.cc (tzset_unlocked): Export as _tzset_unlocked.
    
    Signed-off-by: Corinna Vinschen <cori...@vinschen.de>

Diff:
---
 newlib/ChangeLog           | 11 +++++++++++
 newlib/libc/time/local.h   |  3 +++
 newlib/libc/time/tzset.c   | 10 +++++++++-
 newlib/libc/time/tzset_r.c | 34 ++++++++++++----------------------
 winsup/cygwin/ChangeLog    |  4 ++++
 winsup/cygwin/localtime.cc | 10 ++++++++++
 6 files changed, 49 insertions(+), 23 deletions(-)

diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index c214b69..420354e 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,14 @@
+2015-03-31  Corinna Vinschen  <vinsc...@redhat.com>
+
+       * libc/time/local.h (_tzset_unlocked_r): Add prototype.
+       (_tzset_unlocked): Ditto.
+       * libc/time/tzset.c (_tzset_unlocked): New function, call
+       _tzset_unlocked_r.
+       (tzset): Lock and call _tzset_unlocked_r.
+       * libc/time/tzset_r (_tzset_unlocked_r): Remove locking and rename
+       from _tzset_r.
+       (_tzset_r): Lock and call _tzset_unlocked_r.
+
 2015-03-30  Craig Howland  <howl...@lgsinnovations.com>
 
        * libc/stdlib/setenv_r.c (_setenv_r): Remove tzset() call for TZ
diff --git a/newlib/libc/time/local.h b/newlib/libc/time/local.h
index 5fc3ddc..af5793a 100644
--- a/newlib/libc/time/local.h
+++ b/newlib/libc/time/local.h
@@ -23,6 +23,9 @@ int         _EXFUN (__tzcalc_limits, (int __year));
 
 extern _CONST int __month_lengths[2][MONSPERYEAR];
 
+_VOID _EXFUN(_tzset_unlocked_r, (struct _reent *));
+_VOID _EXFUN(_tzset_unlocked, (_VOID));
+
 /* locks for multi-threading */
 #ifdef __SINGLE_THREAD__
 #define TZ_LOCK
diff --git a/newlib/libc/time/tzset.c b/newlib/libc/time/tzset.c
index d847a26..5c421a5 100644
--- a/newlib/libc/time/tzset.c
+++ b/newlib/libc/time/tzset.c
@@ -68,7 +68,15 @@ Supporting OS subroutine required: None
 #include "local.h"
 
 _VOID
+_DEFUN_VOID (_tzset_unlocked)
+{
+  _tzset_unlocked_r (_REENT);
+}
+
+_VOID
 _DEFUN_VOID (tzset)
 {
-  _tzset_r (_REENT);
+  TZ_LOCK;
+  _tzset_unlocked_r (_REENT);
+  TZ_UNLOCK;
 }
diff --git a/newlib/libc/time/tzset_r.c b/newlib/libc/time/tzset_r.c
index 2c5b723..6c21e82 100644
--- a/newlib/libc/time/tzset_r.c
+++ b/newlib/libc/time/tzset_r.c
@@ -14,7 +14,7 @@ static char __tzname_dst[11];
 static char *prev_tzenv = NULL;
 
 _VOID
-_DEFUN (_tzset_r, (reent_ptr),
+_DEFUN (_tzset_unlocked_r, (reent_ptr),
         struct _reent *reent_ptr)
 {
   char *tzenv;
@@ -25,24 +25,17 @@ _DEFUN (_tzset_r, (reent_ptr),
 
   if ((tzenv = _getenv_r (reent_ptr, "TZ")) == NULL)
       {
-       TZ_LOCK;
        _timezone = 0;
        _daylight = 0;
        _tzname[0] = "GMT";
        _tzname[1] = "GMT";
        free(prev_tzenv);
        prev_tzenv = NULL;
-       TZ_UNLOCK;
        return;
       }
 
-  TZ_LOCK;
-
   if (prev_tzenv != NULL && strcmp(tzenv, prev_tzenv) == 0)
-    {
-      TZ_UNLOCK;
-      return;
-    }
+    return;
 
   free(prev_tzenv);
   prev_tzenv = _malloc_r (reent_ptr, strlen(tzenv) + 1);
@@ -54,10 +47,7 @@ _DEFUN (_tzset_r, (reent_ptr),
     ++tzenv;  
 
   if (sscanf (tzenv, "%10[^0-9,+-]%n", __tzname_std, &n) <= 0)
-    {
-      TZ_UNLOCK;
-      return;
-    }
+    return;
  
   tzenv += n;
 
@@ -74,10 +64,7 @@ _DEFUN (_tzset_r, (reent_ptr),
   ss = 0;
  
   if (sscanf (tzenv, "%hu%n:%hu%n:%hu%n", &hh, &n, &mm, &n, &ss, &n) < 1)
-    {
-      TZ_UNLOCK;
-      return;
-    }
+    return;
   
   tz->__tzrule[0].offset = sign * (ss + SECSPERMIN * mm + SECSPERHOUR * hh);
   _tzname[0] = __tzname_std;
@@ -88,7 +75,6 @@ _DEFUN (_tzset_r, (reent_ptr),
       _tzname[1] = _tzname[0];
       _timezone = tz->__tzrule[0].offset;
       _daylight = 0;
-      TZ_UNLOCK;
       return;
     }
   else
@@ -127,10 +113,7 @@ _DEFUN (_tzset_r, (reent_ptr),
        {
          if (sscanf (tzenv, "M%hu%n.%hu%n.%hu%n", &m, &n, &w, &n, &d, &n) != 3 
||
              m < 1 || m > 12 || w < 1 || w > 5 || d > 6)
-           {
-             TZ_UNLOCK;
-             return;
-           }
+           return;
          
          tz->__tzrule[i].ch = 'M';
          tz->__tzrule[i].m = m;
@@ -198,6 +181,13 @@ _DEFUN (_tzset_r, (reent_ptr),
   __tzcalc_limits (tz->__tzyear);
   _timezone = tz->__tzrule[0].offset;  
   _daylight = tz->__tzrule[0].offset != tz->__tzrule[1].offset;
+}
 
+_VOID
+_DEFUN (_tzset_r, (reent_ptr),
+        struct _reent *reent_ptr)
+{
+  TZ_LOCK;
+  _tzset_unlocked_r (reent_ptr);
   TZ_UNLOCK;
 }
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index f496ec7..09749e0 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,7 @@
+2015-03-31  Corinna Vinschen  <cori...@vinschen.de>
+
+       * localtime.cc (tzset_unlocked): Export as _tzset_unlocked.
+
 2015-03-30  Yaakov Selkowitz  <yselk...@redhat.com>
 
        * common.din (__gnu_basename): Export.
diff --git a/winsup/cygwin/localtime.cc b/winsup/cygwin/localtime.cc
index ca58b65..d57a020 100644
--- a/winsup/cygwin/localtime.cc
+++ b/winsup/cygwin/localtime.cc
@@ -500,7 +500,11 @@ static int         tzload(timezone_t sp, const char * name,
                                int doextend);
 static int             tzparse(timezone_t sp, const char * name,
                                int lastditch);
+#ifdef __CYGWIN__
+extern "C" void                tzset_unlocked(void);
+#else
 static void            tzset_unlocked(void);
+#endif
 static long            leapcorr(const timezone_t sp, time_t * timep);
 
 static timezone_t lclptr;
@@ -1613,6 +1617,9 @@ tzsetwall (void)
 
 static NO_COPY muto tzset_guard;
 
+#ifdef __CYGWIN__
+extern "C"
+#else
 #ifndef STD_INSPIRED
 /*
 ** A non-static declaration of tzsetwall in a system header file
@@ -1620,6 +1627,7 @@ static NO_COPY muto tzset_guard;
 */
 static
 #endif /* !defined STD_INSPIRED */
+#endif
 void
 tzset_unlocked(void)
 {
@@ -1663,6 +1671,8 @@ tzset_unlocked(void)
        settzname();
 }
 
+EXPORT_ALIAS (tzset_unlocked, _tzset_unlocked)
+
 extern "C" void
 tzset(void)
 {

Reply via email to