ext/libev/ev_win32.c in rev-0.2.4 vs ext/libev/ev_win32.c in rev-0.3.0

- old
+ new

@@ -1,9 +1,9 @@ /* * libev win32 compatibility cruft (_not_ a backend) * - * Copyright (c) 2007,2008 Marc Alexander Lehmann <libev@schmorp.de> + * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: * @@ -53,11 +53,11 @@ ev_pipe (int filedes [2]) { struct sockaddr_in addr = { 0 }; int addr_size = sizeof (addr); struct sockaddr_in adr2; - int adr2_size; + int adr2_size = sizeof (adr2); SOCKET listener; SOCKET sock [2] = { -1, -1 }; if ((listener = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) return -1; @@ -131,24 +131,23 @@ return -1; } #undef pipe #define pipe(filedes) ev_pipe (filedes) - -static int -ev_gettimeofday (struct timeval *tv, struct timezone *tz) + +#define EV_HAVE_EV_TIME 1 +ev_tstamp +ev_time (void) { - struct _timeb tb; + FILETIME ft; + ULARGE_INTEGER ui; - _ftime (&tb); + GetSystemTimeAsFileTime (&ft); + ui.u.LowPart = ft.dwLowDateTime; + ui.u.HighPart = ft.dwHighDateTime; - tv->tv_sec = (long)tb.time; - tv->tv_usec = ((long)tb.millitm) * 1000; - - return 0; + /* msvc cannot convert ulonglong to double... yes, it is that sucky */ + return (LONGLONG)(ui.QuadPart - 116444736000000000) * 1e-7; } - -#undef gettimeofday -#define gettimeofday(tv,tz) ev_gettimeofday (tv, tz) #endif