GNUnet 0.22.2
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_private_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#include <inttypes.h>
48
49#ifdef __clang__
50#undef HAVE_STATIC_ASSERT
51#endif
52
56#define ALLOW_EXTRA_CHECKS GNUNET_YES
57
61#ifndef _XOPEN_SOURCE
62#define _XOPEN_SOURCE 499
63#endif
64
65#ifndef _REENTRANT
66#define _REENTRANT
67#endif
68
69/* configuration options */
70
71#define VERBOSE_STATS 0
72
73#include <netdb.h>
74#include <sys/socket.h>
75#include <sys/un.h>
76#if HAVE_NETINET_IN_H
77#include <netinet/in.h>
78#endif
79#if HAVE_NETINET_IN_SYSTM_H
80#include <netinet/in_systm.h>
81#endif
82#if HAVE_NETINET_IP_H
83#include <netinet/ip.h> /* superset of previous */
84#endif
85#include <arpa/inet.h>
86#include <netinet/tcp.h>
87#include <pwd.h>
88#include <sys/ioctl.h>
89#include <sys/wait.h>
90#include <grp.h>
91
92#include <string.h>
93#include <stdio.h>
94#include <stdlib.h>
95#include <stdint.h>
96#include <stdarg.h>
97#include <stdbool.h>
98#include <errno.h>
99#include <signal.h>
100#include <libgen.h>
101#ifdef HAVE_MALLOC_H
102#include <malloc.h> /* for mallinfo on GNU */
103#endif
104#include <unistd.h> /* KLB_FIX */
105#include <sys/stat.h>
106#include <sys/types.h>
107#include <dirent.h> /* KLB_FIX */
108#include <fcntl.h>
109#include <math.h>
110#if HAVE_SYS_PARAM_H
111#include <sys/param.h>
112#endif
113#if HAVE_SYS_TIME_H
114#include <sys/time.h>
115#endif
116#include <time.h>
117#ifdef BSD
118#include <net/if.h>
119#endif
120#if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__)
121#include <semaphore.h>
122#endif
123#ifdef DARWIN
124#include <dlfcn.h>
125#include <semaphore.h>
126#include <net/if.h>
127#include <xlocale.h>
128#endif
129#if defined(__linux__) || defined(GNU)
130#include <net/if.h>
131#endif
132#ifdef SOLARIS
133#include <sys/sockio.h>
134#include <sys/filio.h>
135#include <sys/loadavg.h>
136#include <semaphore.h>
137#endif
138#if HAVE_UCRED_H
139#include <ucred.h>
140#endif
141#if HAVE_SYS_UCRED_H
142#include <sys/ucred.h>
143#endif
144#if HAVE_IFADDRS_H
145#include <ifaddrs.h>
146#endif
147#include <errno.h>
148#include <limits.h>
149
150#if HAVE_VFORK_H
151#include <vfork.h>
152#endif
153
154#include <ctype.h>
155#if HAVE_SYS_RESOURCE_H
156#include <sys/resource.h>
157#endif
158
159#if HAVE_ENDIAN_H
160#include <endian.h>
161#endif
162#if HAVE_SYS_ENDIAN_H
163#include <sys/endian.h>
164#endif
165
166#define DIR_SEPARATOR '/'
167#define DIR_SEPARATOR_STR "/"
168#define PATH_SEPARATOR ':'
169#define PATH_SEPARATOR_STR ":"
170#define NEWLINE "\n"
171
172#include "compat.h"
173
174#include <locale.h>
175#include "gettext.h"
179#define _(String) dgettext (PACKAGE, String)
180#define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor"
181
182#include <sys/mman.h>
183
184/* FreeBSD_kernel is not defined on the now discontinued kFreeBSD */
185#if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__)
186#define __BYTE_ORDER BYTE_ORDER
187#define __BIG_ENDIAN BIG_ENDIAN
188#endif
189
190#ifdef DARWIN
191#define __BYTE_ORDER BYTE_ORDER
192#define __BIG_ENDIAN BIG_ENDIAN
193/* not available on darwin, override configure */
194#undef HAVE_STAT64
195#undef HAVE_MREMAP
196#endif
197
198#if ! HAVE_ATOLL
199long long
200atoll (const char *nptr);
201
202#endif
203
204#if ENABLE_NLS
205#include "langinfo.h"
206#endif
207
208#ifndef SIZE_MAX
209#define SIZE_MAX ((size_t) (-1))
210#endif
211
212#ifndef O_LARGEFILE
213#define O_LARGEFILE 0
214#endif
215
219#ifndef AI_NUMERICSERV
220#define AI_NUMERICSERV 0
221#endif
222
223
224#if defined(__sparc__)
225#define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove (&__tmp, &(val), \
226 sizeof((val))); \
227 __tmp; })
228#else
229#define MAKE_UNALIGNED(val) val
230#endif
231
235#define GNUNET_TERM_SIG SIGTERM
236
237
238#ifndef PATH_MAX
242#define PATH_MAX 4096
243#endif
244
245#if HAVE_THREAD_LOCAL_GCC
246#define GNUNET_THREAD_LOCAL __thread
247#else
248#define GNUNET_THREAD_LOCAL
249#endif
250
251
252/* LSB-style exit status codes */
253#ifndef EXIT_INVALIDARGUMENT
254#define EXIT_INVALIDARGUMENT 2
255#endif
256
257#ifndef EXIT_NOTIMPLEMENTED
258#define EXIT_NOTIMPLEMENTED 3
259#endif
260
261#ifndef EXIT_NOPERMISSION
262#define EXIT_NOPERMISSION 4
263#endif
264
265#ifndef EXIT_NOTINSTALLED
266#define EXIT_NOTINSTALLED 5
267#endif
268
269#ifndef EXIT_NOTCONFIGURED
270#define EXIT_NOTCONFIGURED 6
271#endif
272
273#ifndef EXIT_NOTRUNNING
274#define EXIT_NOTRUNNING 7
275#endif
276
277#ifndef EXIT_NO_RESTART
278#define EXIT_NO_RESTART 9
279#endif
280
284#if __has_attribute (__nonstring__)
285# define __nonstring __attribute__((__nonstring__))
286#else
287# define __nonstring
288#endif
289
290#endif
long long atoll(const char *nptr)