? unix/Common/1.txt ? unix/Common/2.txt Index: m3core.h =================================================================== RCS file: /usr/cvs/cm3/m3-libs/m3core/src/m3core.h,v retrieving revision 1.23 diff -u -r1.23 m3core.h --- m3core.h 15 Apr 2010 08:57:16 -0000 1.23 +++ m3core.h 15 Apr 2010 11:42:18 -0000 @@ -280,13 +280,7 @@ int __cdecl Umman__munmap(ADDRESS addr, size_t len); #ifndef _WIN32 -/* somewhat idealized, but ideally we'd use INT64 here - * Win32 varies, sometimes time_t is 32bits, sometimes - * 64bits; since this code isn't actually used, - * and we don't want to use 32bit time_t if we can - * help it, disable - */ -typedef INTEGER m3_time_t; +typedef INT64 m3_time_t; #endif typedef struct { @@ -416,25 +410,49 @@ typedef struct { - size_t year; - size_t month; - size_t day; - size_t hour; - size_t minute; - size_t second; + INTEGER year; + UINT8 month; + UINT8 day; + UINT8 hour; + UINT8 minute; + UINT8 second; + UINT8 align1[3]; ptrdiff_t offset; TEXT zone; - size_t weekDay; + UINT8 weekDay; + UINT8 align2[sizeof(size_t) - 1]; } Date_t; +M3_STATIC_ASSERT(sizeof(Date_t) == (24 * (sizeof(char*) == 4)) + (40 * (sizeof(char*) == 8))); +M3_STATIC_ASSERT(M3_SIZE_THROUGH_FIELD(Date_t, month) == (sizeof(char*) + 1)); +M3_STATIC_ASSERT(M3_SIZE_THROUGH_FIELD(Date_t, day) == (sizeof(char*) + 2)); +M3_STATIC_ASSERT(M3_SIZE_THROUGH_FIELD(Date_t, hour) == (sizeof(char*) + 3)); +M3_STATIC_ASSERT(M3_SIZE_THROUGH_FIELD(Date_t, minute) == (sizeof(char*) + 4)); +M3_STATIC_ASSERT(M3_SIZE_THROUGH_FIELD(Date_t, second) == (sizeof(char*) + 5)); +M3_STATIC_ASSERT(M3_SIZE_THROUGH_FIELD(Date_t, offset) == (sizeof(char*) + 8 + sizeof(char*))); +M3_STATIC_ASSERT(M3_SIZE_THROUGH_FIELD(Date_t, zone) == (sizeof(char*) + 8 + 2 * sizeof(char*))); +M3_STATIC_ASSERT(M3_SIZE_THROUGH_FIELD(Date_t, weekDay) == (sizeof(char*) + 8 + 2 * sizeof(char*) + 1)); +M3_STATIC_ASSERT(offsetof(Date_t, month) == (sizeof(char*))); +M3_STATIC_ASSERT(offsetof(Date_t, day) == (sizeof(char*) + 1)); +M3_STATIC_ASSERT(offsetof(Date_t, hour) == (sizeof(char*) + 2)); +M3_STATIC_ASSERT(offsetof(Date_t, minute) == (sizeof(char*) + 3)); +M3_STATIC_ASSERT(offsetof(Date_t, second) == (sizeof(char*) + 4)); +M3_STATIC_ASSERT(offsetof(Date_t, offset) == (sizeof(char*) + 8)); +M3_STATIC_ASSERT(offsetof(Date_t, zone) == (sizeof(char*) + 8 + sizeof(char*))); +M3_STATIC_ASSERT(offsetof(Date_t, weekDay) == (sizeof(char*) + 8 + 2 * sizeof(char*))); + void __cdecl -DatePosix__FromTime(double t, const ptrdiff_t* zone, Date_t* date, TEXT unknown); +DatePosix__FromTime(double t, const ptrdiff_t* zone, Date_t* date, TEXT unknown, TEXT gmt); double __cdecl DatePosix__ToTime(const Date_t* date); +void +__cdecl +DatePosix__TypeCheck(const Date_t* d, size_t sizeof_DateT); + #ifdef __cplusplus } /* extern "C" */ #endif Index: time/POSIX/DatePosix.m3 =================================================================== RCS file: /usr/cvs/cm3/m3-libs/m3core/src/time/POSIX/DatePosix.m3,v retrieving revision 1.9 diff -u -r1.9 DatePosix.m3 --- time/POSIX/DatePosix.m3 6 Dec 2009 11:34:16 -0000 1.9 +++ time/POSIX/DatePosix.m3 15 Apr 2010 11:42:18 -0000 @@ -8,63 +8,25 @@ UNSAFE MODULE DatePosix EXPORTS Date; -IMPORT Time, M3toC, Utime, TimePosix; +IMPORT Time, DatePosix, Utime; REVEAL TimeZone = BRANDED "Date.TimeZone" REF INTEGER; CONST Unknown = "[Unknown zone]"; +CONST GMT = "GMT"; PROCEDURE FromTime(t: Time.T; z: TimeZone := NIL): T = - VAR - date : T; - tv : Utime.struct_timeval; - tm : Utime.struct_tm; + VAR date: T; BEGIN - tv := TimePosix.ToUtime(t); - IF (z = NIL) OR (z^ = 0) - THEN EVAL Utime.localtime_r (tv.tv_sec, ADR (tm)); - ELSE EVAL Utime.gmtime_r (tv.tv_sec, ADR(tm)); - END; - - date.year := tm.tm_year + 1900; - date.month := VAL(tm.tm_mon, Month); - date.day := tm.tm_mday; - date.hour := tm.tm_hour; - date.minute := tm.tm_min; - date.second := tm.tm_sec; - date.weekDay := VAL(tm.tm_wday, WeekDay); - - IF tm.tm_isdst = 0 THEN - date.offset := Utime.get_timezone(); - date.zone := M3toC.CopyStoT (Utime.get_tzname(0)); - ELSIF tm.tm_isdst > 0 AND Utime.get_daylight() # 0 THEN - date.offset := Utime.get_altzone(); - date.zone := M3toC.CopyStoT (Utime.get_tzname(1)); - ELSE - date.offset := 0; - date.zone := Unknown; - END; - + DatePosix.FromTime(t, z, date, Unknown, GMT); RETURN date; END FromTime; PROCEDURE ToTime(READONLY d: T): Time.T RAISES {Error} = - VAR - tm : Utime.struct_tm; - time : Utime.time_t; - t : Time.T; + VAR t: Time.T; BEGIN - tm.tm_sec := d.second; - tm.tm_min := d.minute; - tm.tm_hour := d.hour; - tm.tm_mday := d.day; - tm.tm_mon := ORD(d.month); - tm.tm_year := d.year - 1900; - (* tm.tm_wday ignored *) - tm.tm_isdst := 0; (* tell mktime that DST is not in effect *) - time := Utime.mktime(ADR(tm)); - IF time = -1 THEN RAISE Error END; - t := FLOAT(time, LONGREAL); + t := DatePosix.ToTime(d); + IF t = -1.0d0 THEN RAISE Error END; RETURN t; END ToTime; @@ -72,4 +34,8 @@ Utime.tzset (); (* initialize Utime's global variables *) Local := NEW(TimeZone); Local^ := 0; UTC := NEW(TimeZone); UTC^ := 1; + DatePosix.TypeCheck(T{year := 1, month := Month.Mar, day := 3, hour := 4, + minute := 5, second := 6, offset := 7, + zone := LOOPHOLE(8, TEXT), + weekDay := WeekDay.Sat}, BYTESIZE(T)); END DatePosix. Index: time/POSIX/DatePosixC.c =================================================================== RCS file: /usr/cvs/cm3/m3-libs/m3core/src/time/POSIX/DatePosixC.c,v retrieving revision 1.8 diff -u -r1.8 DatePosixC.c --- time/POSIX/DatePosixC.c 15 Apr 2010 08:57:17 -0000 1.8 +++ time/POSIX/DatePosixC.c 15 Apr 2010 11:42:18 -0000 @@ -25,7 +25,7 @@ void __cdecl -DatePosix__FromTime(double t, const ptrdiff_t* zone, Date_t* date, TEXT unknown) +DatePosix__FromTime(double t, const ptrdiff_t* zone, Date_t* date, TEXT unknown, TEXT gmt) { struct tm* tm; struct timeval tv; @@ -34,15 +34,13 @@ tzset(); ZeroMemory(date, sizeof(*date)); ZeroMemory(&tv, sizeof(tv)); - ZeroMemory(&tm_storage, sizeof(tm_storage)); - - tv = TimePosix__ToUtime(t); + ZeroMemory(&tm_storage, sizeof(tm_storage)); + tv = TimePosix__ToUtime(t); + assert(zone == NULL || *zone == Local || *zone == UTC); if (zone == NULL || *zone == Local) tm = localtime_r(&tv.tv_sec, &tm_storage); else if (*zone == UTC) tm = gmtime_r(&tv.tv_sec, &tm_storage); - else - assert(0); date->year = tm->tm_year + 1900; date->month = tm->tm_mon; date->day = tm->tm_mday; @@ -59,24 +57,32 @@ date->offset = -tm->tm_gmtoff; date->zone = M3toC__CopyStoT(tm->tm_zone); #else - if (tm->tm_isdst == 0) - { - date->offset = Utime__get_timezone(); - date->zone = M3toC__CopyStoT(Utime__get_tzname(0)); - } - else if (tm->tm_isdst > 0 && Utime__get_daylight()) + if (zone == NULL || *zone == Local) { + if (tm->tm_isdst == 0) + { + date->offset = Utime__get_timezone(); + date->zone = M3toC__CopyStoT(Utime__get_tzname(0)); + } + else if (tm->tm_isdst > 0 && Utime__get_daylight()) + { #ifdef __sun - date->offset = Utime__get_altzone(); + date->offset = Utime__get_altzone(); #else - date->offset = Utime__get_timezone() - 3600; + date->offset = Utime__get_timezone() - 3600; #endif - date->zone = M3toC__CopyStoT(Utime__get_tzname(1)); + date->zone = M3toC__CopyStoT(Utime__get_tzname(1)); + } + else + { + date->offset = 0; + date->zone = unknown; + } } else { - date->offset = 0; - date->zone = unknown; + date->offset = 0; + date->zone = gmt; } #endif } @@ -126,6 +132,22 @@ return t; } +void +__cdecl +DatePosix__TypeCheck(const Date_t* d, size_t sizeof_DateT) +{ + assert(sizeof(Date_t) == sizeof_DateT); + assert(d->year == 1); + assert(d->month == 2); + assert(d->day == 3); + assert(d->hour == 4); + assert(d->minute == 5); + assert(d->second == 6); + assert(d->offset == 7); + assert(d->zone == (TEXT)8); + assert(d->weekDay == 6); +} + #ifdef __cplusplus } /* extern C */ #endif Index: time/POSIX/TimePosix.i3 =================================================================== RCS file: /usr/cvs/cm3/m3-libs/m3core/src/time/POSIX/TimePosix.i3,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 TimePosix.i3 --- time/POSIX/TimePosix.i3 24 Jan 2001 12:24:35 -0000 1.1.1.1 +++ time/POSIX/TimePosix.i3 15 Apr 2010 11:42:18 -0000 @@ -6,13 +6,9 @@ (* modified on Thu Jan 28 10:00:32 PST 1993 by mjordan *) INTERFACE TimePosix; +IMPORT Time; -IMPORT Time, Utime; - -(* Conversions between a "Time.T" and a "Utime.struct_timeval". *) - -PROCEDURE ToUtime(n: Time.T): Utime.struct_timeval; - -PROCEDURE FromUtime(READONLY tv: Utime.struct_timeval): Time.T; +<*EXTERNAL TimePosix__ComputeGrain*> PROCEDURE ComputeGrain(): Time.T; +<*EXTERNAL TimePosix__Now*> PROCEDURE Now(): Time.T; END TimePosix. Index: time/POSIX/TimePosix.m3 =================================================================== RCS file: /usr/cvs/cm3/m3-libs/m3core/src/time/POSIX/TimePosix.m3,v retrieving revision 1.2 diff -u -r1.2 TimePosix.m3 --- time/POSIX/TimePosix.m3 14 Feb 2006 14:46:39 -0000 1.2 +++ time/POSIX/TimePosix.m3 15 Apr 2010 11:42:18 -0000 @@ -6,38 +6,14 @@ (* modified on Fri Apr 30 17:08:11 PDT 1993 by mjordan *) (* modified on Tue Jan 12 13:09:41 PST 1993 by mcjones *) -MODULE TimePosix EXPORTS Time, TimePosix; +MODULE TimePosix EXPORTS Time; +IMPORT Time, TimePosix; -IMPORT Utime; - -PROCEDURE Now(): T = - VAR - tv: Utime.struct_timeval; - i := Utime.gettimeofday(tv); +PROCEDURE Now(): Time.T = BEGIN - <* ASSERT i=0 *> - RETURN FromUtime(tv); + RETURN TimePosix.Now(); END Now; -PROCEDURE ToUtime(n: T): Utime.struct_timeval= - VAR tv: Utime.struct_timeval; - BEGIN - tv.tv_sec := TRUNC(n); - tv.tv_usec := ROUND((n - FLOAT(tv.tv_sec, LONGREAL)) * 1.0D6); - RETURN tv; - END ToUtime; - -PROCEDURE FromUtime(READONLY tv: Utime.struct_timeval): T= - BEGIN - RETURN FLOAT(tv.tv_sec, LONGREAL) + FLOAT(tv.tv_usec, LONGREAL) / 1.0D6 - END FromUtime; - -VAR t0, t1: T; BEGIN - (* Determine value of "Grain" experimentally. Note that - this will fail if this thread is descheduled for a tick during the - loop below. *) - t0 := Now(); - REPEAT t1 := Now() UNTIL t1 # t0; - Grain := t1-t0 + Grain := TimePosix.ComputeGrain(); END TimePosix. Index: time/POSIX/TimePosixC.c =================================================================== RCS file: /usr/cvs/cm3/m3-libs/m3core/src/time/POSIX/TimePosixC.c,v retrieving revision 1.14 diff -u -r1.14 TimePosixC.c --- time/POSIX/TimePosixC.c 15 Apr 2010 08:57:17 -0000 1.14 +++ time/POSIX/TimePosixC.c 15 Apr 2010 11:42:18 -0000 @@ -20,6 +20,7 @@ struct timeval __cdecl TimePosix__ToUtime(T t) +/* NOT exposed to Modula-3. */ { struct timeval tv; double n = { 0 }; @@ -33,6 +34,7 @@ T __cdecl TimePosix__FromUtime(const struct timeval* tv) +/* NOT exposed to Modula-3. */ { return ((T)tv->tv_sec) + ((T)tv->tv_usec) / (T)MILLION; } Index: time/POSIX/m3makefile =================================================================== RCS file: /usr/cvs/cm3/m3-libs/m3core/src/time/POSIX/m3makefile,v retrieving revision 1.31 diff -u -r1.31 m3makefile --- time/POSIX/m3makefile 12 Apr 2010 11:49:17 -0000 1.31 +++ time/POSIX/m3makefile 15 Apr 2010 11:42:18 -0000 @@ -6,25 +6,7 @@ % modified on Tue Jun 15 21:53:44 PDT 1993 by harrison % modified on Tue May 4 10:16:00 PDT 1993 by mjordan - -readonly _DateImpls = { - "CYGWIN" : "DatePosix", - "DARWIN" : "DateBsd", - "FREEBSD" : "DateBsd", - "HPUX" : "DatePosix", - "INTERIX" : "DatePosix", - "LINUX" : "DateBsd", - "NETBSD" : "DateBsd", - "NT" : "DatePosix", - "OPENBSD" : "DateBsd", - "SOLARIS" : "DatePosix", -} - -if equal(_DateImpls {TARGET_OS}, "DateBsd") and KernelThreads - exec("@grep -v \" mu \" ../src/time/POSIX/DateBsd.m3 > DateBsd.m3.tmp") - cp_if("DateBsd.m3.tmp", "DateBsd.m3") - derived_implementation ("DateBsd") -else - implementation (_DateImpls {TARGET_OS}) -end -Module("TimePosix") +module("TimePosix") +module("DatePosix") +c_source("DatePosixC") +c_source("TimePosixC") Index: unix/m3makefile =================================================================== RCS file: /usr/cvs/cm3/m3-libs/m3core/src/unix/m3makefile,v retrieving revision 1.60 diff -u -r1.60 m3makefile --- unix/m3makefile 31 Mar 2010 13:35:42 -0000 1.60 +++ unix/m3makefile 15 Apr 2010 11:42:18 -0000 @@ -3,39 +3,39 @@ % See the file COPYRIGHT for a full description. readonly _UnixPieces = { - "AMD64_DARWIN" : [ "darwin-common", "uin-len" ], - "AMD64_FREEBSD" : [ "freebsd-common", "uin-len" ], - "AMD64_LINUX" : [ "linux-common", "uin-common" ], - "AMD64_NETBSD" : [ "netbsd-common", "uin-len" ], - "AMD64_OPENBSD" : [ "openbsd-common", "uin-len" ], - "AMD64_SOLARIS" : [ "solaris-common", "uin-common" ], - "ARM_DARWIN" : [ "darwin-common", "uin-len" ], - "FreeBSD4" : [ "freebsd-common", "uin-len" ], - "I386_CYGWIN" : [ "cygwin", "uin-common" ], - "I386_DARWIN" : [ "darwin-common", "uin-len" ], - "I386_FREEBSD" : [ "freebsd-common", "uin-len" ], - "I386_INTERIX" : [ "interix-common", "uin-common" ], - "I386_LINUX" : [ "linux-common", "uin-common" ], - "I386_NETBSD" : [ "netbsd-common", "uin-len" ], - "I386_OPENBSD" : [ "openbsd-common", "uin-len" ], - "I386_SOLARIS" : [ "solaris-common", "uin-common" ], - "LINUXLIBC6" : [ "linux-common", "uin-common" ], - "MIPS64_OPENBSD" : [ "openbsd-common", "uin-len" ], - "NetBSD2_i386" : [ "netbsd-common", "uin-common" ], - "NT386" : [ "cygwin", "uin-common" ], - "NT386GNU" : [ "cygwin", "uin-common" ], - "PA32_HPUX" : [ "hpux-common", "uin-common" ], - "PA64_HPUX" : [ "hpux-common", "uin-common" ], - "PPC_DARWIN" : [ "darwin-common", "uin-len" ], - "PPC64_DARWIN" : [ "darwin-common", "uin-len" ], - "PPC_LINUX" : [ "linux-common", "uin-common" ], - "PPC32_OPENBSD" : [ "openbsd-common", "uin-len" ], - "SOLgnu" : [ "solaris-common", "solaris-2-x", "uin-common" ], - "SOLsun" : [ "solaris-common", "solaris-2-x", "uin-common" ], - "SPARC32_LINUX" : [ "linux-common", "uin-common" ], - "SPARC64_LINUX" : [ "linux-common", "uin-common" ], - "SPARC64_OPENBSD" : [ "openbsd-common", "uin-len" ], - "SPARC64_SOLARIS" : [ "solaris-common", "uin-common" ], + "AMD64_DARWIN" : [ "uin-len" ], + "AMD64_FREEBSD" : [ "uin-len" ], + "AMD64_LINUX" : [ "uin-common" ], + "AMD64_NETBSD" : [ "uin-len" ], + "AMD64_OPENBSD" : [ "uin-len" ], + "AMD64_SOLARIS" : [ "uin-common" ], + "ARM_DARWIN" : [ "uin-len" ], + "FreeBSD4" : [ "uin-len" ], + "I386_CYGWIN" : [ "uin-common" ], + "I386_DARWIN" : [ "uin-len" ], + "I386_FREEBSD" : [ "uin-len" ], + "I386_INTERIX" : [ "uin-common" ], + "I386_LINUX" : [ "uin-common" ], + "I386_NETBSD" : [ "uin-len" ], + "I386_OPENBSD" : [ "uin-len" ], + "I386_SOLARIS" : [ "uin-common" ], + "LINUXLIBC6" : [ "uin-common" ], + "MIPS64_OPENBSD" : [ "uin-len" ], + "NetBSD2_i386" : [ "uin-common" ], + "NT386" : [ "uin-common" ], + "NT386GNU" : [ "uin-common" ], + "PA32_HPUX" : [ "uin-common" ], + "PA64_HPUX" : [ "uin-common" ], + "PPC_DARWIN" : [ "uin-len" ], + "PPC64_DARWIN" : [ "uin-len" ], + "PPC_LINUX" : [ "uin-common" ], + "PPC32_OPENBSD" : [ "uin-len" ], + "SOLgnu" : [ "solaris-2-x", "uin-common" ], + "SOLsun" : [ "solaris-2-x", "uin-common" ], + "SPARC32_LINUX" : [ "uin-common" ], + "SPARC64_LINUX" : [ "uin-common" ], + "SPARC64_OPENBSD" : [ "uin-len" ], + "SPARC64_SOLARIS" : [ "uin-common" ], } include_dir ("Common") Index: unix/Common/Unix.i3 =================================================================== RCS file: /usr/cvs/cm3/m3-libs/m3core/src/unix/Common/Unix.i3,v retrieving revision 1.35 diff -u -r1.35 Unix.i3 --- unix/Common/Unix.i3 14 Apr 2010 09:38:44 -0000 1.35 +++ unix/Common/Unix.i3 15 Apr 2010 11:42:18 -0000 @@ -7,7 +7,6 @@ FROM Cstddef IMPORT size_t; FROM Ctypes IMPORT int, const_char_star, char_star, char_star_star, unsigned; FROM Utypes IMPORT off_t, mode_t, dev_t, uid_t, gid_t, pid_t; -IMPORT Usysdep; CONST MaxPathLen = 1024; (* 4096 on Irix? *) @@ -118,13 +117,6 @@ <*EXTERNAL*> PROCEDURE vfork (): pid_t; - -CONST - MAX_FDSET = Usysdep.MAX_FDSET; - -TYPE - FDSet = SET OF [0 .. MAX_FDSET - 1]; - <*EXTERNAL "Unix__mknod"*> PROCEDURE mknod (path: const_char_star; mode: mode_t; dev: dev_t): int; Index: unix/Common/Utime.i3 =================================================================== RCS file: /usr/cvs/cm3/m3-libs/m3core/src/unix/Common/Utime.i3,v retrieving revision 1.24 diff -u -r1.24 Utime.i3 --- unix/Common/Utime.i3 11 Apr 2010 22:28:40 -0000 1.24 +++ unix/Common/Utime.i3 15 Apr 2010 11:42:18 -0000 @@ -5,45 +5,13 @@ INTERFACE Utime; IMPORT Utypes; -FROM Ctypes IMPORT char_star, const_char_star, int; -IMPORT Usysdep; +FROM Ctypes IMPORT char_star; TYPE - struct_timeval = RECORD - (* somewhat idealized; this does not necessarily match - the underlying system; ideally we'd use LONGINT here. *) - tv_sec: INTEGER; - tv_usec: INTEGER; - END; - - struct_timezone = RECORD - (* Every system defines this the same, and we assert it in UnixC.c *) - tz_minuteswest: int; (* minutes west of Greenwich *) - tz_dsttime: int; (* type of dst correction *) - END; - - struct_tm_star = UNTRACED REF struct_tm; - struct_tm = Usysdep.struct_tm; - time_t = Utypes.time_t; -<*EXTERNAL "Utime__gettimeofday"*>PROCEDURE gettimeofday (VAR t: struct_timeval): int; - <*EXTERNAL "Utime__time"*>PROCEDURE time (tloc: UNTRACED REF time_t): time_t; -<*EXTERNAL "Utime__mktime"*>PROCEDURE mktime (tm: struct_tm_star): time_t; - <*EXTERNAL "Utime__ctime"*>PROCEDURE ctime (READONLY clock: time_t): char_star; -<*EXTERNAL "Utime__localtime"*>PROCEDURE localtime (clock: (*const*) UNTRACED REF time_t): struct_tm_star; -<*EXTERNAL "Utime__gmtime"*>PROCEDURE gmtime (clock: (*const*) UNTRACED REF time_t): struct_tm_star; - -<*EXTERNAL "Utime__localtime_r"*>PROCEDURE localtime_r (READONLY clock: time_t; result: struct_tm_star): struct_tm_star; -<*EXTERNAL "Utime__gmtime_r"*>PROCEDURE gmtime_r (READONLY clock: time_t; result: struct_tm_star): struct_tm_star; - -<*EXTERNAL "Utime__get_timezone"*>PROCEDURE get_timezone(): time_t; -<*EXTERNAL "Utime__get_altzone"*>PROCEDURE get_altzone(): time_t; -<*EXTERNAL "Utime__get_daylight"*>PROCEDURE get_daylight(): int; -<*EXTERNAL "Utime__get_tzname"*>PROCEDURE get_tzname(a: [0..1]): const_char_star; - <*EXTERNAL "Utime__tzset"*>PROCEDURE tzset(); END Utime. Index: unix/Common/UtimeC.c =================================================================== RCS file: /usr/cvs/cm3/m3-libs/m3core/src/unix/Common/UtimeC.c,v retrieving revision 1.54 diff -u -r1.54 UtimeC.c --- unix/Common/UtimeC.c 14 Apr 2010 13:28:42 -0000 1.54 +++ unix/Common/UtimeC.c 15 Apr 2010 11:42:18 -0000 @@ -15,46 +15,8 @@ __cdecl Utime__Assertions(void) { -#ifndef _WIN32 - /* Basically no 32bit system has a 64bit time_t, unfortunate. */ - M3_STATIC_ASSERT(sizeof(time_t) <= sizeof(void*)); - - /* verify timeval (microtime) contains just the two fields we know about, in either order */ -#if defined(__APPLE__) && defined(__LP64__) -/* AMD64_DARWIN has: -struct timeval -{ - int64 tv_sec; - int32 tv_usec; - 4 bytes of padding -}; I do not see much we can do about this. We use copying wrappers and we - want to be sure they are copying the entire struct. -*/ - { typedef struct timeval T1; - typedef struct { time_t tv_sec; suseconds_t tv_usec; } T2; - M3_STATIC_ASSERT(M3_FIELD_SIZE(T1, tv_sec) == 8); - M3_STATIC_ASSERT(M3_FIELD_SIZE(T1, tv_usec) == 4); - M3_STATIC_ASSERT(M3_FIELD_SIZE(T2, tv_sec) == 8); - M3_STATIC_ASSERT(M3_FIELD_SIZE(T2, tv_usec) == 4); - M3_STATIC_ASSERT(sizeof(T1) == 16); - M3_STATIC_ASSERT(sizeof(T2) == 16); - } -#else - { typedef struct timeval T; - M3_STATIC_ASSERT(sizeof(T) == M3_FIELD_SIZE(T, tv_sec) + M3_FIELD_SIZE(T, tv_usec)); } -#endif - - /* verify timezone is exactly as we expect */ - { typedef m3_timezone_t M; - typedef struct timezone T; - M3_STATIC_ASSERT(sizeof(T) == sizeof(M)); - M3_STATIC_ASSERT(sizeof(T) == 8); - M3_STATIC_ASSERT(offsetof(T, tz_minuteswest) == 0); - M3_STATIC_ASSERT(offsetof(T, tz_dsttime) == 4); - M3_STATIC_ASSERT(offsetof(M, minuteswest) == 0); - M3_STATIC_ASSERT(offsetof(M, dsttime) == 4); - } -#endif + /* We won't ever be truncating. */ + M3_STATIC_ASSERT(sizeof(time_t) <= sizeof(INT64)); } #if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__) @@ -92,7 +54,7 @@ #endif } -#endif /* cygwin | sun */ +#endif /* cygwin | sun | hpux | interix */ int __cdecl @@ -115,27 +77,6 @@ #endif /* M3BSD, WIN32 */ -#ifndef _WIN32 - -static void timeval_to_m3(const struct timeval* t, m3_timeval_t* m) -{ - if (!m) return; - assert(t); - m->sec = t->tv_sec; - m->usec = t->tv_usec; -} - -int -__cdecl -Utime__gettimeofday(m3_timeval_t* m3t) -{ - struct timeval t; - /* null is not valid here; gcc warns */ - int r = gettimeofday(&t, 0); - timeval_to_m3(&t, m3t); - return r; -} - m3_time_t __cdecl Utime__time(m3_time_t* tloc) @@ -146,13 +87,6 @@ return a; } -m3_time_t -__cdecl -Utime__mktime(struct tm* tm) -{ - return mktime(tm); -} - char* __cdecl Utime__ctime(const m3_time_t* m) @@ -161,40 +95,6 @@ return ctime(m ? &t : 0); } -struct tm* -__cdecl -Utime__localtime(const m3_time_t* m) -{ - time_t t = m ? (time_t)*m : 0; - return localtime(m ? &t : 0); -} - -struct tm* -__cdecl -Utime__gmtime(const m3_time_t* m) -{ - time_t t = m ? (time_t)*m : 0; - return gmtime(m ? &t : 0); -} - -struct tm* -__cdecl -Utime__localtime_r(const m3_time_t* m3t, struct tm* result) -{ - time_t t = m3t ? *m3t : 0; - return localtime_r(m3t ? &t : 0, result); -} - -struct tm* -__cdecl -Utime__gmtime_r(const m3_time_t* m3t, struct tm* result) -{ - time_t t = m3t ? *m3t : 0; - return gmtime_r(m3t ? &t : 0, result); -} - -#endif /* _WIN32 */ - void __cdecl Utime__tzset(void) Index: unix/Common/Utypes.i3 =================================================================== RCS file: /usr/cvs/cm3/m3-libs/m3core/src/unix/Common/Utypes.i3,v retrieving revision 1.17 diff -u -r1.17 Utypes.i3 --- unix/Common/Utypes.i3 11 Apr 2010 23:07:29 -0000 1.17 +++ unix/Common/Utypes.i3 15 Apr 2010 11:42:18 -0000 @@ -40,8 +40,7 @@ *) off_t = int64_t; - (* Ideally this is always 64 bits, else time runs out in 2038 on 32bit systems. *) - time_t = INTEGER; + time_t = LONGINT; (* NOTE: Signedness of gid_t and uid_t can be important. * see how cvsup sets NoOwner and NoGroup.