From 5f828d9e9687d7a61562720ddee399deb01585c6 Mon Sep 17 00:00:00 2001 From: sof Date: Sun, 19 Sep 1999 19:21:22 +0000 Subject: [PATCH] [project @ 1999-09-19 19:21:22 by sof] unify two near-identical impls of toClockSec() --- ghc/lib/std/cbits/toClockSec.c | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/ghc/lib/std/cbits/toClockSec.c b/ghc/lib/std/cbits/toClockSec.c index 7b2a01d..742e814 100644 --- a/ghc/lib/std/cbits/toClockSec.c +++ b/ghc/lib/std/cbits/toClockSec.c @@ -1,7 +1,7 @@ /* * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998 * - * $Id: toClockSec.c,v 1.3 1998/12/02 13:28:01 simonm Exp $ + * $Id: toClockSec.c,v 1.4 1999/09/19 19:21:22 sof Exp $ * * toClockSec Runtime Support */ @@ -10,38 +10,8 @@ #include "timezone.h" #include "stgio.h" -StgAddr -toClockSec(I_ year, I_ mon, I_ mday, I_ hour, I_ min, I_ sec, I_ isdst, StgByteArray res) -{ - struct tm tm; - time_t t; - - tm.tm_year = year - 1900; - tm.tm_mon = mon; - tm.tm_mday = mday; - tm.tm_hour = hour; - tm.tm_min = min; - tm.tm_sec = sec; - tm.tm_isdst = isdst; - -#ifdef HAVE_MKTIME - t = mktime(&tm); -#else -#ifdef HAVE_TIMELOCAL - t = timelocal(&tm); -#else - t = (time_t) -1; -#endif -#endif - if (t == (time_t) -1) - return NULL; - - *(time_t *)res = t; - return res; -} - StgInt -prim_toClockSec(I_ year, I_ mon, I_ mday, I_ hour, I_ min, I_ sec, I_ isdst, StgByteArray res) +toClockSec(I_ year, I_ mon, I_ mday, I_ hour, I_ min, I_ sec, I_ isdst, StgByteArray res) { struct tm tm; time_t t; @@ -56,13 +26,11 @@ prim_toClockSec(I_ year, I_ mon, I_ mday, I_ hour, I_ min, I_ sec, I_ isdst, Stg #ifdef HAVE_MKTIME t = mktime(&tm); -#else -#ifdef HAVE_TIMELOCAL +#elif defined(HAVE_TIMELOCAL) t = timelocal(&tm); #else t = (time_t) -1; #endif -#endif if (t == (time_t) -1) return 0; -- 1.7.10.4