[project @ 2000-05-28 17:47:27 by panne]
authorpanne <unknown>
Sun, 28 May 2000 17:47:27 +0000 (17:47 +0000)
committerpanne <unknown>
Sun, 28 May 2000 17:47:27 +0000 (17:47 +0000)
The C functions toLocalTime and toUTCTime now return an StgInt, not a
rather useless StgAddr. This fixes two gcc warnings during the
compilation of Time. In the course of this, toLocalTime.c and
toUTCTime.c are synched a little bit more.

(*please merge*)

ghc/lib/std/cbits/stgio.h
ghc/lib/std/cbits/toLocalTime.c
ghc/lib/std/cbits/toUTCTime.c

index 6d9b795..c551226 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: stgio.h,v 1.20 2000/05/18 11:33:21 panne Exp $
+ * $Id: stgio.h,v 1.21 2000/05/28 17:47:27 panne Exp $
  *
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1999
  *
@@ -216,11 +216,11 @@ StgInt  sizeof_time_t    ( void );
 char*   get_ZONE         ( StgAddr );
 
 /* toLocalTime.c */
-StgAddr toLocalTime (StgInt, StgByteArray, StgByteArray);
+StgInt toLocalTime (StgInt, StgByteArray, StgByteArray);
 StgInt prim_toLocalTime ( StgInt64,StgByteArray );
 
 /* toUTCTime.c */
-StgAddr toUTCTime (StgInt, StgByteArray, StgByteArray);
+StgInt toUTCTime (StgInt, StgByteArray, StgByteArray);
 StgInt prim_toUTCTime ( StgInt64,StgByteArray );
 
 /* toClockSec.c */
index c2b7bb7..6295972 100644 (file)
@@ -1,7 +1,7 @@
 /* 
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
  *
- * $Id: toLocalTime.c,v 1.4 1999/11/26 16:25:56 simonmar Exp $
+ * $Id: toLocalTime.c,v 1.5 2000/05/28 17:47:27 panne Exp $
  *
  * toCalendarTime Runtime Support
  */
 #include "stgio.h"
 #include "timezone.h"
 
-StgAddr
+StgInt
 toLocalTime(I_ size, StgByteArray d, StgByteArray res)
 {
-    struct tm *tm,*tmp=(struct tm *)res;
     time_t t;
+    struct tm *tm,*tmp=(struct tm *)res;
 
     switch(size) {
        default:
-           return NULL;
+           return 0;
        case 0:
            t = 0;
            break;
        case -1:
            t = - (time_t) ((StgInt *)d)[0];
            if (t > 0) 
-               return NULL;
+               return 0;
            break;
        case 1:
            t = (time_t) ((StgInt *)d)[0];
            if (t < 0) 
-               return NULL;
+               return 0;
            break;
        }
     tm = localtime(&t);
     
     if (tm == NULL)
-       return NULL;
+       return 0;
 
     /*
       localtime() may return a ptr to statically allocated storage,
@@ -63,18 +63,16 @@ toLocalTime(I_ size, StgByteArray d, StgByteArray res)
     tmp->tm_gmtoff = tm->tm_gmtoff;
 #endif
 
-    return (StgAddr)res;
+    return 1;
 }
 
-/* Note that we DO NOT return res as a result.
- * res is typically a MutableByteArray and it seems very dubious
- * to return a pointer into the middle of it.
- */
-StgInt prim_toLocalTime ( StgInt64 d, StgByteArray res)
+StgInt
+prim_toLocalTime(StgInt64 d, StgByteArray res)
 {
+    time_t t;
     struct tm *tm,*tmp=(struct tm *)res;
-    time_t t = (time_t) d;
 
+    t = (time_t) d;
     if (t < 0) 
         return 0;
 
index 44b598a..9298f29 100644 (file)
@@ -1,7 +1,7 @@
 /* 
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
  *
- * $Id: toUTCTime.c,v 1.4 1999/11/26 16:25:57 simonmar Exp $
+ * $Id: toUTCTime.c,v 1.5 2000/05/28 17:47:27 panne Exp $
  *
  * toUTCTime Runtime Support
  */
@@ -10,7 +10,7 @@
 #include "stgio.h"
 #include "timezone.h"
 
-StgAddr 
+StgInt
 toUTCTime(I_ size, StgByteArray d, StgByteArray res)
 {
     time_t t;
@@ -18,25 +18,25 @@ toUTCTime(I_ size, StgByteArray d, StgByteArray res)
 
     switch(size) {
        default:
-           return NULL;
+           return 0;
        case 0:
            t = 0;
            break;
        case -1:
            t = - (time_t) ((StgInt *)d)[0];
            if (t > 0) 
-               return NULL;
+               return 0;
            break;
        case 1:
            t = (time_t) ((StgInt *)d)[0];
            if (t < 0) 
-               return NULL;
+               return 0;
            break;
        }
     tm = gmtime(&t);
     
     if (tm == NULL)
-       return NULL;
+       return 0;
 
     /*
       gmtime() may return a ptr to statically allocated storage,
@@ -63,7 +63,7 @@ toUTCTime(I_ size, StgByteArray d, StgByteArray res)
     tmp->tm_gmtoff = tm->tm_gmtoff;
 #endif
 
-    return (StgAddr)res;
+    return 1;
 }
 
 StgInt
@@ -74,7 +74,7 @@ prim_toUTCTime(StgInt64 d, StgByteArray res)
 
     t = (time_t) d;
     if (t < 0) 
-      return 0;
+        return 0;
 
     tm = gmtime(&t);