From 6a089dac4995e032a8bb38c8de4041434fe9c93e Mon Sep 17 00:00:00 2001 From: panne Date: Sun, 28 May 2000 17:47:27 +0000 Subject: [PATCH] [project @ 2000-05-28 17:47:27 by panne] 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 | 6 +++--- ghc/lib/std/cbits/toLocalTime.c | 26 ++++++++++++-------------- ghc/lib/std/cbits/toUTCTime.c | 16 ++++++++-------- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/ghc/lib/std/cbits/stgio.h b/ghc/lib/std/cbits/stgio.h index 6d9b795..c551226 100644 --- a/ghc/lib/std/cbits/stgio.h +++ b/ghc/lib/std/cbits/stgio.h @@ -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 */ diff --git a/ghc/lib/std/cbits/toLocalTime.c b/ghc/lib/std/cbits/toLocalTime.c index c2b7bb7..6295972 100644 --- a/ghc/lib/std/cbits/toLocalTime.c +++ b/ghc/lib/std/cbits/toLocalTime.c @@ -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 */ @@ -10,33 +10,33 @@ #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; diff --git a/ghc/lib/std/cbits/toUTCTime.c b/ghc/lib/std/cbits/toUTCTime.c index 44b598a..9298f29 100644 --- a/ghc/lib/std/cbits/toUTCTime.c +++ b/ghc/lib/std/cbits/toUTCTime.c @@ -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); -- 1.7.10.4