Initial support for Windows
[awesomized/libmemcached] / win32 / wrappers.h
1 /* LibMemcached
2 * Copyright (C) 2010 Brian Aker, Trond Norbye
3 * All rights reserved.
4 *
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
7 *
8 * Summary: "Implementation" of the function we don't have on windows
9 * to avoid a bunch of ifdefs in the rest of the code
10 *
11 */
12 #ifndef WIN32_WRAPPERS_H
13 #define WIN32_WRAPPERS_H 1
14
15 /*
16 * One of the Windows headers define interface as a macro, but that
17 * is causing problems with the member named "interface" in some of the
18 * structs.
19 */
20 #undef interface
21
22 /*
23 * WinSock use a separate range for error codes. Let's just map to the
24 * WinSock ones.
25 */
26 #define EADDRINUSE WSAEADDRINUSE
27 #define EWOULDBLOCK WSAEWOULDBLOCK
28 #define EINPROGRESS WSAEINPROGRESS
29 #define EALREADY WSAEALREADY
30 #define EISCONN WSAEISCONN
31 #define ENOTCONN WSAENOTCONN
32 #define ENOBUFS WSAENOBUFS
33 #define SHUT_RDWR SD_BOTH
34
35 /* EAI_SYSTEM isn't defined anywhere... just set it to... 11? */
36 #define EAI_SYSTEM 11
37
38 /* Best effort mapping of functions to alternative functions */
39 #define index(a,b) strchr(a,b)
40 #define rindex(a,b) strrchr(a,b)
41 #define random() rand()
42 #define srandom(a) while (false) {}
43 #define kill(a, b) while (false) {}
44 #define fork() (-1)
45 #define waitpid(a,b,c) (-1)
46 #define fnmatch(a,b,c) (-1)
47 #define sleep(a) Sleep(a*1000)
48
49 #endif /* WIN32_WRAPPERS_H */