GNUnet  0.11.x
platform.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2012 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your 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  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
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 #define BREAKPOINT
42 #define GNUNET_SIGCHLD SIGCHLD
43 
44 #ifdef HAVE_SYS_TYPES_H
45 #include <sys/types.h>
46 #endif
47 
51 #define ALLOW_EXTRA_CHECKS GNUNET_YES
52 
56 #ifndef _XOPEN_SOURCE
57 #define _XOPEN_SOURCE 499
58 #endif
59 
60 #ifndef _REENTRANT
61 #define _REENTRANT
62 #endif
63 
64 /* configuration options */
65 
66 #define VERBOSE_STATS 0
67 
68 #include <netdb.h>
69 #include <sys/socket.h>
70 #include <sys/un.h>
71 #if HAVE_NETINET_IN_H
72 #include <netinet/in.h>
73 #endif
74 #if HAVE_NETINET_IN_SYSTM_H
75 #include <netinet/in_systm.h>
76 #endif
77 #if HAVE_NETINET_IP_H
78 #include <netinet/ip.h> /* superset of previous */
79 #endif
80 #include <arpa/inet.h>
81 #include <netinet/tcp.h>
82 #include <pwd.h>
83 #include <sys/ioctl.h>
84 #include <sys/wait.h>
85 #include <grp.h>
86 
87 #include <string.h>
88 #include <stdio.h>
89 #include <stdlib.h>
90 #include <stdint.h>
91 #include <stdarg.h>
92 #include <stdbool.h>
93 #include <errno.h>
94 #include <signal.h>
95 #include <libgen.h>
96 #ifdef HAVE_MALLOC_H
97 #include <malloc.h> /* for mallinfo on GNU */
98 #endif
99 #include <unistd.h> /* KLB_FIX */
100 #include <sys/stat.h>
101 #include <sys/types.h>
102 #include <dirent.h> /* KLB_FIX */
103 #include <fcntl.h>
104 #include <math.h>
105 #if HAVE_SYS_PARAM_H
106 #include <sys/param.h>
107 #endif
108 #if TIME_WITH_SYS_TIME
109 #include <sys/time.h>
110 #include <time.h>
111 #else
112 #if HAVE_SYS_TIME_H
113 #include <sys/time.h>
114 #else
115 #include <time.h>
116 #endif
117 #endif
118 
119 #ifdef SOMEBSD
120 #include <net/if.h>
121 #endif
122 #ifdef FREEBSD
123 #include <semaphore.h>
124 #endif
125 #ifdef DARWIN
126 #include <dlfcn.h>
127 #include <semaphore.h>
128 #include <net/if.h>
129 #endif
130 #if defined(LINUX) || defined(GNU)
131 #include <net/if.h>
132 #endif
133 #ifdef SOLARIS
134 #include <sys/sockio.h>
135 #include <sys/filio.h>
136 #include <sys/loadavg.h>
137 #include <semaphore.h>
138 #endif
139 #if HAVE_UCRED_H
140 #include <ucred.h>
141 #endif
142 #if HAVE_SYS_UCRED_H
143 #include <sys/ucred.h>
144 #endif
145 #if HAVE_IFADDRS_H
146 #include <ifaddrs.h>
147 #endif
148 #include <errno.h>
149 #include <limits.h>
150 
151 #if HAVE_VFORK_H
152 #include <vfork.h>
153 #endif
154 
155 #include <ctype.h>
156 #if HAVE_SYS_RESOURCE_H
157 #include <sys/resource.h>
158 #endif
159 
160 #if HAVE_ENDIAN_H
161 #include <endian.h>
162 #endif
163 #if HAVE_SYS_ENDIAN_H
164 #include <sys/endian.h>
165 #endif
166 
167 #define DIR_SEPARATOR '/'
168 #define DIR_SEPARATOR_STR "/"
169 #define PATH_SEPARATOR ':'
170 #define PATH_SEPARATOR_STR ":"
171 #define NEWLINE "\n"
172 
173 #include "compat.h"
174 
175 #include <locale.h>
176 #ifndef FRAMEWORK_BUILD
177 #include "gettext.h"
181 #define _(String) dgettext (PACKAGE, String)
182 #define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor"
183 #else
184 #include "libintlemu.h"
185 #define _(String) dgettext ("org.gnunet.gnunet", String)
186 #define LIBEXTRACTOR_GETTEXT_DOMAIN "org.gnunet.libextractor"
187 #endif
188 
189 #include <sys/mman.h>
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
207 atoll (const char *nptr);
208 
209 #endif
210 
211 #if ENABLE_NLS
212 #include "langinfo.h"
213 #endif
214 
215 #ifndef SIZE_MAX
216 #define SIZE_MAX ((size_t) (-1))
217 #endif
218 
219 #ifndef O_LARGEFILE
220 #define O_LARGEFILE 0
221 #endif
222 
226 #ifndef AI_NUMERICSERV
227 #define AI_NUMERICSERV 0
228 #endif
229 
230 
231 #if defined(__sparc__)
232 #define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove (&__tmp, &(val), \
233  sizeof((val))); \
234  __tmp; })
235 #else
236 #define MAKE_UNALIGNED(val) val
237 #endif
238 
242 #define GNUNET_TERM_SIG SIGTERM
243 
244 
245 #ifndef PATH_MAX
246 
249 #define PATH_MAX 4096
250 #endif
251 
252 #if HAVE_THREAD_LOCAL_GCC
253 #define GNUNET_THREAD_LOCAL __thread
254 #else
255 #define GNUNET_THREAD_LOCAL
256 #endif
257 
261 #if __has_attribute (__nonstring__)
262 # define __nonstring __attribute__((__nonstring__))
263 #else
264 # define __nonstring
265 #endif
266 
267 #endif
long long atoll(const char *nptr)