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