gettimeofday and POSIX

Jeff Johnston jjohnstn@redhat.com
Fri Jul 6 02:14:00 GMT 2007


Pedro Alves wrote:
> Hi Jeff,
> 
> Jeff Johnston wrote:
>>
>>   How about the attached patch instead?  It goes through and cleans up 
>> all the implementations as well so there is no need for the flag check.
>>
> 
>> --- libgloss/crx/time.c    5 Oct 2004 20:00:53 -0000    1.1
>> +++ libgloss/crx/time.c    5 Jul 2007 17:48:54 -0000
>> @@ -43,8 +43,9 @@ clock_t times (struct tms *buf)
>>  }
>>  
>>  /* _gettimeofday -- implement in terms of time.  */
>> -int gettimeofday (struct timeval *tv, struct timezone *tz)
>> +int gettimeofday (struct timeval *tv, void *tzvp)
>>  {
>> +  struct time *tz = (struct timezone *)tzvp;
> 
> struct timezone *tz = (struct timezone *)tzvp;  ??
> 


This version of gettimeofday actually expects tz to point to a struct 
timezone and accesses the tz structure fields (i.e. tz->xxxxx).  It now 
passes in a void pointer so I named the input parameter tzvp (vp for 
void pointer) and then just set the local pointer tz; this avoided 
having to change the rest of the code.

> And why the casts?  Too much c++ recently? :)
>

Just tired I'm afraid :)

-- Jeff J.



More information about the Newlib mailing list