Mercurial > hg > fxanalyse
view future.c @ 240:7fd5cb857d07
Add data pubblication through ZMQ socket
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Thu, 12 Feb 2015 19:46:54 +0100 |
parents | b955e35c07ae |
children |
line wrap: on
line source
/* welcome in the 2012 */ /* time functions */ #include <windows.h> #include <ansi_c.h> #include "future.h" /* an implementation of the C99 `round` function based on `floor` and `ceil` */ double round(double x) { if (x >= 0.0) { double y = floor(x); if (x - y >= 0.5) y += 1.0; return y; } else { double y = ceil(x); if (x - y >= 0.5) y -= 1.0; return y; } } /* implement high resolution time service */ int gettimeofday(struct timeval *tp, struct timezone *tzp) { /* difference between 1970-01-01 and 1601-01-01 in 100-nanoseconds intervals */ const unsigned __int64 shift = 116444736000000000ULL; union { FILETIME ft; unsigned __int64 integer; /* 100-nanoseconds since 1601-01-01 */ } now; /* retrive system time in UTC. the resolution is limited to the resolution of the system timer, which is typically in the range of 10 milliseconds to 16 milliseconds */ GetSystemTimeAsFileTime(&now.ft); /* shift to epoch and truncate to microseconds */ now.integer = (now.integer - shift) / 10LL; tp->tv_usec = (long)(now.integer % 1000000LL); tp->tv_sec = (long)(now.integer / 1000000LL); /* FIXME CVI redefines the epoch as seconds since 1900-01-01 ! */ tp->tv_sec += 2208988800; return 0; }