9 #define _WIN32_WINNT 0x0501
22 #define EWOULDBLOCK EAGAIN
23 #define EAFNOSUPPORT 47
24 #define EADDRINUSE WSAEADDRINUSE
25 #define ENOTCONN WSAENOTCONN
26 #define ECONNRESET WSAECONNRESET
27 #define EAI_SYSTEM -11
33 typedef char *caddr_t;
47 struct iovec *msg_iov;
53 #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
54 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
56 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
101 int inet_aton(
register const char *cp,
struct in_addr *addr);
103 #define close(s) closesocket(s)
105 #if !defined(strtok_r)
106 #define strtok_r( _s, _sep, _lasts ) \
107 ( *(_lasts) = strtok( (_s), (_sep) ) )
110 static inline void mapErr(
int error) {
115 case WSAEPFNOSUPPORT:
116 errno = EAFNOSUPPORT;
134 #define write mem_write
136 static inline size_t mem_write(
int s,
void *
buf,
size_t len)
138 DWORD dwBufferCount = 0;
141 WSABUF wsabuf = { len, (
char *)buf} ;
142 if(WSASend(s, &wsabuf, 1, &dwBufferCount, 0, NULL, NULL) == 0) {
143 return dwBufferCount;
145 error = WSAGetLastError();
146 if(error == WSAECONNRESET)
return 0;
151 #define read(a,b,c) mem_recv(a,b,c,0)
152 #define recv(a,b,c,d) mem_recv(a,b,c,d)
154 static inline size_t mem_recv(
int s,
void *buf,
size_t len,
int unused)
158 WSABUF wsabuf = { len, (
char *)buf };
161 if(WSARecv((SOCKET)s, &wsabuf, 1, &dwBufferCount, &flags,
163 return dwBufferCount;
165 error = WSAGetLastError();
166 if (error == WSAECONNRESET) {
173 static inline int sendmsg(
int s,
const struct msghdr *
msg,
int flags)
178 if(WSASendTo((SOCKET) s,
179 (LPWSABUF)msg->msg_iov,
180 (DWORD)msg->msg_iovlen,
188 return dwBufferCount;
190 error = WSAGetLastError();
191 if (error == WSAECONNRESET)
return 0;
196 int getrusage(
int who,
struct rusage *usage);
197 int kill(
int pid,
int sig);
198 int sleep(
int seconds);
201 void (*sa_handler)(int);
206 #define sigemptyset(a) 0
208 #define daemonize(a,b) spawn_memcached(argc, argv)
209 extern int spawn_memcached(
int argc,
char **argv);