Merge lp:~tangent-org/libmemcached/1.0-build/ Build: jenkins-Libmemcached-187
[m6w6/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 #include <inttypes.h>
16
17 /*
18 * One of the Windows headers define interface as a macro, but that
19 * is causing problems with the member named "interface" in some of the
20 * structs.
21 */
22 #undef interface
23
24 #undef malloc
25 #undef realloc
26
27
28 /*
29 * WinSock use a separate range for error codes. Let's just map to the
30 * WinSock ones.
31 */
32 #ifndef EADDRINUSE
33 # define EADDRINUSE WSAEADDRINUSE
34 #endif
35
36 #ifndef EWOULDBLOCK
37 # define EWOULDBLOCK WSAEWOULDBLOCK
38 #endif
39
40 #ifndef EINPROGRESS
41 # define EINPROGRESS WSAEINPROGRESS
42 #endif
43
44 #ifndef EALREADY
45 # define EALREADY WSAEALREADY
46 #endif
47
48 #ifndef EISCONN
49 # define EISCONN WSAEISCONN
50 #endif
51
52 #ifndef ENOTCONN
53 # define ENOTCONN WSAENOTCONN
54 #endif
55
56 #ifndef ENOBUFS
57 # define ENOBUFS WSAENOBUFS
58 #endif
59
60 #ifndef SHUT_RDWR
61 # define SHUT_RDWR SD_BOTH
62 #endif
63
64 /* EAI_SYSTEM isn't defined anywhere... just set it to... 11? */
65 #ifndef EAI_SYSTEM
66 # define EAI_SYSTEM 11
67 #endif
68
69 /* Best effort mapping of functions to alternative functions */
70 #define index(a,b) strchr(a,b)
71 #define rindex(a,b) strrchr(a,b)
72 #define random() rand()
73 #define srandom(a) while (false) {}
74 #define kill(a, b) while (false) {}
75 #define fork() (-1)
76 #define waitpid(a,b,c) (-1)
77 #define fnmatch(a,b,c) (-1)
78 #define sleep(a) Sleep(a*1000)
79
80 #endif /* WIN32_WRAPPERS_H */