GNU libmicrohttpd  0.9.29
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
platform.h
Go to the documentation of this file.
1 /*
2  This file is part of libmicrohttpd
3  (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 
34 #ifndef MHD_PLATFORM_H
35 #define MHD_PLATFORM_H
36 
37 #include "MHD_config.h"
38 
39 #ifndef BUILDING_MHD_LIB
40 #ifdef _MHD_EXTERN
41 #undef _MHD_EXTERN
42 #endif /* _MHD_EXTERN */
43 #define _MHD_EXTERN extern
44 #endif /* BUILDING_MHD_LIB */
45 
46 #define _XOPEN_SOURCE_EXTENDED 1
47 #if OS390
48 #define _OPEN_THREADS
49 #define _OPEN_SYS_SOCK_IPV6
50 #define _OPEN_MSGQ_EXT
51 #define _LP64
52 #endif
53 
54 #include <stdio.h>
55 #include <stdlib.h>
56 #include <stdint.h>
57 #include <string.h>
58 #include <unistd.h>
59 #include <stdarg.h>
60 #include <errno.h>
61 #include <fcntl.h>
62 #include <signal.h>
63 #include <stddef.h>
64 #undef HAVE_CONFIG_H
65 #include <pthread.h>
66 #define HAVE_CONFIG_H 1
67 
68 /* different OSes have fd_set in
69  a broad range of header files;
70  we just include most of them (if they
71  are available) */
72 
73 
74 #ifdef OS_VXWORKS
75 #include <sockLib.h>
76 #include <netinet/in.h>
77 #include <stdarg.h>
78 #include <sys/mman.h>
79 #define RESTRICT __restrict__
80 #endif
81 #if HAVE_MEMORY_H
82 #include <memory.h>
83 #endif
84 
85 #if HAVE_SYS_SELECT_H
86 #include <sys/select.h>
87 #endif
88 #if HAVE_SYS_TYPES_H
89 #include <sys/types.h>
90 #endif
91 #if HAVE_SYS_TIME_H
92 #include <sys/time.h>
93 #endif
94 #if HAVE_SYS_STAT_H
95 #include <sys/stat.h>
96 #endif
97 #if HAVE_SYS_MSG_H
98 #include <sys/msg.h>
99 #endif
100 #if HAVE_SYS_MMAN_H
101 #include <sys/mman.h>
102 #endif
103 #if HAVE_NETDB_H
104 #include <netdb.h>
105 #endif
106 #if HAVE_NETINET_IN_H
107 #include <netinet/in.h>
108 #endif
109 #if HAVE_TIME_H
110 #include <time.h>
111 #endif
112 #if HAVE_SYS_SOCKET_H
113 #include <sys/socket.h>
114 #endif
115 #if HAVE_ARPA_INET_H
116 #include <arpa/inet.h>
117 #endif
118 
119 
120 #if defined(_WIN32) && !defined(__CYGWIN__)
121 #include <ws2tcpip.h>
122 #define sleep(seconds) (SleepEx((seconds)*1000, 1)/1000)
123 #define usleep(useconds) (void)SleepEx((useconds)/1000, 1)
124 #endif
125 
126 #if !defined(SHUT_WR) && defined(SD_SEND)
127 #define SHUT_WR SD_SEND
128 #endif
129 #if !defined(SHUT_RD) && defined(SD_RECEIVE)
130 #define SHUT_RD SD_RECEIVE
131 #endif
132 #if !defined(SHUT_RDWR) && defined(SD_BOTH)
133 #define SHUT_RDWR SD_BOTH
134 #endif
135 
136 #ifndef MHD_SOCKET_DEFINED
137 
140 #if !defined(_WIN32) || defined(_SYS_TYPES_FD_SET)
141 #define MHD_POSIX_SOCKETS 1
142 typedef int MHD_socket;
143 #define MHD_INVALID_SOCKET (-1)
144 #else /* !defined(_WIN32) || defined(_SYS_TYPES_FD_SET) */
145 #define MHD_WINSOCK_SOCKETS 1
146 #include <winsock2.h>
147 typedef SOCKET MHD_socket;
148 #define MHD_INVALID_SOCKET (INVALID_SOCKET)
149 #endif /* !defined(_WIN32) || defined(_SYS_TYPES_FD_SET) */
150 #define MHD_SOCKET_DEFINED 1
151 #endif /* MHD_SOCKET_DEFINED */
152 
153 /* Force don't use pipes on W32 */
154 #if defined(_WIN32) && !defined(MHD_DONT_USE_PIPES)
155 #define MHD_DONT_USE_PIPES 1
156 #endif /* defined(_WIN32) && !defined(MHD_DONT_USE_PIPES) */
157 
158 /* MHD_pipe is type for pipe FDs*/
159 #ifndef MHD_DONT_USE_PIPES
160 typedef int MHD_pipe;
161 #else /* ! MHD_DONT_USE_PIPES */
162 typedef MHD_socket MHD_pipe;
163 #endif /* ! MHD_DONT_USE_PIPES */
164 
165 #endif
int MHD_socket
Definition: microhttpd.h:174
int MHD_pipe
Definition: platform.h:160
int MHD_socket
Definition: platform.h:142