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* ^^

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to