From 09e967c2d732783b2579e4e120cd9b608404cb00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwenol=C3=A9=20Beauchesne?= Date: Wed, 4 Jun 2003 18:31:57 +0000 Subject: Merge from R9_0-AMD64, most notably: - AMD64 support to insmod-busybox, minilibc, et al. - Sync with insmod-modutils 2.4.19 something but everyone should use dietlibc nowadays - Factor out compilation and prefix with $(DIET) for dietlibc builds - 64-bit & varargs fixes --- mdk-stage1/dietlibc/libugly/mktime.c | 68 ++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 18 deletions(-) (limited to 'mdk-stage1/dietlibc/libugly/mktime.c') diff --git a/mdk-stage1/dietlibc/libugly/mktime.c b/mdk-stage1/dietlibc/libugly/mktime.c index ee4dab6c1..348068e1d 100644 --- a/mdk-stage1/dietlibc/libugly/mktime.c +++ b/mdk-stage1/dietlibc/libugly/mktime.c @@ -1,21 +1,53 @@ #include -/* seconds per day */ -#define SPD 24*60*60 - -extern unsigned int __spm[]; - -time_t mktime(struct tm *t) { - time_t x=0; - unsigned int i; - if (t->tm_year<70) return (time_t)(-1); - for (i=70; itm_year; ++i) { - x+=__isleap(i+1900)?366:365; - } - t->tm_yday=__spm[t->tm_mon] + t->tm_mday-1 + ((t->tm_mon>2) && __isleap(t->tm_year)?1:0); - x+=t->tm_yday; - /* x is now the number of days since Jan 1 1970 */ - t->tm_wday=(4+x)%7; - x = x*SPD + t->tm_hour*60*60 + t->tm_min*60 + t->tm_sec; - return x; +extern const short __spm []; + +time_t mktime ( register struct tm* const t ) +{ + register time_t day; + register time_t i; + + if ( t->tm_year < 70 ) + return (time_t) -1; + + day = t->tm_yday = __spm [t->tm_mon] + t->tm_mday-1 + ( __isleap (t->tm_year+1900) & (t->tm_mon > 1) ); + + for ( i = 70; i < t->tm_year; i++ ) + day += 365 + __isleap (i+1900); + + /* day is now the number of days since 'Jan 1 1970' */ + i = 7; + t->tm_wday = (day + 4) % i; /* Sunday=0, Monday=1, ..., Saturday=6 */ + + i = 24; + day *= i; + i = 60; + return ((day + t->tm_hour) * i + t->tm_min) * i + t->tm_sec; +} + +#if 0 + +#include + +main() +{ + int i, j, k; + static char *s[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; + + for (i=70; i<200; i++) + for (j=0; j<12; j++) + for (k=1; k<=31; k++) { + struct tm t; + double x; + t.tm_year = i; + t.tm_mon = j; + t.tm_mday = k; + t.tm_hour = 0; + t.tm_min = 0; + t.tm_sec = 0; + x = mktime (&t); + printf ("%4d.%5.0f %2u.%02u.%04u %s\n", (int)floor(x/86400), x-86400.*(int)floor(x/86400), k, j+1, 1900+i, s[t.tm_wday] ); + } + } +#endif -- cgit v1.2.1