2 This file is part of GNUnet.
3 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2012 GNUnet e.V.
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.
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.
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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
23 * @author Christian Grothoff
26 * Plaform specific includes and defines.
28 * This file should never be included by installed
29 * header files (those starting with "gnunet_").
34 #ifndef HAVE_USED_CONFIG_H
35 #define HAVE_USED_CONFIG_H
37 #include "gnunet_config.h"
42 #define BREAKPOINT asm ("int $3;");
43 #define GNUNET_SIGCHLD 17
46 #define GNUNET_SIGCHLD SIGCHLD
49 #ifdef HAVE_SYS_TYPES_H
50 #include <sys/types.h>
54 * These may be expensive, but good for debugging...
56 #define ALLOW_EXTRA_CHECKS GNUNET_YES
59 * For strptime (glibc2 needs this).
62 #define _XOPEN_SOURCE 499
69 /* configuration options */
71 #define VERBOSE_STATS 0
74 #include <sys/reent.h>
79 #define FD_SETSIZE 1024
86 #include <sys/socket.h>
89 #include <netinet/in.h>
91 #if HAVE_NETINET_IN_SYSTM_H
92 #include <netinet/in_systm.h>
95 #include <netinet/ip.h> /* superset of previous */
97 #include <arpa/inet.h>
98 #include <netinet/tcp.h>
100 #include <sys/ioctl.h>
101 #include <sys/wait.h>
118 #include <malloc.h> /* for alloca(), on other OSes it's in stdlib.h */
121 #include <malloc.h> /* for mallinfo on GNU */
124 #include <unistd.h> /* KLB_FIX */
126 #include <sys/stat.h>
127 #include <sys/types.h>
129 #include <dirent.h> /* KLB_FIX */
134 #include <sys/param.h>
136 #if TIME_WITH_SYS_TIME
137 #include <sys/time.h>
141 #include <sys/time.h>
151 #include <semaphore.h>
155 #include <semaphore.h>
158 #if defined(LINUX) || defined(GNU)
162 #include <sys/sockio.h>
163 #include <sys/filio.h>
164 #include <sys/loadavg.h>
165 #include <semaphore.h>
171 #include <sys/ucred.h>
175 #include <cygwin/if.h>
188 #if HAVE_SYS_RESOURCE_H
189 #include <sys/resource.h>
195 #if HAVE_SYS_ENDIAN_H
196 #include <sys/endian.h>
205 #define DIR_SEPARATOR '/'
206 #define DIR_SEPARATOR_STR "/"
207 #define PATH_SEPARATOR ':'
208 #define PATH_SEPARATOR_STR ":"
211 #define DIR_SEPARATOR '\\'
212 #define DIR_SEPARATOR_STR "\\"
213 #define PATH_SEPARATOR ';'
214 #define PATH_SEPARATOR_STR ";"
215 #define NEWLINE "\r\n"
221 #ifndef FRAMEWORK_BUILD
224 * GNU gettext support macro.
226 #define _(String) dgettext(PACKAGE, String)
227 #define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor"
229 #include "libintlemu.h"
230 #define _(String) dgettext("org.gnunet.gnunet", String)
231 #define LIBEXTRACTOR_GETTEXT_DOMAIN "org.gnunet.libextractor"
235 #define SIOCGIFCONF _IOW('s', 100, struct ifconf) /* get if list */
236 #define SIOCGIFFLAGS _IOW('s', 101, struct ifreq) /* Get if flags */
237 #define SIOCGIFADDR _IOW('s', 102, struct ifreq) /* Get if addr */
241 #include <sys/mman.h>
245 #define __BYTE_ORDER BYTE_ORDER
246 #define __BIG_ENDIAN BIG_ENDIAN
250 #define __BYTE_ORDER BYTE_ORDER
251 #define __BIG_ENDIAN BIG_ENDIAN
252 /* not available on darwin, override configure */
260 atoll(const char *nptr);
264 #include "langinfo.h"
268 #define SIZE_MAX ((size_t)(-1))
272 #define O_LARGEFILE 0
276 * AI_NUMERICSERV not defined in windows. Then we just do without.
278 #ifndef AI_NUMERICSERV
279 #define AI_NUMERICSERV 0
283 #if defined(__sparc__)
284 #define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove(&__tmp, &(val), sizeof((val))); __tmp; })
286 #define MAKE_UNALIGNED(val) val
290 #define FDTYPE HANDLE
291 #define SOCKTYPE SOCKET
298 * The termination signal
300 #define GNUNET_TERM_SIG SIGTERM
305 * Assumed maximum path length.
307 #define PATH_MAX 4096
310 #if HAVE_THREAD_LOCAL_GCC
311 #define GNUNET_THREAD_LOCAL __thread
313 #define GNUNET_THREAD_LOCAL
317 * clang et al do not have such an attribute
319 #if __has_attribute(__nonstring__)
320 # define __nonstring __attribute__((__nonstring__))