Debian Codegraph @

src/include/platform.h

raw
1 /*
2 This file is part of libmicrohttpd
3 Copyright (C) 2008 Christian Grothoff (and other contributing authors)
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 /**
21 * @file platform.h
22 * @brief platform-specific includes for libmicrohttpd
23 * @author Christian Grothoff
24 *
25 * This file is included by the libmicrohttpd code
26 * before "microhttpd.h"; it provides the required
27 * standard headers (which are platform-specific).<p>
28 *
29 * Note that this file depends on our configure.ac
30 * build process and the generated config.h file.
31 * Hence you cannot include it directly in applications
32 * that use libmicrohttpd.
33 */
34 #ifndef MHD_PLATFORM_H
35 #define MHD_PLATFORM_H
36
37 #include "mhd_options.h"
38
39 #include <stdio.h>
40 #ifdef HAVE_STDLIB_H
41 #include <stdlib.h>
42 #endif /* HAVE_STDLIB_H */
43 #include <stdint.h>
44 #include <string.h>
45 #ifdef HAVE_UNISTD_H
46 #include <unistd.h>
47 #endif
48 #include <stdarg.h>
49 #include <errno.h>
50 #include <fcntl.h>
51 #include <signal.h>
52 #ifdef HAVE_STDDEF_H
53 #include <stddef.h>
54 #endif /* HAVE_STDDEF_H */
55
56 /* different OSes have fd_set in
57 a broad range of header files;
58 we just include most of them (if they
59 are available) */
60
61
62 #if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS)
63 #include <stdarg.h>
64 #include <sys/mman.h>
65 #ifdef HAVE_SOCKLIB_H
66 #include <sockLib.h>
67 #endif /* HAVE_SOCKLIB_H */
68 #ifdef HAVE_INETLIB_H
69 #include <inetLib.h>
70 #endif /* HAVE_INETLIB_H */
71 #endif /* __VXWORKS__ */
72
73 #ifdef HAVE_MEMORY_H
74 #include <memory.h>
75 #endif
76
77 #ifdef HAVE_SYS_SELECT_H
78 #include <sys/select.h>
79 #endif
80 #ifdef HAVE_SYS_TYPES_H
81 #include <sys/types.h>
82 #endif
83 #ifdef HAVE_SYS_TIME_H
84 #include <sys/time.h>
85 #endif
86 #ifdef HAVE_SYS_STAT_H
87 #include <sys/stat.h>
88 #endif
89 #ifdef HAVE_SYS_MSG_H
90 #include <sys/msg.h>
91 #endif
92 #ifdef HAVE_SYS_MMAN_H
93 #include <sys/mman.h>
94 #endif
95 #ifdef HAVE_TIME_H
96 #include <time.h>
97 #endif
98 #ifdef HAVE_SYS_SOCKET_H
99 #include <sys/socket.h>
100 #endif
101 #if defined(_WIN32) && ! defined(__CYGWIN__)
102 #ifndef WIN32_LEAN_AND_MEAN
103 /* Do not include unneeded parts of W32 headers. */
104 #define WIN32_LEAN_AND_MEAN 1
105 #endif /* !WIN32_LEAN_AND_MEAN */
106 #include <winsock2.h>
107 #include <ws2tcpip.h>
108 #endif /* _WIN32 && !__CYGWIN__ */
109
110 #if defined(__CYGWIN__) && ! defined(_SYS_TYPES_FD_SET)
111 /* Do not define __USE_W32_SOCKETS under Cygwin! */
112 #error Cygwin with winsock fd_set is not supported
113 #endif
114
115 #if defined(_WIN32) && ! defined(__CYGWIN__)
116 #define sleep(seconds) ((SleepEx ((seconds) * 1000, 1)==0) ? 0 : (seconds))
117 #define usleep(useconds) ((SleepEx ((useconds) / 1000, 1)==0) ? 0 : -1)
118 #endif
119
120 #if defined(_MSC_FULL_VER) && ! defined(_SSIZE_T_DEFINED)
121 #define _SSIZE_T_DEFINED
122 typedef intptr_t ssize_t;
123 #endif /* !_SSIZE_T_DEFINED */
124
125 #if ! defined(_WIN32) || defined(__CYGWIN__)
126 typedef time_t _MHD_TIMEVAL_TV_SEC_TYPE;
127 #else /* _WIN32 && ! __CYGWIN__ */
128 typedef long _MHD_TIMEVAL_TV_SEC_TYPE;
129 #endif /* _WIN32 && ! __CYGWIN__ */
130
131 #if ! defined(IPPROTO_IPV6) && defined(_MSC_FULL_VER) && _WIN32_WINNT >= 0x0501
132 /* VC use IPPROTO_IPV6 as part of enum */
133 #define IPPROTO_IPV6 IPPROTO_IPV6
134 #endif
135
136 #endif