root/include/portability.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright 2001-2021 the Pacemaker project contributors
   3  *
   4  * The version control history for this file may have further details.
   5  *
   6  * This source code is licensed under the GNU Lesser General Public License
   7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
   8  */
   9 #ifndef PORTABILITY_H
  10 #  define PORTABILITY_H
  11 
  12 /* Needs to be defined before any other includes, otherwise some system
  13  * headers do not behave as expected! Major black magic... */
  14 #  undef _GNU_SOURCE            /* in case it was defined on the command line */
  15 #  define _GNU_SOURCE
  16 
  17 /* Please leave this as the first #include - Solaris needs it there */
  18 #  ifdef HAVE_CONFIG_H
  19 #    ifndef PCMK__CONFIG_H
  20 #      define PCMK__CONFIG_H
  21 #      include <config.h>
  22 #    endif
  23 #  endif
  24 
  25 /* Prototypes for libreplace functions */
  26 
  27 #  ifndef HAVE_DAEMON
  28   /* We supply a replacement function, but need a prototype */
  29 int daemon(int nochdir, int noclose);
  30 #  endif                        /* HAVE_DAEMON */
  31 
  32 #  ifndef HAVE_SETENV
  33   /* We supply a replacement function, but need a prototype */
  34 int setenv(const char *name, const char *value, int why);
  35 #  endif                        /* HAVE_SETENV */
  36 
  37 #  ifndef HAVE_STRERROR
  38   /* We supply a replacement function, but need a prototype */
  39 char *strerror(int errnum);
  40 #  endif                        /* HAVE_STRERROR */
  41 
  42 #  ifndef HAVE_STRCHRNUL
  43   /* We supply a replacement function, but need a prototype */
  44 char *strchrnul(const char *s, int c_in);
  45 #  endif                        /* HAVE_STRCHRNUL */
  46 
  47 #  ifndef HAVE_ALPHASORT
  48 #    include <dirent.h>
  49 int
  50  alphasort(const void *dirent1, const void *dirent2);
  51 #  endif                        /* HAVE_ALPHASORT */
  52 
  53 #  ifndef HAVE_STRNLEN
  54 size_t strnlen(const char *s, size_t maxlen);
  55 #  else
  56 #       define USE_GNU
  57 #  endif
  58 
  59 #  ifndef HAVE_STRNDUP
  60 char *strndup(const char *str, size_t len);
  61 #  else
  62 #       define USE_GNU
  63 #  endif
  64 
  65 #  if SUPPORT_DBUS
  66 #    ifndef HAVE_DBUSBASICVALUE
  67 #      include <stdint.h>
  68 #      include <dbus/dbus.h>
  69 /**
  70  * An 8-byte struct you could use to access int64 without having
  71  * int64 support
  72  */
  73 typedef struct
  74 {
  75   uint32_t first32;  /**< first 32 bits in the 8 bytes (beware endian issues) */
  76   uint32_t second32; /**< second 32 bits in the 8 bytes (beware endian issues) */
  77 } DBus8ByteStruct;
  78 
  79 /**
  80  * A simple value union that lets you access bytes as if they
  81  * were various types; useful when dealing with basic types via
  82  * void pointers and varargs.
  83  *
  84  * This union also contains a pointer member (which can be used
  85  * to retrieve a string from dbus_message_iter_get_basic(), for
  86  * instance), so on future platforms it could conceivably be larger
  87  * than 8 bytes.
  88  */
  89 typedef union
  90 {
  91   unsigned char bytes[8]; /**< as 8 individual bytes */
  92   int16_t  i16;   /**< as int16 */
  93   uint16_t u16;   /**< as int16 */
  94   int32_t  i32;   /**< as int32 */
  95   uint32_t u32;   /**< as int32 */
  96   uint32_t bool_val; /**< as boolean */
  97 #      ifdef DBUS_HAVE_INT64
  98   int64_t  i64;   /**< as int64 */
  99   uint64_t u64;   /**< as int64 */
 100 #      endif
 101   DBus8ByteStruct eight; /**< as 8-byte struct */
 102   double dbl;          /**< as double */
 103   unsigned char byt;   /**< as byte */
 104   char *str;           /**< as char* (string, object path or signature) */
 105   int fd;              /**< as Unix file descriptor */
 106 } DBusBasicValue;
 107 #    endif
 108 #  endif
 109 
 110 /* Replacement error codes for non-linux */
 111 #  include <errno.h>
 112 
 113 #  ifndef ENOTUNIQ
 114 #    define ENOTUNIQ  190
 115 #  endif
 116 
 117 #  ifndef ECOMM
 118 #    define ECOMM     191
 119 #  endif
 120 
 121 #  ifndef ELIBACC
 122 #    define ELIBACC   192
 123 #  endif
 124 
 125 #  ifndef EREMOTEIO
 126 #    define EREMOTEIO 193
 127 #  endif
 128 
 129 #  ifndef EUNATCH
 130 #    define EUNATCH   194
 131 #  endif
 132 
 133 #  ifndef ENOKEY
 134 #    define ENOKEY    195
 135 #  endif
 136 
 137 #  ifndef ENODATA
 138 #    define ENODATA   196
 139 #  endif
 140 
 141 #  ifndef ETIME
 142 #    define ETIME     197
 143 #  endif
 144 
 145 #  ifndef ENOSR
 146 #    define ENOSR     198
 147 #  endif
 148 
 149 #  ifndef ENOSTR
 150 #    define ENOSTR    199
 151 #  endif
 152 
 153 #  ifndef EKEYREJECTED
 154 #    define EKEYREJECTED 200
 155 #  endif
 156 
 157 #endif                          /* PORTABILITY_H */

/* [previous][next][first][last][top][bottom][index][help] */