twister

HTTP fault injector for testing
Log | Files | Refs | README | LICENSE

platform.h (5769B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2014 Chrisitan Grothoff (and other contributing authors)
      4 
      5   TALER is free software; you can redistribute it and/or modify it under the
      6   terms of the GNU General Public License as published by the Free Software
      7   Foundation; either version 3, or (at your option) any later version.
      8 
      9   TALER 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 General Public License for more details.
     12 
     13   You should have received a copy of the GNU General Public License along with
     14   TALER; 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 "twister_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 /* Include the features available for GNU source */
     43 #define _GNU_SOURCE
     44 
     45 
     46 #ifdef HAVE_SYS_TYPES_H
     47 #include <sys/types.h>
     48 #endif
     49 
     50 #ifdef __clang__
     51 #undef HAVE_STATIC_ASSERT
     52 #endif
     53 
     54 /**
     55  * These may be expensive, but good for debugging...
     56  */
     57 #define ALLOW_EXTRA_CHECKS GNUNET_YES
     58 
     59 /**
     60  * For strptime (glibc2 needs this).
     61  */
     62 #ifndef _XOPEN_SOURCE
     63 #define _XOPEN_SOURCE 499
     64 #endif
     65 
     66 #ifndef _REENTRANT
     67 #define _REENTRANT
     68 #endif
     69 
     70 /* configuration options */
     71 
     72 #define VERBOSE_STATS 0
     73 
     74 #include <netdb.h>
     75 #include <sys/socket.h>
     76 #include <sys/un.h>
     77 #if HAVE_NETINET_IN_H
     78 #include <netinet/in.h>
     79 #endif
     80 #if HAVE_NETINET_IN_SYSTM_H
     81 #include <netinet/in_systm.h>
     82 #endif
     83 #if HAVE_NETINET_IP_H
     84 #include <netinet/ip.h>         /* superset of previous */
     85 #endif
     86 #include <arpa/inet.h>
     87 #include <netinet/tcp.h>
     88 #include <pwd.h>
     89 #include <sys/ioctl.h>
     90 #include <sys/wait.h>
     91 #include <grp.h>
     92 
     93 #include <string.h>
     94 #include <stdio.h>
     95 #include <stdlib.h>
     96 #include <stdint.h>
     97 #include <stdarg.h>
     98 #include <stdbool.h>
     99 #include <errno.h>
    100 #include <signal.h>
    101 #include <libgen.h>
    102 #ifdef HAVE_MALLOC_H
    103 #include <malloc.h>             /* for mallinfo on GNU */
    104 #endif
    105 #include <unistd.h>             /* KLB_FIX */
    106 #include <sys/stat.h>
    107 #include <sys/types.h>
    108 #include <dirent.h>             /* KLB_FIX */
    109 #include <fcntl.h>
    110 #include <math.h>
    111 #if HAVE_SYS_PARAM_H
    112 #include <sys/param.h>
    113 #endif
    114 #if HAVE_SYS_TIME_H
    115 #include <sys/time.h>
    116 #endif
    117 #include <time.h>
    118 #ifdef BSD
    119 #include <net/if.h>
    120 #endif
    121 #if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__)
    122 #include <semaphore.h>
    123 #endif
    124 #ifdef DARWIN
    125 #include <dlfcn.h>
    126 #include <semaphore.h>
    127 #include <net/if.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 <locale.h>
    173 #include <sys/mman.h>
    174 
    175 /* FreeBSD_kernel is not defined on the now discontinued kFreeBSD  */
    176 #if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__)
    177 #define __BYTE_ORDER BYTE_ORDER
    178 #define __BIG_ENDIAN BIG_ENDIAN
    179 #endif
    180 
    181 #ifdef DARWIN
    182 #define __BYTE_ORDER BYTE_ORDER
    183 #define __BIG_ENDIAN BIG_ENDIAN
    184 /* not available on darwin, override configure */
    185 #undef HAVE_STAT64
    186 #undef HAVE_MREMAP
    187 #endif
    188 
    189 #if ! HAVE_ATOLL
    190 long long
    191 atoll (const char *nptr);
    192 
    193 #endif
    194 
    195 
    196 #ifndef SIZE_MAX
    197 #define SIZE_MAX ((size_t) (-1))
    198 #endif
    199 
    200 #ifndef O_LARGEFILE
    201 #define O_LARGEFILE 0
    202 #endif
    203 
    204 /**
    205  * AI_NUMERICSERV not defined in windows.  Then we just do without.
    206  */
    207 #ifndef AI_NUMERICSERV
    208 #define AI_NUMERICSERV 0
    209 #endif
    210 
    211 
    212 #if defined(__sparc__)
    213 #define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove (&__tmp, &(val), \
    214                                                                  sizeof((val))); \
    215                                __tmp; })
    216 #else
    217 #define MAKE_UNALIGNED(val) val
    218 #endif
    219 
    220 
    221 #ifndef PATH_MAX
    222 /**
    223  * Assumed maximum path length.
    224  */
    225 #define PATH_MAX 4096
    226 #endif
    227 
    228 #if HAVE_THREAD_LOCAL_GCC
    229 #define TWISTER_THREAD_LOCAL __thread
    230 #else
    231 #define TWISTER_THREAD_LOCAL
    232 #endif
    233 
    234 
    235 /* LSB-style exit status codes */
    236 #ifndef EXIT_INVALIDARGUMENT
    237 #define EXIT_INVALIDARGUMENT 2
    238 #endif
    239 
    240 #ifndef EXIT_NOTIMPLEMENTED
    241 #define EXIT_NOTIMPLEMENTED 3
    242 #endif
    243 
    244 #ifndef EXIT_NOPERMISSION
    245 #define EXIT_NOPERMISSION 4
    246 #endif
    247 
    248 #ifndef EXIT_NOTINSTALLED
    249 #define EXIT_NOTINSTALLED 5
    250 #endif
    251 
    252 #ifndef EXIT_NOTCONFIGURED
    253 #define EXIT_NOTCONFIGURED 6
    254 #endif
    255 
    256 #ifndef EXIT_NOTRUNNING
    257 #define EXIT_NOTRUNNING 7
    258 #endif
    259 
    260 /**
    261  * clang et al do not have such an attribute
    262  */
    263 #if __has_attribute (__nonstring__)
    264 # define __nonstring                    __attribute__((__nonstring__))
    265 #else
    266 # define __nonstring
    267 #endif
    268 
    269 
    270 /* Do not use shortcuts for gcrypt mpi */
    271 #define GCRYPT_NO_MPI_MACROS 1
    272 
    273 /* Do not use deprecated functions from gcrypt */
    274 #define GCRYPT_NO_DEPRECATED 1
    275 
    276 /* Ignore MHD deprecations for now as we want to be compatible
    277    to "ancient" MHD releases. */
    278 #define MHD_NO_DEPRECATION 1
    279 
    280 
    281 #endif  /* PLATFORM_H_ */
    282 
    283 /* end of platform.h */