check
[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 #define _REENT_ONLY
73 #endif
74
75 #ifdef CYGWIN
76 #undef _REENT_ONLY
77 #endif
78
79 #ifdef _MSC_VER
80 #include <Winsock2.h>
81 #include <ws2tcpip.h>
82 #else
83 #ifndef MINGW
84 #include <netdb.h>
85 #include <sys/socket.h>
86 #include <sys/un.h>
87 #if HAVE_NETINET_IN_H
88 #include <netinet/in.h>
89 #endif
90 #if HAVE_NETINET_IN_SYSTM_H
91 #include <netinet/in_systm.h>
92 #endif
93 #include <netinet/ip.h> /* superset of previous */
94 #include <arpa/inet.h>
95 #include <netinet/tcp.h>
96 #include <pwd.h>
97 #include <sys/ioctl.h>
98 #include <sys/wait.h>
99 #include <grp.h>
100 #else
101 #include "winproc.h"
102 #endif
103 #endif
104
105 #include <string.h>
106 #include <stdio.h>
107 #include <stdlib.h>
108 #include <stdint.h>
109 #include <stdarg.h>
110 #include <errno.h>
111 #include <signal.h>
112 #ifdef WINDOWS
113 #include <malloc.h> /* for alloca(), on other OSes it's in stdlib.h */
114 #endif
115 #ifndef _MSC_VER
116 #include <unistd.h>             /* KLB_FIX */
117 #endif
118 #include <sys/stat.h>
119 #include <sys/types.h>
120 #ifndef _MSC_VER
121 #include <dirent.h>             /* KLB_FIX */
122 #endif
123 #include <fcntl.h>
124 #include <math.h>
125 #if HAVE_SYS_PARAM_H
126 #include <sys/param.h>
127 #endif
128 #if TIME_WITH_SYS_TIME
129 #include <sys/time.h>
130 #include <time.h>
131 #else
132 #if HAVE_SYS_TIME_H
133 #include <sys/time.h>
134 #else
135 #include <time.h>
136 #endif
137 #endif
138
139 #ifdef SOMEBSD
140 #include <net/if.h>
141 #endif
142 #ifdef GNUNET_freeBSD
143 #include <semaphore.h>
144 #endif
145 #ifdef DARWIN
146 #include <dlfcn.h>
147 #include <semaphore.h>
148 #include <net/if.h>
149 #endif
150 #ifdef LINUX
151 #include <net/if.h>
152 #endif
153 #ifdef SOLARIS
154 #include <sys/sockio.h>
155 #include <sys/filio.h>
156 #include <sys/loadavg.h>
157 #include <semaphore.h>
158 #endif
159 #if HAVE_UCRED_H
160 #include <ucred.h>
161 #endif
162 #ifdef CYGWIN
163 #include <windows.h>
164 #include <cygwin/if.h>
165 #endif
166 #if HAVE_IFADDRS_H
167 #include <ifaddrs.h>
168 #endif
169 #include <errno.h>
170 #include <limits.h>
171
172 #if HAVE_VFORK_H
173 #include <vfork.h>
174 #endif
175
176 #include <ctype.h>
177 #if HAVE_SYS_RESOURCE_H
178 #include <sys/resource.h>
179 #endif
180
181 #if HAVE_ENDIAN_H
182 #include <endian.h>
183 #endif
184 #if HAVE_SYS_ENDIAN_H
185 #include <sys/endian.h>
186 #endif
187
188 #include "plibc.h"
189
190 #include <locale.h>
191 #ifndef FRAMEWORK_BUILD
192 #include "gettext.h"
193 /**
194  * GNU gettext support macro.
195  */
196 #define _(String) dgettext("gnunet",String)
197 #define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor"
198 #else
199 #include "libintlemu.h"
200 #define _(String) dgettext("org.gnunet.gnunet",String)
201 #define LIBEXTRACTOR_GETTEXT_DOMAIN "org.gnunet.libextractor"
202 #endif
203
204 #ifdef CYGWIN
205 #define SIOCGIFCONF     _IOW('s', 100, struct ifconf)   /* get if list */
206 #define SIOCGIFFLAGS    _IOW('s', 101, struct ifreq)    /* Get if flags */
207 #define SIOCGIFADDR     _IOW('s', 102, struct ifreq)    /* Get if addr */
208 #endif
209
210 #ifndef MINGW
211 #include <sys/mman.h>
212 #endif
213
214 #ifdef FREEBSD
215 #define __BYTE_ORDER BYTE_ORDER
216 #define __BIG_ENDIAN BIG_ENDIAN
217 #endif
218
219 #ifdef DARWIN
220 #define __BYTE_ORDER BYTE_ORDER
221 #define __BIG_ENDIAN BIG_ENDIAN
222  /* not available on darwin, override configure */
223 #undef HAVE_STAT64
224 #undef HAVE_MREMAP
225 #endif
226
227
228 #if !HAVE_ATOLL
229 long long 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 #if defined(__sparc__)
245 #define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove(&__tmp, &(val), sizeof((val))); __tmp; })
246 #else
247 #define MAKE_UNALIGNED(val) val
248 #endif
249
250 #endif