root/include/portability.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. g_list_free_full

   1 /*
   2  * Copyright 2001-2020 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 #  define       EOS                     '\0'
  13 #  define       DIMOF(a)                ((int) (sizeof(a)/sizeof(a[0])) )
  14 
  15 /* Needs to be defined before any other includes, otherwise some system
  16  * headers do not behave as expected! Major black magic... */
  17 #  undef _GNU_SOURCE            /* in case it was defined on the command line */
  18 #  define _GNU_SOURCE
  19 
  20 /* Please leave this as the first #include - Solaris needs it there */
  21 #  ifdef HAVE_CONFIG_H
  22 #    ifndef PCMK__CONFIG_H
  23 #      define PCMK__CONFIG_H
  24 #      include <config.h>
  25 #    endif
  26 #  endif
  27 
  28 /* Prototypes for libreplace functions */
  29 
  30 #  ifndef HAVE_DAEMON
  31   /* We supply a replacement function, but need a prototype */
  32 int daemon(int nochdir, int noclose);
  33 #  endif                        /* HAVE_DAEMON */
  34 
  35 #  ifndef HAVE_SETENV
  36   /* We supply a replacement function, but need a prototype */
  37 int setenv(const char *name, const char *value, int why);
  38 #  endif                        /* HAVE_SETENV */
  39 
  40 #  ifndef HAVE_STRERROR
  41   /* We supply a replacement function, but need a prototype */
  42 char *strerror(int errnum);
  43 #  endif                        /* HAVE_STRERROR */
  44 
  45 #  ifndef HAVE_STRCHRNUL
  46   /* We supply a replacement function, but need a prototype */
  47 char *strchrnul(const char *s, int c_in);
  48 #  endif                        /* HAVE_STRCHRNUL */
  49 
  50 #  ifndef HAVE_ALPHASORT
  51 #    include <dirent.h>
  52 int
  53  alphasort(const void *dirent1, const void *dirent2);
  54 #  endif                        /* HAVE_ALPHASORT */
  55 
  56 #  ifndef HAVE_STRNLEN
  57 size_t strnlen(const char *s, size_t maxlen);
  58 #  else
  59 #       define USE_GNU
  60 #  endif
  61 
  62 #  ifndef HAVE_STRNDUP
  63 char *strndup(const char *str, size_t len);
  64 #  else
  65 #       define USE_GNU
  66 #  endif
  67 
  68 // This test could be better, but it covers platforms of interest
  69 #  if defined(ON_BSD) || defined(ON_SOLARIS)
  70 #    define SUPPORT_PROCFS 0
  71 #  else
  72 #    define SUPPORT_PROCFS 1
  73 #  endif
  74 
  75 #  include <glib.h>
  76 
  77 #  if !GLIB_CHECK_VERSION(2,28,0)
  78 #    include <string.h>
  79 /* Since: 2.28 */
  80 static inline void
  81 g_list_free_full(GList * list, GDestroyNotify free_func)
     /* [previous][next][first][last][top][bottom][index][help] */
  82 {
  83     g_list_foreach(list, (GFunc) free_func, NULL);
  84     g_list_free(list);
  85 }
  86 #  endif
  87 
  88 #  if SUPPORT_DBUS
  89 #    ifndef HAVE_DBUSBASICVALUE
  90 #      include <stdint.h>
  91 #      include <dbus/dbus.h>
  92 /**
  93  * An 8-byte struct you could use to access int64 without having
  94  * int64 support
  95  */
  96 typedef struct
  97 {
  98   uint32_t first32;  /**< first 32 bits in the 8 bytes (beware endian issues) */
  99   uint32_t second32; /**< second 32 bits in the 8 bytes (beware endian issues) */
 100 } DBus8ByteStruct;
 101 
 102 /**
 103  * A simple value union that lets you access bytes as if they
 104  * were various types; useful when dealing with basic types via
 105  * void pointers and varargs.
 106  *
 107  * This union also contains a pointer member (which can be used
 108  * to retrieve a string from dbus_message_iter_get_basic(), for
 109  * instance), so on future platforms it could conceivably be larger
 110  * than 8 bytes.
 111  */
 112 typedef union
 113 {
 114   unsigned char bytes[8]; /**< as 8 individual bytes */
 115   int16_t  i16;   /**< as int16 */
 116   uint16_t u16;   /**< as int16 */
 117   int32_t  i32;   /**< as int32 */
 118   uint32_t u32;   /**< as int32 */
 119   uint32_t bool_val; /**< as boolean */
 120 #      ifdef DBUS_HAVE_INT64
 121   int64_t  i64;   /**< as int64 */
 122   uint64_t u64;   /**< as int64 */
 123 #      endif
 124   DBus8ByteStruct eight; /**< as 8-byte struct */
 125   double dbl;          /**< as double */
 126   unsigned char byt;   /**< as byte */
 127   char *str;           /**< as char* (string, object path or signature) */
 128   int fd;              /**< as Unix file descriptor */
 129 } DBusBasicValue;
 130 #    endif
 131 #  endif
 132 
 133 /* Replacement error codes for non-linux */
 134 #  include <errno.h>
 135 
 136 #  ifndef ENOTUNIQ
 137 #    define ENOTUNIQ  190
 138 #  endif
 139 
 140 #  ifndef ECOMM
 141 #    define ECOMM     191
 142 #  endif
 143 
 144 #  ifndef ELIBACC
 145 #    define ELIBACC   192
 146 #  endif
 147 
 148 #  ifndef EREMOTEIO
 149 #    define EREMOTEIO 193
 150 #  endif
 151 
 152 #  ifndef EUNATCH
 153 #    define EUNATCH   194
 154 #  endif
 155 
 156 #  ifndef ENOKEY
 157 #    define ENOKEY    195
 158 #  endif
 159 
 160 #  ifndef ENODATA
 161 #    define ENODATA   196
 162 #  endif
 163 
 164 #  ifndef ETIME
 165 #    define ETIME     197
 166 #  endif
 167 
 168 #  ifndef ENOSR
 169 #    define ENOSR     198
 170 #  endif
 171 
 172 #  ifndef ENOSTR
 173 #    define ENOSTR    199
 174 #  endif
 175 
 176 #  ifndef EKEYREJECTED
 177 #    define EKEYREJECTED 200
 178 #  endif
 179 
 180 #endif                          /* PORTABILITY_H */

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