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