Return to BSD News archive
Newsgroups: comp.unix.bsd Path: sserve!manuel!munnari.oz.au!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!news.belwue.de!news.uni-tuebingen.de!mailserv!zxmsd01 From: zxmsd01@mailserv.zdv.uni-tuebingen.de (Gunther Schadow) Subject: Re: 386BSD: were is the ftime() function? Message-ID: <zxmsd01.710680662@mailserv> Sender: news@softserv.zdv.uni-tuebingen.de (News Operator) Organization: Comp. Center (ZDV) U of Tuebingen, FRG References: <zxmsd01.710531593@mailserv> Date: Thu, 9 Jul 1992 11:17:42 GMT Lines: 79 Hi again, the answer to the ftime() problem came quite immediately from J"org Wunsch. He sent me an ftime() interface to gettimeofday() wich can be used for code still requiring the (obsolete, in the meantime) ftime(). Thanks to J"org Wunsch, whose ftime() emulating code I appended to my posting. Even though he told me that he didn't tested this, I think it will help all, who are concerned in porting Unix-software to 386BSD. regards -Gunther -----------------8<-----------/usr/include/sys/timeb.h-------------- /* * struct timeb, used for ftime(3) * OBSOLETED BY gettimeofday(2) - stop using ftime anymore * */ #ifndef _SYS_TIMEB_H #define _SYS_TIMEB_H struct timeb { time_t time; unsigned short millitm; short timezone; short dstflag; }; extern int ftime __P((struct timeb *tp)); #endif /* _SYS_TIMEB_H */ -------------------------------------------------------------------- -----------------8<-----------/usr/src/lib/libc/gen/ftime.c--------- /* * ftime.c * get time, OBSOLETED BY gettimeofday(2) * */ #include <sys/types.h> #include <time.h> #include <sys/timeb.h> #ifdef __STDC__ int ftime(struct timeb *tp) #else int ftime(tp) struct timeb *tp; #endif { struct timeval tv; struct timezone tz; if(gettimeofday(&tv, &tz) < 0) return -1; /* any error */ tp->time = tv.tv_sec; tp->millitm = tv.tv_usec / 1000; tp->timezone = tz.tz_minuteswest; tp->dstflag = tz.tz_dsttime != DST_NONE; return 0; } -------------------------------------------------------------------- -- ------------------------------------------------------------------------------- Gunther Schadow, e-mail: Gunther@mailserv.ZDV.Uni-Tuebingen.DE Sudetenstrasse 25, Phone: (49) 7071/37527 7400 Tuebingen, Germany._______________________________________________________