timeval

Is there a standard way to convert a struct timeval into a struct timespec?

struct timeval represents and instant in time with two members, tv_sec (seconds) and tv_usec (microseconds). In this representation, tv_usec is not by itself an absolute time it is a sub second offset off of tv_sec. struct timespec works the same way except that instead of microseconds it's offset (tv_nsec) is stored in nanosecond units...

How do I compare two timestamps in C?

I'm writing a socket program that maintains FIFO queues for two input sockets. When deciding which queue to service, the program pulls the most recent time-stamp from each queue. I need a reliable method for comparing two timeval structs. I tried using timercmp(), but my version of gcc doesn't support it, and documentation states that ...

timeval undefined when using windows.h and WIN32_LEAN_AND_MEAN

To avoid conflicts with winsock2.h, I want to wrap my include of windows.h with WIN32_LEAN_AND_MEAN (I undef it after windows.h so as not to interfere with applications that include my headers). Doing this causes timeval to be undefined when winsock2.h isn't included. Including time.h doesn't define timeval either. How can I get timeval...

are these msec<->timeval functions correct?

I have a bug in this program, and I keep coming back to these two functions, but they look right to me. Anything wrong here? long visual_time_get_msec(VisTime *time_) { visual_log_return_val_if_fail(time_ != NULL, 0); return time_->tv_sec * 1000 + time_->tv_usec / 1000; } int visual_time_set_from_msec(VisTime *time_, long mse...

timeval to string (converting between the two)

I'm trying to pull the two components out of a timeval struct and place them into strings. I'm not having much luck with this. I've attempted casting and converting first to a long and then to a string. I need the most efficient way to do this. Any ideas? I do NOT want to convert to another data structure first (localtime, etc). I need...

How do I separately convert a struct timeval into two 32 bit variables?

A struct timeval is 64 bit long. I need, for a project, to convert this long (struct timeval) into two 32 bit chunks, and put each chunk into a different variable. How do I do this? Thanx in advance. ...