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