home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / d / libc / libc-4.6 / libc-4 / libc-linux / bsd / ftime.c next >
Encoding:
C/C++ Source or Header  |  1994-01-10  |  583 b   |  24 lines

  1. /*  Bezerkeley compatible ftime(3C).
  2.     This call is deprecated, use gettimeofday(2) in new code.
  3.     We use the Bezerkeley gettimeofday(2) call in the implementation, as
  4.     there is no way to get millisecond resolution in POSIX (lose, lose). */
  5.  
  6. #include <sys/types.h>
  7. #include <sys/timeb.h>
  8. #include <sys/time.h>
  9.  
  10. int
  11. ftime(struct timeb *tb)
  12. {
  13.   struct timeval tv;
  14.   struct timezone tz;
  15.  
  16.   if (__gettimeofday(&tv, &tz) < 0 )
  17.     return -1;
  18.   tb->time = tv.tv_sec;
  19.   tb->millitm = tv.tv_usec/1000; 
  20.   tb->timezone = tz.tz_minuteswest;
  21.   tb->dstflag = tz.tz_dsttime;
  22.   return 0;
  23. }
  24.