platform.h (5852B)
1 /* 2 This file is part of Frosix 3 Copyright (C) 2014, 2015, 2016, 2021 Anastasis SARL 4 5 Frosix is free software; you can redistribute it and/or modify it under the 6 terms of the GNU Affero General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 Frosix is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. 12 13 You should have received a copy of the GNU Affero General Public License along with 14 Frosix; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 17 /** 18 * @file include/platform.h 19 * @brief This file contains the includes and definitions which are used by the 20 * rest of the modules 21 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 22 */ 23 24 #ifndef PLATFORM_H_ 25 #define PLATFORM_H_ 26 27 /* Include our configuration header */ 28 #ifndef HAVE_USED_CONFIG_H 29 #define HAVE_USED_CONFIG_H 30 #ifdef HAVE_CONFIG_H 31 #include "frosix_config.h" 32 #endif 33 #endif 34 35 36 #if (GNUNET_EXTRA_LOGGING >= 1) 37 #define VERBOSE(cmd) cmd 38 #else 39 #define VERBOSE(cmd) do { break; } while (0) 40 #endif 41 42 43 /* LSB-style exit status codes */ 44 #ifndef EXIT_INVALIDARGUMENT 45 #define EXIT_INVALIDARGUMENT 2 46 #endif 47 48 #ifndef EXIT_NOTIMPLEMENTED 49 #define EXIT_NOTIMPLEMENTED 3 50 #endif 51 52 #ifndef EXIT_NOPERMISSION 53 #define EXIT_NOPERMISSION 4 54 #endif 55 56 #ifndef EXIT_NOTINSTALLED 57 #define EXIT_NOTINSTALLED 5 58 #endif 59 60 #ifndef EXIT_NOTCONFIGURED 61 #define EXIT_NOTCONFIGURED 6 62 #endif 63 64 #ifndef EXIT_NOTRUNNING 65 #define EXIT_NOTRUNNING 7 66 #endif 67 68 69 /* Include the features available for GNU source */ 70 #define _GNU_SOURCE 71 72 73 #ifdef HAVE_SYS_TYPES_H 74 #include <sys/types.h> 75 #endif 76 77 #ifdef __clang__ 78 #undef HAVE_STATIC_ASSERT 79 #endif 80 81 /** 82 * These may be expensive, but good for debugging... 83 */ 84 #define ALLOW_EXTRA_CHECKS GNUNET_YES 85 86 /** 87 * For strptime (glibc2 needs this). 88 */ 89 #ifndef _XOPEN_SOURCE 90 #define _XOPEN_SOURCE 499 91 #endif 92 93 #ifndef _REENTRANT 94 #define _REENTRANT 95 #endif 96 97 /* configuration options */ 98 99 #define VERBOSE_STATS 0 100 101 #include <netdb.h> 102 #include <sys/socket.h> 103 #include <sys/un.h> 104 #if HAVE_NETINET_IN_H 105 #include <netinet/in.h> 106 #endif 107 #if HAVE_NETINET_IN_SYSTM_H 108 #include <netinet/in_systm.h> 109 #endif 110 #if HAVE_NETINET_IP_H 111 #include <netinet/ip.h> /* superset of previous */ 112 #endif 113 #include <arpa/inet.h> 114 #include <netinet/tcp.h> 115 #include <pwd.h> 116 #include <sys/ioctl.h> 117 #include <sys/wait.h> 118 #include <grp.h> 119 120 #include <string.h> 121 #include <stdio.h> 122 #include <stdlib.h> 123 #include <stdint.h> 124 #include <stdarg.h> 125 #include <stdbool.h> 126 #include <errno.h> 127 #include <signal.h> 128 #include <libgen.h> 129 #ifdef HAVE_MALLOC_H 130 #include <malloc.h> /* for mallinfo on GNU */ 131 #endif 132 #include <unistd.h> /* KLB_FIX */ 133 #include <sys/stat.h> 134 #include <sys/types.h> 135 #include <dirent.h> /* KLB_FIX */ 136 #include <fcntl.h> 137 #include <math.h> 138 #if HAVE_SYS_PARAM_H 139 #include <sys/param.h> 140 #endif 141 #if HAVE_SYS_TIME_H 142 #include <sys/time.h> 143 #endif 144 #include <time.h> 145 #ifdef BSD 146 #include <net/if.h> 147 #endif 148 #if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__) 149 #include <semaphore.h> 150 #endif 151 #ifdef DARWIN 152 #include <dlfcn.h> 153 #include <semaphore.h> 154 #include <net/if.h> 155 #endif 156 #if defined(__linux__) || defined(GNU) 157 #include <net/if.h> 158 #endif 159 #ifdef SOLARIS 160 #include <sys/sockio.h> 161 #include <sys/filio.h> 162 #include <sys/loadavg.h> 163 #include <semaphore.h> 164 #endif 165 #if HAVE_UCRED_H 166 #include <ucred.h> 167 #endif 168 #if HAVE_SYS_UCRED_H 169 #include <sys/ucred.h> 170 #endif 171 #if HAVE_IFADDRS_H 172 #include <ifaddrs.h> 173 #endif 174 #include <errno.h> 175 #include <limits.h> 176 177 #if HAVE_VFORK_H 178 #include <vfork.h> 179 #endif 180 181 #include <ctype.h> 182 #if HAVE_SYS_RESOURCE_H 183 #include <sys/resource.h> 184 #endif 185 186 #if HAVE_ENDIAN_H 187 #include <endian.h> 188 #endif 189 #if HAVE_SYS_ENDIAN_H 190 #include <sys/endian.h> 191 #endif 192 193 #define DIR_SEPARATOR '/' 194 #define DIR_SEPARATOR_STR "/" 195 #define PATH_SEPARATOR ':' 196 #define PATH_SEPARATOR_STR ":" 197 #define NEWLINE "\n" 198 199 #include <locale.h> 200 #include "gettext.h" 201 /** 202 * GNU gettext support macro. 203 */ 204 #define _(String) dgettext (PACKAGE, String) 205 #define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor" 206 207 #include <sys/mman.h> 208 209 /* FreeBSD_kernel is not defined on the now discontinued kFreeBSD */ 210 #if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__) 211 #define __BYTE_ORDER BYTE_ORDER 212 #define __BIG_ENDIAN BIG_ENDIAN 213 #endif 214 215 #ifdef DARWIN 216 #define __BYTE_ORDER BYTE_ORDER 217 #define __BIG_ENDIAN BIG_ENDIAN 218 /* not available on darwin, override configure */ 219 #undef HAVE_STAT64 220 #undef HAVE_MREMAP 221 #endif 222 223 #if ! HAVE_ATOLL 224 long long 225 atoll (const char *nptr); 226 227 #endif 228 229 #if ENABLE_NLS 230 #include "langinfo.h" 231 #endif 232 233 #ifndef SIZE_MAX 234 #define SIZE_MAX ((size_t) (-1)) 235 #endif 236 237 #ifndef O_LARGEFILE 238 #define O_LARGEFILE 0 239 #endif 240 241 /** 242 * AI_NUMERICSERV not defined in windows. Then we just do without. 243 */ 244 #ifndef AI_NUMERICSERV 245 #define AI_NUMERICSERV 0 246 #endif 247 248 249 #if defined(__sparc__) 250 #define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove (&__tmp, &(val), \ 251 sizeof((val))); \ 252 __tmp; }) 253 #else 254 #define MAKE_UNALIGNED(val) val 255 #endif 256 257 /** 258 * The termination signal 259 */ 260 #define GNUNET_TERM_SIG SIGTERM 261 262 263 #ifndef PATH_MAX 264 /** 265 * Assumed maximum path length. 266 */ 267 #define PATH_MAX 4096 268 #endif 269 270 #if HAVE_THREAD_LOCAL_GCC 271 #define ANASTASIS_THREAD_LOCAL __thread 272 #else 273 #define ANASTASIS_THREAD_LOCAL 274 #endif 275 276 277 /* Do not use shortcuts for gcrypt mpi */ 278 #define GCRYPT_NO_MPI_MACROS 1 279 280 /* Do not use deprecated functions from gcrypt */ 281 #define GCRYPT_NO_DEPRECATED 1 282 283 /* Ignore MHD deprecations for now as we want to be compatible 284 to "ancient" MHD releases. */ 285 #define MHD_NO_DEPRECATION 1 286 287 #endif /* PLATFORM_H_ */ 288 289 /* end of platform.h */