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