for w32 port
[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/loadavg.h>
152 #include <semaphore.h>
153 #endif
154 #ifdef CYGWIN
155 #include <windows.h>
156 #include <cygwin/if.h>
157 #endif
158 #if HAVE_IFADDRS_H
159 #include <ifaddrs.h>
160 #endif
161 #include <errno.h>
162 #include <limits.h>
163
164 #if HAVE_VFORK_H
165 #include <vfork.h>
166 #endif
167
168 #if HAVE_CTYPE_H
169 #include <ctype.h>
170 #endif
171 #if HAVE_SYS_RESOURCE_H
172 #include <sys/resource.h>
173 #endif
174
175 #include "plibc.h"
176
177 #include <locale.h>
178 #ifndef FRAMEWORK_BUILD
179 #include "gettext.h"
180 /**
181  * GNU gettext support macro.
182  */
183 #define _(String) dgettext("gnunet",String)
184 #define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor"
185 #else
186 #include "libintlemu.h"
187 #define _(String) dgettext("org.gnunet.gnunet",String)
188 #define LIBEXTRACTOR_GETTEXT_DOMAIN "org.gnunet.libextractor"
189 #endif
190
191 #ifdef CYGWIN
192 #define SIOCGIFCONF     _IOW('s', 100, struct ifconf)   /* get if list */
193 #define SIOCGIFFLAGS    _IOW('s', 101, struct ifreq)    /* Get if flags */
194 #define SIOCGIFADDR     _IOW('s', 102, struct ifreq)    /* Get if addr */
195 #endif
196
197 #ifndef MINGW
198 #include <sys/mman.h>
199 #endif
200
201 #ifdef FREEBSD
202 #define __BYTE_ORDER BYTE_ORDER
203 #define __BIG_ENDIAN BIG_ENDIAN
204 #endif
205
206 #ifdef DARWIN
207 #define __BYTE_ORDER BYTE_ORDER
208 #define __BIG_ENDIAN BIG_ENDIAN
209  /* not available on darwin, override configure */
210 #undef HAVE_STAT64
211 #undef HAVE_MREMAP
212 #endif
213
214
215 #if !HAVE_ATOLL
216 long long atoll (const char *nptr);
217 #endif
218
219 #if ENABLE_NLS
220 #include "langinfo.h"
221 #endif
222
223 #ifndef SIZE_MAX
224 #define SIZE_MAX ((size_t)(-1))
225 #endif
226
227 #ifndef O_LARGEFILE
228 #define O_LARGEFILE 0
229 #endif
230
231 #if defined(__sparc__)
232 #define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove(&__tmp, &(val), sizeof((val))); __tmp; })
233 #else
234 #define MAKE_UNALIGNED(val) val
235 #endif
236
237 #endif