X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fwin32%2Fwrappers.h;h=a009fbdc8037dce7918829802bf97e8158f116d1;hb=aeac01630eed825d8a624e7fd7c107d47bb2e40c;hp=5bf325e9b31f68d431d1d30aa27370a17417acc3;hpb=dfdcce95b625e98144c1681f05b337648b92f20f;p=awesomized%2Flibmemcached diff --git a/src/win32/wrappers.h b/src/win32/wrappers.h index 5bf325e9..a009fbdc 100644 --- a/src/win32/wrappers.h +++ b/src/win32/wrappers.h @@ -59,6 +59,12 @@ #ifndef SHUT_RDWR # define SHUT_RDWR SD_BOTH #endif +#ifndef SHUT_WR +# define SHUT_WR SD_SEND +#endif +#ifndef SHUT_RD +# define SHUT_RD SD_RECEIVE +#endif /* EAI_SYSTEM isn't defined anywhere... just set it to... 11? */ #ifndef EAI_SYSTEM @@ -75,3 +81,24 @@ #define waitpid(a,b,c) (-1) #define fnmatch(a,b,c) (-1) #define sleep(a) Sleep(a*1000) + +#ifdef __cplusplus +# include +static inline int gettimeofday(struct timeval* tp, struct timezone* tzp) { + using clock = std::chrono::system_clock; + auto as_sec = [] (auto d) { + return std::chrono::duration_cast(d); + }; + auto as_usec = [] (auto d) { + return std::chrono::duration_cast(d); + }; + + auto now = clock::now().time_since_epoch(); + auto sec = as_sec(now); + auto usec = as_usec(now - sec); + + tp->tv_sec = sec.count(); + tp->tv_usec = usec.count(); + return 0; +} +#endif \ No newline at end of file