aboutsummaryrefslogtreecommitdiff
path: root/osc/packOSC.c
diff options
context:
space:
mode:
authorMartin Peach <mrpeach@users.sourceforge.net>2007-07-15 18:00:20 +0000
committerMartin Peach <mrpeach@users.sourceforge.net>2007-07-15 18:00:20 +0000
commitb05f8113fc20bfd28478fd43d9208a6b3d0e81b3 (patch)
tree0cd0bfcc7d378dfecc2912d93bcb880e7267b73c /osc/packOSC.c
parent9d4dbf04277754f2a120719bf41b17d40dcc6736 (diff)
Should compile on MSW now...
svn path=/trunk/externals/mrpeach/; revision=8082
Diffstat (limited to 'osc/packOSC.c')
-rwxr-xr-xosc/packOSC.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/osc/packOSC.c b/osc/packOSC.c
index ce73277..1a604a4 100755
--- a/osc/packOSC.c
+++ b/osc/packOSC.c
@@ -37,12 +37,13 @@ The OSC webpage is http://cnmat.cnmat.berkeley.edu/OpenSoundControl
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include <sys/time.h>
#ifdef MSW
#include <winsock2.h>
+#include <sys/timeb.h>
#else
#include <ctype.h>
+#include <sys/time.h>
#endif
#ifdef unix
@@ -1268,9 +1269,22 @@ static OSCTimeTag OSCTT_Infinite(void)
static OSCTimeTag OSCTT_CurrentTimePlusOffset(uint4 offset)
{ /* offset is in microseconds */
OSCTimeTag tt;
+ static unsigned int onemillion = 1000000;
+ static unsigned int onethousand = 1000;
+#ifdef MSW
+ struct _timeb tb;
+
+ _ftime(&tb);
+
+ /* First get the seconds right */
+ tt.seconds = (unsigned)SECONDS_FROM_1900_to_1970 +
+ (unsigned)tb.time+
+ (unsigned)offset/onemillion;
+ /* Now get the fractional part. */
+ tt.fraction = (unsigned)tb.millitm*onethousand + (unsigned)(offset%onemillion); /* in usec */
+#else
struct timeval tv;
struct timezone tz;
- static unsigned int onemillion = 1000000;
gettimeofday(&tv, &tz);
@@ -1282,6 +1296,7 @@ static OSCTimeTag OSCTT_CurrentTimePlusOffset(uint4 offset)
(unsigned) offset/onemillion;
/* Now get the fractional part. */
tt.fraction = (unsigned) tv.tv_usec + (unsigned)(offset%onemillion); /* in usec */
+#endif
if (tt.fraction > onemillion)
{
tt.fraction -= onemillion;