[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: c-api-03 minor nits (struct timeval)



> > ...
> > 6) struct timeval
> >
> > Not all systems timeval fields are of type 'long'.
> > Implementations must be allowed to declare struct
> > timeval as it is found in primary header files of
> > the current C translator.
> 
> I didn't realize that was the case.  Is timeval defined in a POSIX spec.
> (it must be)?  It would be nice to have a reference.
> 

I do not recall 'struct timeval' ever being incorporated into
a POSIX specification, I thought they liked 'struct timespec' instead.
Regardless, 'struct timeval' does differ between platforms:

/* Compaq Tru64 UNIX (or whatever it's called this week) */
struct timeval {
 time_t  tv_sec;         /* seconds */
 int     tv_usec;        /* microseconds */
};

/* HP-UX */
struct timeval { 
   unsigned long tv_sec;         /* seconds */ 
   long          tv_usec;        /* and microseconds */ 
}; 

/* IRIX */
struct timeval {
  time_t    tv_sec;        /* seconds since Jan. 1, 1970 */
  long tv_usec;       /* and microseconds */
};

/* I also recall seeing this... */
struct timeval {
  int    tv_sec;     /* seconds since Jan. 1, 1970 */
  int tv_usec;       /* and microseconds */
};


Anyways, I think I made my point....

	Kurt