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 PCMK__PORTABILITY__H
  10 #  define PCMK__PORTABILITY__H
  11 
  12 /* This header provides replacements for required definitions and declarations
  13  * that certain supported build environments don't provide
  14  */
  15 
  16 /* This header *MUST* be included before any system headers, because the
  17  * following definition can change the behavior of some of them.
  18  */
  19 #  undef _GNU_SOURCE            /* in case it was defined on the command line */
  20 #  define _GNU_SOURCE
  21 
  22 /* Please leave this as the first #include - Solaris needs it there */
  23 #  ifdef HAVE_CONFIG_H
  24 #    ifndef PCMK__CONFIG_H
  25 #      define PCMK__CONFIG_H
  26 #      include <config.h>
  27 #    endif
  28 #  endif
  29 
  30 /* Prototypes for libreplace functions */
  31 
  32 #  ifndef HAVE_DAEMON
  33   /* We supply a replacement function, but need a prototype */
  34 int daemon(int nochdir, int noclose);
  35 #  endif
  36 
  37 #  ifndef HAVE_SETENV
  38   /* We supply a replacement function, but need a prototype */
  39 int setenv(const char *name, const char *value, int why);
  40 #  endif
  41 
  42 #  ifndef HAVE_STRERROR
  43   /* We supply a replacement function, but need a prototype */
  44 char *strerror(int errnum);
  45 #  endif
  46 
  47 #  ifndef HAVE_STRCHRNUL
  48   /* We supply a replacement function, but need a prototype */
  49 char *strchrnul(const char *s, int c_in);
  50 #  endif
  51 
  52 #  ifndef HAVE_ALPHASORT
  53 #    include <dirent.h>
  54 int alphasort(const void *dirent1, const void *dirent2);
  55 #  endif
  56 
  57 #  ifndef HAVE_STRNLEN
  58 size_t strnlen(const char *s, size_t maxlen);
  59 #  else
  60 #    define USE_GNU
  61 #  endif
  62 
  63 #  ifndef HAVE_STRNDUP
  64 char *strndup(const char *str, size_t len);
  65 #  else
  66 #    define USE_GNU
  67 #  endif
  68 
  69 #  if SUPPORT_DBUS
  70 #    ifndef HAVE_DBUSBASICVALUE
  71 #      include <stdint.h>
  72 #      include <dbus/dbus.h>
  73 /**
  74  * An 8-byte struct you could use to access int64 without having
  75  * int64 support
  76  */
  77 typedef struct
  78 {
  79   uint32_t first32;  /**< first 32 bits in the 8 bytes (beware endian issues) */
  80   uint32_t second32; /**< second 32 bits in the 8 bytes (beware endian issues) */
  81 } DBus8ByteStruct;
  82 
  83 /**
  84  * A simple value union that lets you access bytes as if they
  85  * were various types; useful when dealing with basic types via
  86  * void pointers and varargs.
  87  *
  88  * This union also contains a pointer member (which can be used
  89  * to retrieve a string from dbus_message_iter_get_basic(), for
  90  * instance), so on future platforms it could conceivably be larger
  91  * than 8 bytes.
  92  */
  93 typedef union
  94 {
  95   unsigned char bytes[8]; /**< as 8 individual bytes */
  96   int16_t  i16;   /**< as int16 */
  97   uint16_t u16;   /**< as int16 */
  98   int32_t  i32;   /**< as int32 */
  99   uint32_t u32;   /**< as int32 */
 100   uint32_t bool_val; /**< as boolean */
 101 #      ifdef DBUS_HAVE_INT64
 102   int64_t  i64;   /**< as int64 */
 103   uint64_t u64;   /**< as int64 */
 104 #      endif
 105   DBus8ByteStruct eight; /**< as 8-byte struct */
 106   double dbl;          /**< as double */
 107   unsigned char byt;   /**< as byte */
 108   char *str;           /**< as char* (string, object path or signature) */
 109   int fd;              /**< as Unix file descriptor */
 110 } DBusBasicValue;
 111 #    endif  // !defined(HAVE_DBUSBASICVALUE)
 112 #  endif    // !defined(SUPPORT_DBUS)
 113 
 114 // Replacement constants for Linux-specific errno values
 115 
 116 #  include <errno.h>
 117 
 118 #  ifndef ENOTUNIQ
 119 #    define PCMK__ENOTUNIQ
 120 #    define ENOTUNIQ  190
 121 #  endif
 122 
 123 #  ifndef ECOMM
 124 #    define PCMK__ECOMM
 125 #    define ECOMM     191
 126 #  endif
 127 
 128 #  ifndef ELIBACC
 129 #    define PCMK__ELIBACC
 130 #    define ELIBACC   192
 131 #  endif
 132 
 133 #  ifndef EREMOTEIO
 134 #    define PCMK__EREMOTIO
 135 #    define EREMOTEIO 193
 136 #  endif
 137 
 138 #  ifndef ENOKEY
 139 #    define PCMK__ENOKEY
 140 #    define ENOKEY    195
 141 #  endif
 142 
 143 #  ifndef ENODATA
 144 #    define PCMK__ENODATA
 145 #    define ENODATA   196
 146 #  endif
 147 
 148 #  ifndef ETIME
 149 #    define PCMK__ETIME
 150 #    define ETIME     197
 151 #  endif
 152 
 153 #  ifndef EKEYREJECTED
 154 #    define PCMK__EKEYREJECTED
 155 #    define EKEYREJECTED 200
 156 #  endif
 157 
 158 #endif // PCMK__PORTABILITY__H

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