- key generation for secretsharing
[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, 2012 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 3, 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 specific includes and defines
24  * @author Nils Durner
25  * @author Christian Grothoff
26  * This file should never be included by installed
27  * header files (those starting with "gnunet_").
28  */
29 #ifndef PLATFORM_H
30 #define PLATFORM_H
31
32 #ifndef HAVE_USED_CONFIG_H
33 #define HAVE_USED_CONFIG_H
34 #if HAVE_CONFIG_H
35 #include "gnunet_config.h"
36 #endif
37 #endif
38
39 #ifdef WINDOWS
40 #define BREAKPOINT asm("int $3;");
41 #define GNUNET_SIGCHLD 17
42 #else
43 #define BREAKPOINT
44 #define GNUNET_SIGCHLD SIGCHLD
45 #endif
46
47 #ifdef HAVE_SYS_TYPES_H
48 #include <sys/types.h>
49 #endif
50
51 #define ALLOW_EXTRA_CHECKS GNUNET_NO
52
53 /**
54  * For strptime (glibc2 needs this).
55  */
56 #ifndef _XOPEN_SOURCE
57 #define _XOPEN_SOURCE 499
58 #endif
59
60 #ifndef _REENTRANT
61 #define _REENTRANT
62 #endif
63
64 /* configuration options */
65
66 #define VERBOSE_STATS 0
67
68 #ifdef CYGWIN
69 #include <sys/reent.h>
70 #endif
71
72 #ifdef _MSC_VER
73 #ifndef FD_SETSIZE
74 #define FD_SETSIZE 1024
75 #endif
76 #include <Winsock2.h>
77 #include <ws2tcpip.h>
78 #else
79 #ifndef MINGW
80 #include <netdb.h>
81 #include <sys/socket.h>
82 #include <sys/un.h>
83 #if HAVE_NETINET_IN_H
84 #include <netinet/in.h>
85 #endif
86 #if HAVE_NETINET_IN_SYSTM_H
87 #include <netinet/in_systm.h>
88 #endif
89 #if HAVE_NETINET_IP_H
90 #include <netinet/ip.h>         /* superset of previous */
91 #endif
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 #ifdef HAVE_MALLOC_H
115 #include <malloc.h>             /* for mallinfo on GNU */
116 #endif
117 #ifndef _MSC_VER
118 #include <unistd.h>             /* KLB_FIX */
119 #endif
120 #include <sys/stat.h>
121 #include <sys/types.h>
122 #ifndef _MSC_VER
123 #include <dirent.h>             /* KLB_FIX */
124 #endif
125 #include <fcntl.h>
126 #include <math.h>
127 #if HAVE_SYS_PARAM_H
128 #include <sys/param.h>
129 #endif
130 #if TIME_WITH_SYS_TIME
131 #include <sys/time.h>
132 #include <time.h>
133 #else
134 #if HAVE_SYS_TIME_H
135 #include <sys/time.h>
136 #else
137 #include <time.h>
138 #endif
139 #endif
140
141 #ifdef SOMEBSD
142 #include <net/if.h>
143 #endif
144 #ifdef FREEBSD
145 #include <semaphore.h>
146 #endif
147 #ifdef DARWIN
148 #include <dlfcn.h>
149 #include <semaphore.h>
150 #include <net/if.h>
151 #endif
152 #if defined(LINUX) || defined(GNU)
153 #include <net/if.h>
154 #endif
155 #ifdef SOLARIS
156 #include <sys/sockio.h>
157 #include <sys/filio.h>
158 #include <sys/loadavg.h>
159 #include <semaphore.h>
160 #endif
161 #if HAVE_UCRED_H
162 #include <ucred.h>
163 #endif
164 #ifdef CYGWIN
165 #include <windows.h>
166 #include <cygwin/if.h>
167 #endif
168 #if HAVE_IFADDRS_H
169 #include <ifaddrs.h>
170 #endif
171 #include <errno.h>
172 #include <limits.h>
173
174 #if HAVE_VFORK_H
175 #include <vfork.h>
176 #endif
177
178 #include <ctype.h>
179 #if HAVE_SYS_RESOURCE_H
180 #include <sys/resource.h>
181 #endif
182
183 #if HAVE_ENDIAN_H
184 #include <endian.h>
185 #endif
186 #if HAVE_SYS_ENDIAN_H
187 #include <sys/endian.h>
188 #endif
189
190 #include "plibc.h"
191
192 #include <locale.h>
193 #ifndef FRAMEWORK_BUILD
194 #include "gettext.h"
195 /**
196  * GNU gettext support macro.
197  */
198 #define _(String) dgettext("gnunet",String)
199 #define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor"
200 #else
201 #include "libintlemu.h"
202 #define _(String) dgettext("org.gnunet.gnunet",String)
203 #define LIBEXTRACTOR_GETTEXT_DOMAIN "org.gnunet.libextractor"
204 #endif
205
206 #ifdef CYGWIN
207 #define SIOCGIFCONF     _IOW('s', 100, struct ifconf)   /* get if list */
208 #define SIOCGIFFLAGS    _IOW('s', 101, struct ifreq)    /* Get if flags */
209 #define SIOCGIFADDR     _IOW('s', 102, struct ifreq)    /* Get if addr */
210 #endif
211
212 #ifndef MINGW
213 #include <sys/mman.h>
214 #endif
215
216 #ifdef FREEBSD
217 #define __BYTE_ORDER BYTE_ORDER
218 #define __BIG_ENDIAN BIG_ENDIAN
219 #endif
220
221 #ifdef DARWIN
222 #define __BYTE_ORDER BYTE_ORDER
223 #define __BIG_ENDIAN BIG_ENDIAN
224  /* not available on darwin, override configure */
225 #undef HAVE_STAT64
226 #undef HAVE_MREMAP
227 #endif
228
229
230 #if !HAVE_ATOLL
231 long long
232 atoll (const char *nptr);
233 #endif
234
235 #if ENABLE_NLS
236 #include "langinfo.h"
237 #endif
238
239 #ifndef SIZE_MAX
240 #define SIZE_MAX ((size_t)(-1))
241 #endif
242
243 #ifndef O_LARGEFILE
244 #define O_LARGEFILE 0
245 #endif
246
247 /**
248  * AI_NUMERICSERV not defined in windows.  Then we just do without.
249  */
250 #ifndef AI_NUMERICSERV
251 #define AI_NUMERICSERV 0
252 #endif
253
254
255 #if defined(__sparc__)
256 #define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove(&__tmp, &(val), sizeof((val))); __tmp; })
257 #else
258 #define MAKE_UNALIGNED(val) val
259 #endif
260
261 #if WINDOWS
262 #define FDTYPE HANDLE
263 #define SOCKTYPE SOCKET
264 #else
265 #define FDTYPE int
266 #define SOCKTYPE int
267 #endif
268
269 /**
270  * The termination signal
271  */
272 #define GNUNET_TERM_SIG SIGTERM
273
274 #endif