ftime32.c raw

   1  #include "time32.h"
   2  #include <sys/timeb.h>
   3  #include <errno.h>
   4  #include <stdint.h>
   5  
   6  struct timeb32 {
   7  	int32_t time;
   8  	unsigned short millitm;
   9  	short timezone, dstflag;
  10  };
  11  
  12  int __ftime32(struct timeb32 *tp)
  13  {
  14  	struct timeb tb;
  15  	if (ftime(&tb) < 0) return -1;
  16  	if (tb.time < INT32_MIN || tb.time > INT32_MAX) {
  17  		errno = EOVERFLOW;
  18  		return -1;
  19  	}
  20  	tp->time = tb.time;
  21  	tp->millitm = tb.millitm;
  22  	tp->timezone = tb.timezone;
  23  	tp->dstflag = tb.dstflag;
  24  	return 0;
  25  }
  26