struct timeval: why is tv_sec long?
Andreas Kohn
andreas.kohn at gmx.net
Thu Oct 6 17:39:59 PDT 2005
Hi,
is there any special reason for timeval.tv_sec being long?
--- sys/_timeval.h
/*
* Structure returned by gettimeofday(2) system call, and used in other
calls.
*/
struct timeval {
long tv_sec; /* seconds (XXX should be
time_t) */
suseconds_t tv_usec; /* and microseconds */
};
---
I just stumbled across this code in an application,
---
timeval tv;
gettimeofday(&tv, 0);
char tbuf[64];
struct tm tmp;
strftime(tbuf, sizeof(tbuf), "%b %d %H:%M:%S", localtime_r(&tv.tv_sec,
&tmp));
---
and this fails to compile on FreeBSD. I fixed the application code now,
but I do wonder why that XXX in sys/_timeval.h is there.
_timeval.h came into existence on 31-Dec-2002, before that timeval was
defined in sys/time.h with both tv_sec and tv_usec as long.
Could anyone offer any pointers?
Best regards,
--
Andreas
--
<TalisA> was macht man eigentlich auf einer linux-gamer lan ? hl server
aufsetzen und freuen ? *duck* ^^
--
<TalisA> was macht man eigentlich auf einer linux-gamer lan ? hl server
aufsetzen und freuen ? *duck* ^^
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: This is a digitally signed message part
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20051007/17784760/attachment.bin
More information about the freebsd-hackers
mailing list