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