257fc7c6b1685d0eea85c773199a14925d02849f
[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 #else
44 #define BREAKPOINT
45 #endif
46
47 #ifdef HAVE_SYS_TYPES_H
48 #include <sys/types.h>
49 #endif
50
51 #define ALLOW_EXTRA_CHECKS GNUNET_NO
52
53 /**
54  * For strptime (glibc2 needs this).
55  */
56 #ifndef _XOPEN_SOURCE
57 #define _XOPEN_SOURCE
58 #endif
59
60 #ifndef _REENTRANT
61 #define _REENTRANT
62 #endif
63
64 /* configuration options */
65
66 #define VERBOSE_STATS 0
67
68 #ifdef CYGWIN
69 #include <sys/reent.h>
70 #define _REENT_ONLY
71 #endif
72
73 #ifdef CYGWIN
74 #undef _REENT_ONLY
75 #endif
76
77 #ifdef _MSC_VER
78 #include <Winsock2.h>
79 #else
80 #ifndef MINGW
81 #include <netdb.h>
82 #include <sys/socket.h>
83 #include <netinet/in.h>
84 #include <arpa/inet.h>
85 #include <netinet/tcp.h>
86 #include <pwd.h>
87 #include <sys/ioctl.h>
88 #include <sys/wait.h>
89 #include <grp.h>
90 #else
91 #include "winproc.h"
92 #endif
93 #endif
94
95 #include <string.h>
96 #include <stdio.h>
97 #include <stdlib.h>
98 #include <stdarg.h>
99 #include <errno.h>
100 #include <signal.h>
101 #ifndef _MSC_VER
102 #include <unistd.h>             /* KLB_FIX */
103 #endif
104 #include <sys/stat.h>
105 #include <sys/types.h>
106 #ifndef _MSC_VER
107 #include <dirent.h>             /* KLB_FIX */
108 #endif
109 #include <fcntl.h>
110 #include <math.h>
111 #if HAVE_SYS_PARAM_H
112 #include <sys/param.h>
113 #endif
114 #if TIME_WITH_SYS_TIME
115 #include <sys/time.h>
116 #include <time.h>
117 #else
118 #if HAVE_SYS_TIME_H
119 #include <sys/time.h>
120 #else
121 #include <time.h>
122 #endif
123 #endif
124
125 #ifdef SOMEBSD
126 #include <net/if.h>
127 #endif
128 #ifdef GNUNET_freeBSD
129 #include <semaphore.h>
130 #endif
131 #ifdef DARWIN
132 #include <dlfcn.h>
133 #include <semaphore.h>
134 #include <net/if.h>
135 #endif
136 #ifdef LINUX
137 #include <net/if.h>
138 #endif
139 #ifdef SOLARIS
140 #include <sys/sockio.h>
141 #include <sys/loadavg.h>
142 #include <semaphore.h>
143 #endif
144 #ifdef CYGWIN
145 #include <windows.h>
146 #include <cygwin/if.h>
147 #endif
148 #if HAVE_IFADDRS_H
149 #include <ifaddrs.h>
150 #endif
151 #include <errno.h>
152 #include <limits.h>
153
154 #if HAVE_CTYPE_H
155 #include <ctype.h>
156 #endif
157 #if HAVE_SYS_RESOURCE_H
158 #include <sys/resource.h>
159 #endif
160
161 #include "plibc.h"
162
163 #undef HAVE_CONFIG_H
164 #include <pthread.h>
165 #define HAVE_CONFIG_H 1
166 #include <locale.h>
167 #ifndef FRAMEWORK_BUILD
168 #include "gettext.h"
169 /**
170  * GNU gettext support macro.
171  */
172 #define _(String) dgettext("gnunet",String)
173 #define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor"
174 #else
175 #include "libintlemu.h"
176 #define _(String) dgettext("org.gnunet.gnunet",String)
177 #define LIBEXTRACTOR_GETTEXT_DOMAIN "org.gnunet.libextractor"
178 #endif
179
180 #ifdef CYGWIN
181 #define SIOCGIFCONF     _IOW('s', 100, struct ifconf)   /* get if list */
182 #define SIOCGIFFLAGS    _IOW('s', 101, struct ifreq)    /* Get if flags */
183 #define SIOCGIFADDR     _IOW('s', 102, struct ifreq)    /* Get if addr */
184 #endif
185
186 #ifndef MINGW
187 #include <sys/mman.h>
188 #endif
189
190 #ifdef FREEBSD
191 #define __BYTE_ORDER BYTE_ORDER
192 #define __BIG_ENDIAN BIG_ENDIAN
193 #endif
194
195 #ifdef DARWIN
196 #define __BYTE_ORDER BYTE_ORDER
197 #define __BIG_ENDIAN BIG_ENDIAN
198  /* not available on darwin, override configure */
199 #undef HAVE_STAT64
200 #undef HAVE_MREMAP
201 #endif
202
203
204 #if !HAVE_ATOLL
205 long long atoll (const char *nptr);
206 #endif
207
208 #if ENABLE_NLS
209 #include "langinfo.h"
210 #endif
211
212 #ifndef O_LARGEFILE
213 #define O_LARGEFILE 0
214 #endif
215
216 #if defined(__sparc__)
217 #define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove(&__tmp, &(val), sizeof((val))); __tmp; })
218 #else
219 #define MAKE_UNALIGNED(val) val
220 #endif
221
222 #endif