removed additional >
[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 #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 #include <netinet/ip.h> /* superset of previous */
93 #include <arpa/inet.h>
94 #include <netinet/tcp.h>
95 #include <pwd.h>
96 #include <sys/ioctl.h>
97 #include <sys/wait.h>
98 #include <grp.h>
99 #else
100 #include "winproc.h"
101 #endif
102 #endif
103
104 #include <string.h>
105 #include <stdio.h>
106 #include <stdlib.h>
107 #include <stdint.h>
108 #include <stdarg.h>
109 #include <errno.h>
110 #include <signal.h>
111 #ifndef _MSC_VER
112 #include <unistd.h>             /* KLB_FIX */
113 #endif
114 #include <sys/stat.h>
115 #include <sys/types.h>
116 #ifndef _MSC_VER
117 #include <dirent.h>             /* KLB_FIX */
118 #endif
119 #include <fcntl.h>
120 #include <math.h>
121 #if HAVE_SYS_PARAM_H
122 #include <sys/param.h>
123 #endif
124 #if TIME_WITH_SYS_TIME
125 #include <sys/time.h>
126 #include <time.h>
127 #else
128 #if HAVE_SYS_TIME_H
129 #include <sys/time.h>
130 #else
131 #include <time.h>
132 #endif
133 #endif
134
135 #ifdef SOMEBSD
136 #include <net/if.h>
137 #endif
138 #ifdef GNUNET_freeBSD
139 #include <semaphore.h>
140 #endif
141 #ifdef DARWIN
142 #include <dlfcn.h>
143 #include <semaphore.h>
144 #include <net/if.h>
145 #endif
146 #ifdef LINUX
147 #include <net/if.h>
148 #endif
149 #ifdef SOLARIS
150 #include <sys/sockio.h>
151 #include <sys/filio.h>
152 #include <sys/loadavg.h>
153 #include <semaphore.h>
154 #endif
155 #ifdef CYGWIN
156 #include <windows.h>
157 #include <cygwin/if.h>
158 #endif
159 #if HAVE_IFADDRS_H
160 #include <ifaddrs.h>
161 #endif
162 #include <errno.h>
163 #include <limits.h>
164
165 #if HAVE_VFORK_H
166 #include <vfork.h>
167 #endif
168
169 #if HAVE_CTYPE_H
170 #include <ctype.h>
171 #endif
172 #if HAVE_SYS_RESOURCE_H
173 #include <sys/resource.h>
174 #endif
175
176 #include "plibc.h"
177
178 #include <locale.h>
179 #ifndef FRAMEWORK_BUILD
180 #include "gettext.h"
181 /**
182  * GNU gettext support macro.
183  */
184 #define _(String) dgettext("gnunet",String)
185 #define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor"
186 #else
187 #include "libintlemu.h"
188 #define _(String) dgettext("org.gnunet.gnunet",String)
189 #define LIBEXTRACTOR_GETTEXT_DOMAIN "org.gnunet.libextractor"
190 #endif
191
192 #ifdef CYGWIN
193 #define SIOCGIFCONF     _IOW('s', 100, struct ifconf)   /* get if list */
194 #define SIOCGIFFLAGS    _IOW('s', 101, struct ifreq)    /* Get if flags */
195 #define SIOCGIFADDR     _IOW('s', 102, struct ifreq)    /* Get if addr */
196 #endif
197
198 #ifndef MINGW
199 #include <sys/mman.h>
200 #endif
201
202 #ifdef FREEBSD
203 #define __BYTE_ORDER BYTE_ORDER
204 #define __BIG_ENDIAN BIG_ENDIAN
205 #endif
206
207 #ifdef DARWIN
208 #define __BYTE_ORDER BYTE_ORDER
209 #define __BIG_ENDIAN BIG_ENDIAN
210  /* not available on darwin, override configure */
211 #undef HAVE_STAT64
212 #undef HAVE_MREMAP
213 #endif
214
215
216 #if !HAVE_ATOLL
217 long long atoll (const char *nptr);
218 #endif
219
220 #if ENABLE_NLS
221 #include "langinfo.h"
222 #endif
223
224 #ifndef SIZE_MAX
225 #define SIZE_MAX ((size_t)(-1))
226 #endif
227
228 #ifndef O_LARGEFILE
229 #define O_LARGEFILE 0
230 #endif
231
232 #if defined(__sparc__)
233 #define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove(&__tmp, &(val), sizeof((val))); __tmp; })
234 #else
235 #define MAKE_UNALIGNED(val) val
236 #endif
237
238 #endif