Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.lang.c Subject: Re: Need help with a time() warp Message-ID: <1237@virtech.UUCP> Date: 6 Oct 89 14:38:11 GMT References: <252BFD80.194C@marob.masa.com> Organization: Virtual Technologies Inc Lines: 48 In article <252BFD80.194C@marob.masa.com>, daveh@marob.masa.com (Dave Hammond) writes: > System: 386 compatible, SCO Xenix 2.3.1 > Compiler: Microsoft (standard SCO 'cc'). Is this Xenix for a 386 or for a 286? This could matter. time(2) is a system call that in the kernel does not take an argument. The system call library interface routine simply stores the return value in the argument if the argument is non-null. Therefore time(2) should return the same (allowing for ongoing second incrementation) reguardless of the calling context. This would seem to indicate that there is a problem in your code which I cannot comment on since you did not post it. You should try to put together the smallest section of code that will replicate your problem and post it. My totally ignorant *guess* would be that you are overrunning some variable on your stack. This could cause the problem you are seeing (even with the second incrementing you are seeing) because of the way that the 80386 stores integers (in reverse byte order). For example: long t = 0x01020304; in memory: 0x04 0x03 0x02 0x01 so the 0x02,0x01 could be getting messed up and they will still seem correct. This would also be a symptom if you are storing the result of the time(2) system call into a short integer. - Yes, I know you said that you are doing it right, but I can't see it so I am just running off a list of possible explanations. As to ctime() returning < Jan 1, 1970, this is due to your time being a negative number. On System V.3, time_t is defined as a (signed) long and therefore 4294944287 unsigned is equal to -23009 signed. The additional hours before Jan 1, 1970 is due to the timezone difference from GMT. -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+