sync

Backup service to store encrypted wallet databases (experimental)
Log | Files | Refs | Submodules | README | LICENSE

platform.h (6163B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2014, 2015, 2016 GNUnet e.V. and INRIA
      4 
      5   TALER 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   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 "sync_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 #ifdef HAVE_SYS_TYPES_H
     46 #include <sys/types.h>
     47 #endif
     48 
     49 #ifdef __clang__
     50 #undef HAVE_STATIC_ASSERT
     51 #endif
     52 
     53 /**
     54  * These may be expensive, but good for debugging...
     55  */
     56 #define ALLOW_EXTRA_CHECKS GNUNET_YES
     57 
     58 /**
     59  * For strptime (glibc2 needs this).
     60  */
     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 #endif
    128 #if defined(__linux__) || defined(GNU)
    129 #include <net/if.h>
    130 #endif
    131 #ifdef SOLARIS
    132 #include <sys/sockio.h>
    133 #include <sys/filio.h>
    134 #include <sys/loadavg.h>
    135 #include <semaphore.h>
    136 #endif
    137 #if HAVE_UCRED_H
    138 #include <ucred.h>
    139 #endif
    140 #if HAVE_SYS_UCRED_H
    141 #include <sys/ucred.h>
    142 #endif
    143 #if HAVE_IFADDRS_H
    144 #include <ifaddrs.h>
    145 #endif
    146 #include <errno.h>
    147 #include <limits.h>
    148 
    149 #if HAVE_VFORK_H
    150 #include <vfork.h>
    151 #endif
    152 
    153 #include <ctype.h>
    154 #if HAVE_SYS_RESOURCE_H
    155 #include <sys/resource.h>
    156 #endif
    157 
    158 #if HAVE_ENDIAN_H
    159 #include <endian.h>
    160 #endif
    161 #if HAVE_SYS_ENDIAN_H
    162 #include <sys/endian.h>
    163 #endif
    164 
    165 #define DIR_SEPARATOR '/'
    166 #define DIR_SEPARATOR_STR "/"
    167 #define PATH_SEPARATOR ':'
    168 #define PATH_SEPARATOR_STR ":"
    169 #define NEWLINE "\n"
    170 
    171 #include <locale.h>
    172 #include <sys/mman.h>
    173 
    174 /* FreeBSD_kernel is not defined on the now discontinued kFreeBSD  */
    175 #if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__)
    176 #define __BYTE_ORDER BYTE_ORDER
    177 #define __BIG_ENDIAN BIG_ENDIAN
    178 #endif
    179 
    180 #ifdef DARWIN
    181 #define __BYTE_ORDER BYTE_ORDER
    182 #define __BIG_ENDIAN BIG_ENDIAN
    183 /* not available on darwin, override configure */
    184 #undef HAVE_STAT64
    185 #undef HAVE_MREMAP
    186 #endif
    187 
    188 #if ! HAVE_ATOLL
    189 long long
    190 atoll (const char *nptr);
    191 
    192 #endif
    193 
    194 #if ENABLE_NLS
    195 #include "langinfo.h"
    196 #endif
    197 
    198 #ifndef SIZE_MAX
    199 #define SIZE_MAX ((size_t) (-1))
    200 #endif
    201 
    202 #ifndef O_LARGEFILE
    203 #define O_LARGEFILE 0
    204 #endif
    205 
    206 /**
    207  * AI_NUMERICSERV not defined in windows.  Then we just do without.
    208  */
    209 #ifndef AI_NUMERICSERV
    210 #define AI_NUMERICSERV 0
    211 #endif
    212 
    213 
    214 #if defined(__sparc__)
    215 #define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove (&__tmp, &(val), \
    216                                                                  sizeof((val))); \
    217                                __tmp; })
    218 #else
    219 #define MAKE_UNALIGNED(val) val
    220 #endif
    221 
    222 
    223 #ifndef PATH_MAX
    224 /**
    225  * Assumed maximum path length.
    226  */
    227 #define PATH_MAX 4096
    228 #endif
    229 
    230 #if HAVE_THREAD_LOCAL_GCC
    231 #define GNUNET_THREAD_LOCAL __thread
    232 #else
    233 #define GNUNET_THREAD_LOCAL
    234 #endif
    235 
    236 
    237 /* Do not use shortcuts for gcrypt mpi */
    238 #define GCRYPT_NO_MPI_MACROS 1
    239 
    240 /* Do not use deprecated functions from gcrypt */
    241 #define GCRYPT_NO_DEPRECATED 1
    242 
    243 
    244 /* LSB-style exit status codes */
    245 #ifndef EXIT_INVALIDARGUMENT
    246 /**
    247  * Command-line arguments are invalid.
    248  * Restarting useless.
    249  */
    250 #define EXIT_INVALIDARGUMENT 2
    251 #endif
    252 
    253 #ifndef EXIT_NOTIMPLEMENTED
    254 /**
    255  * The requested operation is not implemented.
    256  * Restarting useless.
    257  */
    258 #define EXIT_NOTIMPLEMENTED 3
    259 #endif
    260 
    261 #ifndef EXIT_NOPERMISSION
    262 /**
    263  * Permissions needed to run are not available.
    264  * Restarting useless.
    265  */
    266 #define EXIT_NOPERMISSION 4
    267 #endif
    268 
    269 #ifndef EXIT_NOTINSTALLED
    270 /**
    271  * Key resources are not installed.
    272  * Restarting useless.
    273  */
    274 #define EXIT_NOTINSTALLED 5
    275 #endif
    276 
    277 #ifndef EXIT_NOTCONFIGURED
    278 /**
    279  * Key configuration settings are missing or invalid.
    280  * Restarting useless.
    281  */
    282 #define EXIT_NOTCONFIGURED 6
    283 #endif
    284 
    285 #ifndef EXIT_NOTRUNNING
    286 #define EXIT_NOTRUNNING 7
    287 #endif
    288 
    289 
    290 #ifndef EXIT_NO_RESTART
    291 /**
    292  * Exit code from 'main' if we do not want to be restarted,
    293  * except by manual intervention (hard failure).
    294  */
    295 #define EXIT_NO_RESTART 9
    296 #endif
    297 
    298 
    299 /* Ignore MHD deprecations for now as we want to be compatible
    300    to "ancient" MHD releases. */
    301 #define MHD_NO_DEPRECATION 1
    302 
    303 #endif  /* PLATFORM_H_ */
    304 
    305 /* end of platform.h */