use -Wl on -no-undefined as it is a linker option:
[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 /**
52  * These may be expensive, but good for debugging...
53  */
54 #define ALLOW_EXTRA_CHECKS GNUNET_YES
55
56 /**
57  * For strptime (glibc2 needs this).
58  */
59 #ifndef _XOPEN_SOURCE
60 #define _XOPEN_SOURCE 499
61 #endif
62
63 #ifndef _REENTRANT
64 #define _REENTRANT
65 #endif
66
67 /* configuration options */
68
69 #define VERBOSE_STATS 0
70
71 #ifdef CYGWIN
72 #include <sys/reent.h>
73 #endif
74
75 #ifdef _MSC_VER
76 #ifndef FD_SETSIZE
77 #define FD_SETSIZE 1024
78 #endif
79 #include <Winsock2.h>
80 #include <ws2tcpip.h>
81 #else
82 #ifndef MINGW
83 #include <netdb.h>
84 #include <sys/socket.h>
85 #include <sys/un.h>
86 #if HAVE_NETINET_IN_H
87 #include <netinet/in.h>
88 #endif
89 #if HAVE_NETINET_IN_SYSTM_H
90 #include <netinet/in_systm.h>
91 #endif
92 #if HAVE_NETINET_IP_H
93 #include <netinet/ip.h>         /* superset of previous */
94 #endif
95 #include <arpa/inet.h>
96 #include <netinet/tcp.h>
97 #include <pwd.h>
98 #include <sys/ioctl.h>
99 #include <sys/wait.h>
100 #include <grp.h>
101 #else
102 #include "winproc.h"
103 #endif
104 #endif
105
106 #include <string.h>
107 #include <stdio.h>
108 #include <stdlib.h>
109 #include <stdint.h>
110 #include <stdarg.h>
111 #include <errno.h>
112 #include <signal.h>
113 #include <libgen.h>
114 #ifdef WINDOWS
115 #include <malloc.h>             /* for alloca(), on other OSes it's in stdlib.h */
116 #endif
117 #ifdef HAVE_MALLOC_H
118 #include <malloc.h>             /* for mallinfo on GNU */
119 #endif
120 #ifndef _MSC_VER
121 #include <unistd.h>             /* KLB_FIX */
122 #endif
123 #include <sys/stat.h>
124 #include <sys/types.h>
125 #ifndef _MSC_VER
126 #include <dirent.h>             /* KLB_FIX */
127 #endif
128 #include <fcntl.h>
129 #include <math.h>
130 #if HAVE_SYS_PARAM_H
131 #include <sys/param.h>
132 #endif
133 #if TIME_WITH_SYS_TIME
134 #include <sys/time.h>
135 #include <time.h>
136 #else
137 #if HAVE_SYS_TIME_H
138 #include <sys/time.h>
139 #else
140 #include <time.h>
141 #endif
142 #endif
143
144 #ifdef SOMEBSD
145 #include <net/if.h>
146 #endif
147 #ifdef FREEBSD
148 #include <semaphore.h>
149 #endif
150 #ifdef DARWIN
151 #include <dlfcn.h>
152 #include <semaphore.h>
153 #include <net/if.h>
154 #endif
155 #if defined(LINUX) || defined(GNU)
156 #include <net/if.h>
157 #endif
158 #ifdef SOLARIS
159 #include <sys/sockio.h>
160 #include <sys/filio.h>
161 #include <sys/loadavg.h>
162 #include <semaphore.h>
163 #endif
164 #if HAVE_UCRED_H
165 #include <ucred.h>
166 #endif
167 #if HAVE_SYS_UCRED_H
168 #include <sys/ucred.h>
169 #endif
170 #ifdef CYGWIN
171 #include <windows.h>
172 #include <cygwin/if.h>
173 #endif
174 #if HAVE_IFADDRS_H
175 #include <ifaddrs.h>
176 #endif
177 #include <errno.h>
178 #include <limits.h>
179
180 #if HAVE_VFORK_H
181 #include <vfork.h>
182 #endif
183
184 #include <ctype.h>
185 #if HAVE_SYS_RESOURCE_H
186 #include <sys/resource.h>
187 #endif
188
189 #if HAVE_ENDIAN_H
190 #include <endian.h>
191 #endif
192 #if HAVE_SYS_ENDIAN_H
193 #include <sys/endian.h>
194 #endif
195
196 #include "plibc.h"
197
198 #include <locale.h>
199 #ifndef FRAMEWORK_BUILD
200 #include "gettext.h"
201 /**
202  * GNU gettext support macro.
203  */
204 #define _(String) dgettext("gnunet",String)
205 #define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor"
206 #else
207 #include "libintlemu.h"
208 #define _(String) dgettext("org.gnunet.gnunet",String)
209 #define LIBEXTRACTOR_GETTEXT_DOMAIN "org.gnunet.libextractor"
210 #endif
211
212 #ifdef CYGWIN
213 #define SIOCGIFCONF     _IOW('s', 100, struct ifconf)   /* get if list */
214 #define SIOCGIFFLAGS    _IOW('s', 101, struct ifreq)    /* Get if flags */
215 #define SIOCGIFADDR     _IOW('s', 102, struct ifreq)    /* Get if addr */
216 #endif
217
218 #ifndef MINGW
219 #include <sys/mman.h>
220 #endif
221
222 #ifdef FREEBSD
223 #define __BYTE_ORDER BYTE_ORDER
224 #define __BIG_ENDIAN BIG_ENDIAN
225 #endif
226
227 #ifdef DARWIN
228 #define __BYTE_ORDER BYTE_ORDER
229 #define __BIG_ENDIAN BIG_ENDIAN
230  /* not available on darwin, override configure */
231 #undef HAVE_STAT64
232 #undef HAVE_MREMAP
233 #endif
234
235
236 #if !HAVE_ATOLL
237 long long
238 atoll (const char *nptr);
239 #endif
240
241 #if ENABLE_NLS
242 #include "langinfo.h"
243 #endif
244
245 #ifndef SIZE_MAX
246 #define SIZE_MAX ((size_t)(-1))
247 #endif
248
249 #ifndef O_LARGEFILE
250 #define O_LARGEFILE 0
251 #endif
252
253 /**
254  * AI_NUMERICSERV not defined in windows.  Then we just do without.
255  */
256 #ifndef AI_NUMERICSERV
257 #define AI_NUMERICSERV 0
258 #endif
259
260
261 #if defined(__sparc__)
262 #define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove(&__tmp, &(val), sizeof((val))); __tmp; })
263 #else
264 #define MAKE_UNALIGNED(val) val
265 #endif
266
267 #if WINDOWS
268 #define FDTYPE HANDLE
269 #define SOCKTYPE SOCKET
270 #else
271 #define FDTYPE int
272 #define SOCKTYPE int
273 #endif
274
275 /**
276  * The termination signal
277  */
278 #define GNUNET_TERM_SIG SIGTERM
279
280 #endif