Windows and Shaper
I was browsing the online CVS repository and noticed the
config-win32.h.in says that HAVE_GETTIMEOFDAY is specified in misc.c. When I look in misc.c, I don't see the file. Is the latest version just not checked in? I also implemented a gettimeofday for windows. It is based on QueryPerformanceCounter. If you are interested in this version let me know. If somebody knows the correct status of gettimeofday for the cvs code, I would appreciate an update.
Thanks,
Derek Burdick
I was greping the wrong directory. I found the windows implementation of gettimeofday in otime.c, contrary to the config-win32.h. Thanks!
Derek Burdick
----- Original Message -----
From: "Derek Burdick" <[email protected]...>
To: <[email protected]>
Sent: Saturday, April 24, 2004 1:46 AM
Subject: [Openvpn-devel] Windows and Shaper
Quoted 2 lines
I was browsing the online CVS repository and noticed the
config-win32.h.in says thatHAVE_GETTIMEOFDAYis specified inmisc.c.
When
Quoted 2 lines
I look in
misc.c, I don't see the file. Is the latest version just not checked in? I also implemented a gettimeofday for windows. It is based
on
Quoted 1 line
QueryPerformanceCounter. If you are interested in this version let me
know.
Quoted 18 lines
If somebody knows the correct status of gettimeofday for the cvs code, I would appreciate an update.
Thanks,
Derek Burdick-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek For a limited time only, get FREE Ground shipping on all orders of $35 or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Quoted 7 lines · Derek Burdick
I was browsing the online CVS repository and noticed the
config-win32.h.in says thatHAVE_GETTIMEOFDAYis specified inmisc.c. When I look inmisc.c, I don't see the file. Is the latest version just not checked in? I also implemented a gettimeofday for windows. It is based on QueryPerformanceCounter. If you are interested in this version let me know. If somebody knows the correct status of gettimeofday for the cvs code, I would appreciate an update.
Derek,
Yes, I'd like to see your gettimeofday for Windows that uses QueryPerformanceCounter. OpenVPN 2.0 will have a gettimeofday function for Windows so that --shaper and --mode server can be supported.
James
Here is the function. Don't forget to #DEFINE HAVE_GETTIMEOFDAY in config-win32.h. Let me know what you think.
Derek Burdick
----- Original Message -----
From: "James Yonan" <[email protected]...>
To: "Derek Burdick" <[email protected]...>;
<[email protected]>
Sent: Tuesday, April 27, 2004 12:48 PM
Subject: Re: [Openvpn-devel] Windows and Shaper
Quoted 4 lines
Quoted 2 lines · Derek Burdick
I was browsing the online CVS repository and noticed the
config-win32.h.in says thatHAVE_GETTIMEOFDAYis specified inmisc.c.
When
Quoted 2 lines
Quoted 2 lines
I look in
misc.c, I don't see the file. Is the latest version just not checked in? I also implemented a gettimeofday for windows. It is based
on
Quoted 1 line
Quoted 1 line
QueryPerformanceCounter. If you are interested in this version let me
know.
Quoted 7 lines
Quoted 2 lines
If somebody knows the correct status of gettimeofday for the cvs code, I would appreciate an update.
Derek,
Yes, I'd like to see your gettimeofday for Windows that uses QueryPerformanceCounter. OpenVPN 2.0 will have a gettimeofday function
for
Quoted 5 lines
Windows so that --shaper and --mode server can be supported.
James
misc.c +53 -0
@@ -678,3 +678,56 @@ ++cp; } } + +#ifdef HAVE_GETTIMEOFDAY +#ifdef WIN32 +static double counterPerMicrosecond =-1.0 ; +static unsigned __int64 frequency =0 ; +static unsigned __int64 timeSecOffset =0 ; +static unsigned __int64 startPerformanceCounter =0 ; + +/* +* gettimeofday for windows +* +* CounterPerMicrosecond is the number of counts per microsecond. +* Double is required if we have less than 1 counter per microsecond. This has not been tested. +* On a PIII 700, I get about 3.579545. This is guaranteed not to change while the processor is running. +* We really don't need to check for loop detection. On my machine it would take about 59645564 days to loop. +* (2^64) / frequency / 60 / 60 / 24. +* +*/ +int gettimeofday (struct timeval *tv,long *ignored) +{ +unsigned __int64 counter; + +QueryPerformanceCounter ((LARGE_INTEGER *) &counter); + +if (counter < startPerformanceCounter || counterPerMicrosecond ==-1.0 ) + { +time_t t; +mutex_lock (L_GETTIMEOFDAY ); + +QueryPerformanceFrequency ((LARGE_INTEGER *) &frequency); + + counterPerMicrosecond = (double )frequency /1000000.0f ; + +time (&t); +QueryPerformanceCounter ((LARGE_INTEGER *) &counter); + startPerformanceCounter = counter; + + counter /= frequency; + + timeSecOffset = t - counter; + +mutex_unlock (L_GETTIMEOFDAY ); +QueryPerformanceCounter ((LARGE_INTEGER *) &counter); + } + + tv->tv_sec = (counter / frequency) + timeSecOffset; + tv->tv_usec = ((__int64)(counter / counterPerMicrosecond) %1000000 ); + +return 0 ; +} + +#endif /* WIN32 */ +#endif /* HAVE_GETTIMEOFDAY */
Derek,
Thanks for the function, I like it better than the previous function which was using timeGetTime (and therefore has wraparound problems).
I've merged it in test26 which should be released soon.
James
Quoted 36 lines · Derek Burdick
Here is the function. Don't forget to #DEFINE
HAVE_GETTIMEOFDAYinconfig-win32.h. Let me know what you think.Derek Burdick
----- Original Message -----
From: "James Yonan" <[email protected]...>
To: "Derek Burdick" <[email protected]...>;
<[email protected]>
Sent: Tuesday, April 27, 2004 12:48 PM
Subject: Re: [Openvpn-devel] Windows and ShaperQuoted 4 lines
Quoted 2 lines · Derek Burdick
I was browsing the online CVS repository and noticed the
config-win32.h.in says thatHAVE_GETTIMEOFDAYis specified inmisc.c.When
Quoted 2 lines
Quoted 2 lines
I look in
misc.c, I don't see the file. Is the latest version just not checked in? I also implemented a gettimeofday for windows. It is basedon
Quoted 1 line
Quoted 1 line
QueryPerformanceCounter. If you are interested in this version let me
know.
Quoted 7 lines
Quoted 2 lines
If somebody knows the correct status of gettimeofday for the cvs code, I would appreciate an update.
Derek,
Yes, I'd like to see your gettimeofday for Windows that uses QueryPerformanceCounter. OpenVPN 2.0 will have a gettimeofday function
for
Quoted 5 lines
Windows so that --shaper and --mode server can be supported.
James