messages for inter-controller overlay connect
[oweals/gnunet.git] / src / include / platform.h
1 /*
2      This file is part of GNUnet.
3      (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 2, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file include/platform.h
23  * @brief plaform specifics
24  *
25  * @author Nils Durner
26  *
27  * This file should never be included by installed
28  * header files (thos starting with "gnunet_").
29  */
30
31 #ifndef PLATFORM_H
32 #define PLATFORM_H
33
34 #ifndef HAVE_USED_CONFIG_H
35 #define HAVE_USED_CONFIG_H
36 #if HAVE_CONFIG_H
37 #include "gnunet_config.h"
38 #endif
39 #endif
40
41 #ifdef WINDOWS
42 #define BREAKPOINT asm("int $3;");
43 #define GNUNET_SIGCHLD 17
44 #else
45 #define BREAKPOINT
46 #define GNUNET_SIGCHLD SIGCHLD
47 #endif
48
49 #ifdef HAVE_SYS_TYPES_H
50 #include <sys/types.h>
51 #endif
52
53 #define ALLOW_EXTRA_CHECKS GNUNET_NO
54
55 /**
56  * For strptime (glibc2 needs this).
57  */
58 #ifndef _XOPEN_SOURCE
59 #define _XOPEN_SOURCE
60 #endif
61
62 #ifndef _REENTRANT
63 #define _REENTRANT
64 #endif
65
66 /* configuration options */
67
68 #define VERBOSE_STATS 0
69
70 #ifdef CYGWIN
71 #include <sys/reent.h>
72 #endif
73
74 #ifdef _MSC_VER
75 #ifndef FD_SETSIZE
76 #define FD_SETSIZE 1024
77 #endif
78 #include <Winsock2.h>
79 #include <ws2tcpip.h>
80 #else
81 #ifndef MINGW
82 #include <netdb.h>
83 #include <sys/socket.h>
84 #include <sys/un.h>
85 #if HAVE_NETINET_IN_H
86 #include <netinet/in.h>
87 #endif
88 #if HAVE_NETINET_IN_SYSTM_H
89 #include <netinet/in_systm.h>
90 #endif
91 #include <netinet/ip.h>         /* superset of previous */
92 #include <arpa/inet.h>
93 #include <netinet/tcp.h>
94 #include <pwd.h>
95 #include <sys/ioctl.h>
96 #include <sys/wait.h>
97 #include <grp.h>
98 #else
99 #include "winproc.h"
100 #endif
101 #endif
102
103 #include <string.h>
104 #include <stdio.h>
105 #include <stdlib.h>
106 #include <stdint.h>
107 #include <stdarg.h>
108 #include <errno.h>
109 #include <signal.h>
110 #include <libgen.h>
111 #ifdef WINDOWS
112 #include <malloc.h>             /* for alloca(), on other OSes it's in stdlib.h */
113 #endif
114 #ifndef _MSC_VER
115 #include <unistd.h>             /* KLB_FIX */
116 #endif
117 #include <sys/stat.h>
118 #include <sys/types.h>
119 #ifndef _MSC_VER
120 #include <dirent.h>             /* KLB_FIX */
121 #endif
122 #include <fcntl.h>
123 #include <math.h>
124 #if HAVE_SYS_PARAM_H
125 #include <sys/param.h>
126 #endif
127 #if TIME_WITH_SYS_TIME
128 #include <sys/time.h>
129 #include <time.h>
130 #else
131 #if HAVE_SYS_TIME_H
132 #include <sys/time.h>
133 #else
134 #include <time.h>
135 #endif
136 #endif
137
138 #ifdef SOMEBSD
139 #include <net/if.h>
140 #endif
141 #ifdef GNUNET_freeBSD
142 #include <semaphore.h>
143 #endif
144 #ifdef DARWIN
145 #include <dlfcn.h>
146 #include <semaphore.h>
147 #include <net/if.h>
148 #endif
149 #if defined(LINUX) || defined(GNU)
150 #include <net/if.h>
151 #endif
152 #ifdef SOLARIS
153 #include <sys/sockio.h>
154 #include <sys/filio.h>
155 #include <sys/loadavg.h>
156 #include <semaphore.h>
157 #endif
158 #if HAVE_UCRED_H
159 #include <ucred.h>
160 #endif
161 #ifdef CYGWIN
162 #include <windows.h>
163 #include <cygwin/if.h>
164 #endif
165 #if HAVE_IFADDRS_H
166 #include <ifaddrs.h>
167 #endif
168 #include <errno.h>
169 #include <limits.h>
170
171 #if HAVE_VFORK_H
172 #include <vfork.h>
173 #endif
174
175 #include <ctype.h>
176 #if HAVE_SYS_RESOURCE_H
177 #include <sys/resource.h>
178 #endif
179
180 #if HAVE_ENDIAN_H
181 #include <endian.h>
182 #endif
183 #if HAVE_SYS_ENDIAN_H
184 #include <sys/endian.h>
185 #endif
186
187 #include "plibc.h"
188
189 #include <locale.h>
190 #ifndef FRAMEWORK_BUILD
191 #include "gettext.h"
192 /**
193  * GNU gettext support macro.
194  */
195 #define _(String) dgettext("gnunet",String)
196 #define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor"
197 #else
198 #include "libintlemu.h"
199 #define _(String) dgettext("org.gnunet.gnunet",String)
200 #define LIBEXTRACTOR_GETTEXT_DOMAIN "org.gnunet.libextractor"
201 #endif
202
203 #ifdef CYGWIN
204 #define SIOCGIFCONF     _IOW('s', 100, struct ifconf)   /* get if list */
205 #define SIOCGIFFLAGS    _IOW('s', 101, struct ifreq)    /* Get if flags */
206 #define SIOCGIFADDR     _IOW('s', 102, struct ifreq)    /* Get if addr */
207 #endif
208
209 #ifndef MINGW
210 #include <sys/mman.h>
211 #endif
212
213 #ifdef FREEBSD
214 #define __BYTE_ORDER BYTE_ORDER
215 #define __BIG_ENDIAN BIG_ENDIAN
216 #endif
217
218 #ifdef DARWIN
219 #define __BYTE_ORDER BYTE_ORDER
220 #define __BIG_ENDIAN BIG_ENDIAN
221  /* not available on darwin, override configure */
222 #undef HAVE_STAT64
223 #undef HAVE_MREMAP
224 #endif
225
226
227 #if !HAVE_ATOLL
228 long long
229 atoll (const char *nptr);
230 #endif
231
232 #if ENABLE_NLS
233 #include "langinfo.h"
234 #endif
235
236 #ifndef SIZE_MAX
237 #define SIZE_MAX ((size_t)(-1))
238 #endif
239
240 #ifndef O_LARGEFILE
241 #define O_LARGEFILE 0
242 #endif
243
244 /**
245  * AI_NUMERICSERV not defined in windows.  Then we just do without.
246  */
247 #ifndef AI_NUMERICSERV
248 #define AI_NUMERICSERV 0
249 #endif
250
251
252 #if defined(__sparc__)
253 #define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove(&__tmp, &(val), sizeof((val))); __tmp; })
254 #else
255 #define MAKE_UNALIGNED(val) val
256 #endif
257
258 #if WINDOWS
259 #define FDTYPE HANDLE
260 #define SOCKTYPE SOCKET
261 #else
262 #define FDTYPE int
263 #define SOCKTYPE int
264 #endif
265
266 #endif