Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:13

0001 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
0002 /* dbus-macros.h  generic macros
0003  *
0004  * Copyright (C) 2002  Red Hat Inc.
0005  *
0006  * Licensed under the Academic Free License version 2.1
0007  *
0008  * This program is free software; you can redistribute it and/or modify
0009  * it under the terms of the GNU General Public License as published by
0010  * the Free Software Foundation; either version 2 of the License, or
0011  * (at your option) any later version.
0012  *
0013  * This program is distributed in the hope that it will be useful,
0014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0016  * GNU General Public License for more details.
0017  *
0018  * You should have received a copy of the GNU General Public License
0019  * along with this program; if not, write to the Free Software
0020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0021  *
0022  */
0023 #if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION)
0024 #error "Only <dbus/dbus.h> can be included directly, this file may disappear or change contents."
0025 #endif
0026 
0027 #ifndef DBUS_MACROS_H
0028 #define DBUS_MACROS_H
0029 
0030 #ifdef  __cplusplus
0031 #  define DBUS_BEGIN_DECLS  extern "C" {
0032 #  define DBUS_END_DECLS    }
0033 #else
0034 #  define DBUS_BEGIN_DECLS
0035 #  define DBUS_END_DECLS
0036 #endif
0037 
0038 #ifndef TRUE
0039 #  define TRUE 1
0040 #endif
0041 #ifndef FALSE
0042 #  define FALSE 0
0043 #endif
0044 
0045 #ifndef NULL
0046 #  ifdef __cplusplus
0047 #    define NULL        (0L)
0048 #  else /* !__cplusplus */
0049 #    define NULL        ((void*) 0)
0050 #  endif /* !__cplusplus */
0051 #endif
0052 
0053 #if  __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
0054 #  define DBUS_DEPRECATED __attribute__ ((__deprecated__))
0055 #elif defined(_MSC_VER) && (_MSC_VER >= 1300)
0056 #  define DBUS_DEPRECATED __declspec(deprecated)
0057 #else
0058 #  define DBUS_DEPRECATED
0059 #endif
0060 
0061 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
0062 #  define _DBUS_GNUC_EXTENSION __extension__
0063 #else
0064 #  define _DBUS_GNUC_EXTENSION
0065 #endif
0066 
0067 #if     (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)) || \
0068          defined(__clang__)
0069 #define _DBUS_GNUC_PRINTF( format_idx, arg_idx )    \
0070   __attribute__((__format__ (__printf__, format_idx, arg_idx)))
0071 #define _DBUS_GNUC_NORETURN                         \
0072   __attribute__((__noreturn__))
0073 #define _DBUS_GNUC_UNUSED                           \
0074   __attribute__((__unused__))
0075 #else   /* !__GNUC__ */
0076 #define _DBUS_GNUC_PRINTF( format_idx, arg_idx )
0077 #define _DBUS_GNUC_NORETURN
0078 #define _DBUS_GNUC_UNUSED
0079 #endif  /* !__GNUC__ */
0080 
0081 #if    __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
0082 #define DBUS_MALLOC     __attribute__((__malloc__))
0083 #else
0084 #define DBUS_MALLOC
0085 #endif
0086 
0087 #if     (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
0088 #define DBUS_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
0089 #define DBUS_ALLOC_SIZE2(x,y) __attribute__((__alloc_size__(x,y)))
0090 #else
0091 #define DBUS_ALLOC_SIZE(x)
0092 #define DBUS_ALLOC_SIZE2(x,y)
0093 #endif
0094 
0095 /** @def _DBUS_WARN_UNUSED_RESULT
0096  *
0097  * An attribute for functions whose result must be checked by the caller.
0098  *
0099  * This macro is used in function declarations. Unlike gcc-specific
0100  * attributes, to avoid compilation failure with MSVC it must appear
0101  * somewhere before the function name in the declaration. Our preferred
0102  * coding style is to place it before the return type, for example:
0103  *
0104  * DBUS_PRIVATE_EXPORT _DBUS_WARN_UNUSED_RESULT
0105  * dbus_bool_t _dbus_user_database_lock_system (void);
0106  */
0107 #if     defined(_MSC_VER) && (_MSC_VER >= 1700)
0108 #define _DBUS_WARN_UNUSED_RESULT _Must_inspect_result_
0109 #elif    (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
0110 #define _DBUS_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
0111 #else
0112 #define _DBUS_WARN_UNUSED_RESULT
0113 #endif
0114 
0115 /** @def _DBUS_GNUC_PRINTF
0116  * used to tell gcc about printf format strings
0117  */
0118 /** @def _DBUS_GNUC_NORETURN
0119  * used to tell gcc about functions that never return, such as _dbus_abort()
0120  */
0121 
0122 /* Normally docs are in .c files, but there isn't a .c file for this. */
0123 /**
0124  * @defgroup DBusMacros Utility macros
0125  * @ingroup  DBus
0126  * @brief #TRUE, #FALSE, #NULL, and so on
0127  *
0128  * Utility macros.
0129  *
0130  * @{
0131  */
0132 
0133 /**
0134  * @def DBUS_BEGIN_DECLS
0135  *
0136  * Macro used prior to declaring functions in the D-Bus header
0137  * files. Expands to "extern "C"" when using a C++ compiler,
0138  * and expands to nothing when using a C compiler.
0139  *
0140  * Please don't use this in your own code, consider it
0141  * D-Bus internal.
0142  */
0143 /**
0144  * @def DBUS_END_DECLS
0145  *
0146  * Macro used after declaring functions in the D-Bus header
0147  * files. Expands to "}" when using a C++ compiler,
0148  * and expands to nothing when using a C compiler.
0149  *
0150  * Please don't use this in your own code, consider it
0151  * D-Bus internal.
0152  */
0153 /**
0154  * @def TRUE
0155  *
0156  * Expands to "1"
0157  */
0158 /**
0159  * @def FALSE
0160  *
0161  * Expands to "0"
0162  */
0163 /**
0164  * @def NULL
0165  *
0166  * A null pointer, defined appropriately for C or C++.
0167  */
0168 /**
0169  * @def DBUS_DEPRECATED
0170  *
0171  * Tells the compiler to warn about a function or type if it's used.
0172  * Code marked in this way should also be enclosed in
0173  * @code
0174  * #ifndef DBUS_DISABLE_DEPRECATED
0175  *  deprecated stuff here
0176  * #endif
0177  * @endcode
0178  *
0179  * Please don't use this in your own code, consider it
0180  * D-Bus internal.
0181  */
0182 /**
0183  * @def _DBUS_GNUC_EXTENSION
0184  *
0185  * Tells gcc not to warn about extensions to the C standard in the
0186  * following expression, even if compiling with -pedantic. Do not use
0187  * this macro in your own code; please consider it to be internal to libdbus.
0188  */
0189 
0190 /*
0191  * @def DBUS_EXPORT
0192  *
0193  * Declare the following symbol as public.  This is currently a noop on
0194  * platforms other than Windows.
0195  */
0196 
0197 #if defined(DBUS_EXPORT)
0198   /* value forced by compiler command line, don't redefine */
0199 #elif defined(_WIN32)
0200 #  if defined(DBUS_STATIC_BUILD)
0201 #  define DBUS_EXPORT
0202 #  elif defined(dbus_1_EXPORTS)
0203 #  define DBUS_EXPORT __declspec(dllexport)
0204 #  else
0205 #  define DBUS_EXPORT __declspec(dllimport)
0206 #  endif
0207 #elif defined(__GNUC__) && __GNUC__ >= 4
0208 #  define DBUS_EXPORT __attribute__ ((__visibility__ ("default")))
0209 #else
0210 #define DBUS_EXPORT
0211 #endif
0212 
0213 #if defined(DBUS_PRIVATE_EXPORT)
0214   /* value forced by compiler command line, don't redefine */
0215 #elif defined(_WIN32)
0216 #  if defined(DBUS_STATIC_BUILD)
0217 #    define DBUS_PRIVATE_EXPORT /* no decoration */
0218 #  elif defined(dbus_1_EXPORTS)
0219 #    define DBUS_PRIVATE_EXPORT __declspec(dllexport)
0220 #  else
0221 #    define DBUS_PRIVATE_EXPORT __declspec(dllimport)
0222 #  endif
0223 #elif defined(__GNUC__) && __GNUC__ >= 4
0224 #  define DBUS_PRIVATE_EXPORT __attribute__ ((__visibility__ ("default")))
0225 #else
0226 #  define DBUS_PRIVATE_EXPORT /* no decoration */
0227 #endif
0228 
0229 /* Implementation for dbus_clear_message() etc. This is not API,
0230  * do not use it directly.
0231  *
0232  * We're using a specific type (T ** and T *) instead of void ** and
0233  * void * partly for type-safety, partly to be strict-aliasing-compliant,
0234  * and partly to keep C++ compilers happy. This code is inlined into
0235  * users of libdbus, so we can't rely on it having dbus' own compiler
0236  * settings. */
0237 #define _dbus_clear_pointer_impl(T, pointer_to_pointer, destroy) \
0238   do { \
0239     T **_pp = (pointer_to_pointer); \
0240     T *_value = *_pp; \
0241     \
0242     *_pp = NULL; \
0243     \
0244     if (_value != NULL) \
0245       destroy (_value); \
0246   } while (0)
0247 /* Not (destroy) (_value) in case destroy() is a function-like macro */
0248 
0249 /** @} */
0250 
0251 #endif /* DBUS_MACROS_H */