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