github.com/kaydxh/golang@v0.0.131/pkg/gocv/cgo/third_path/graphics-magick/include/GraphicsMagick/magick/common.h (about) 1 /* 2 Copyright (C) 2009-2016 GraphicsMagick Group 3 4 This program is covered by multiple licenses, which are described in 5 Copyright.txt. You should have received a copy of Copyright.txt with this 6 package; otherwise see http://www.graphicsmagick.org/www/Copyright.html. 7 8 Magick API common definitions support. 9 */ 10 #ifndef _MAGICK_COMMON_H 11 #define _MAGICK_COMMON_H 12 13 #if defined(__cplusplus) || defined(c_plusplus) 14 extern "C" { 15 #endif 16 17 /* 18 * Borland C++ Builder DLL compilation defines 19 */ 20 #if defined(__BORLANDC__) && defined(_DLL) 21 # pragma message("BCBMagick lib DLL export interface") 22 # define _MAGICKDLL_ 23 # define _MAGICKLIB_ 24 # undef BuildMagickModules 25 # define SupportMagickModules 26 #endif 27 28 #if defined(MSWINDOWS) && !defined(__CYGWIN__) 29 # if defined(_MT) && defined(_DLL) && !defined(_MAGICKDLL_) && !defined(_LIB) 30 # define _MAGICKDLL_ 31 # endif 32 # if defined(_MAGICKDLL_) 33 # if defined(_VISUALC_) 34 # pragma warning( disable: 4273 ) /* Disable the dll linkage warnings */ 35 # endif 36 # if !defined(_MAGICKLIB_) 37 # define MagickExport __declspec(dllimport) 38 # if defined(_VISUALC_) 39 # pragma message( "Magick lib DLL import interface" ) 40 # endif 41 # else 42 # define MagickExport __declspec(dllexport) 43 # if defined(_VISUALC_) 44 # pragma message( "Magick lib DLL export interface" ) 45 # endif 46 # endif 47 # else 48 # define MagickExport 49 # if defined(_VISUALC_) 50 # pragma message( "Magick lib static interface" ) 51 # endif 52 # endif 53 # if defined(_DLL) && !defined(_LIB) 54 # define ModuleExport __declspec(dllexport) 55 # if defined(_VISUALC_) 56 # pragma message( "Magick module DLL export interface" ) 57 # endif 58 # else 59 # define ModuleExport 60 # if defined(_VISUALC_) 61 # pragma message( "Magick module static interface" ) 62 # endif 63 # endif 64 # define MagickGlobal __declspec(thread) 65 # if defined(_VISUALC_) 66 # pragma warning(disable : 4018) 67 # pragma warning(disable : 4244) 68 # pragma warning(disable : 4244) 69 # pragma warning(disable : 4275) /* non dll-interface class 'foo' used as base for dll-interface class 'bar' */ 70 # pragma warning(disable : 4800) 71 # pragma warning(disable : 4786) 72 # pragma warning(disable : 4996) /* function deprecation warnings */ 73 # endif 74 #else 75 # define MagickExport 76 # define ModuleExport 77 # define MagickGlobal 78 #endif 79 80 /* 81 This size is the default minimum string allocation size (heap or 82 stack) for a C string in GraphicsMagick. The weird size is claimed 83 to be based on 2*FILENAME_MAX (not including terminating NULL) on 84 some antique system. Linux has a FILENAME_MAX definition, but it is 85 4096 bytes. Many OSs have path limits of 1024 bytes. 86 87 The FormatString() function assumes that the buffer it is writing to 88 has at least this many bytes remaining. 89 */ 90 #if !defined(MaxTextExtent) 91 # define MaxTextExtent 2053 92 #endif 93 94 #define MagickSignature 0xabacadabUL 95 96 #define MagickPassFail unsigned int 97 #define MagickPass 1 98 #define MagickFail 0 99 100 #define MagickBool unsigned int 101 #define MagickTrue 1 102 #define MagickFalse 0 103 104 /* 105 Support for __attribute__ was added in GCC 2.0. It is not supported 106 in strict ANSI mode which is indicated by __STRICT_ANSI__ being 107 defined. 108 109 http://www.ohse.de/uwe/articles/gcc-attributes.html 110 111 Note that GCC 3.2 on MinGW does not define __GNUC__ or __GNUC_MINOR__. 112 113 Clang/llvm and GCC 5.0 support __has_attribute(attribute) to test if an 114 attribute is supported. Clang/llvm supports __has_builtin(builtin) to test 115 if a builtin is supported. Clang/llvm attempts to support most GCC 116 features. 117 118 __SANITIZE_ADDRESS__ is defined by GCC and Clang if -fsanitize=address is 119 supplied. 120 121 After incuding valgrind/memcheck.h or valgrind/valgrind.h, the macro 122 RUNNING_ON_VALGRIND can be used to test if the program is run under valgrind. 123 See http://valgrind.org/docs/manual/manual-core-adv.html. 124 125 */ 126 #if !defined(MAGICK_ATTRIBUTE) 127 # if ((!defined(__clang__)) && (!defined(__GNUC__) || (__GNUC__ < 2 || __STRICT_ANSI__))) 128 # define MAGICK_ATTRIBUTE(x) /*nothing*/ 129 # else 130 # define MAGICK_ATTRIBUTE(x) __attribute__(x) 131 # if ((defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 5)) && !defined(__COVERITY__)) 132 # define MAGICK_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) 133 # else 134 # define MAGICK_HAS_ATTRIBUTE(attribute) (0) 135 # endif 136 # if (defined(__clang__) && !defined(__COVERITY__)) 137 # define MAGICK_CLANG_HAS_BUILTIN(builtin) __has_builtin(builtin) 138 # else 139 # define MAGICK_CLANG_HAS_BUILTIN(builtin) (0) 140 # endif 141 # if ((MAGICK_HAS_ATTRIBUTE(__deprecated__)) || \ 142 (((__GNUC__) > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))) /* 3.1+ */ 143 # define MAGICK_FUNC_DEPRECATED MAGICK_ATTRIBUTE((__deprecated__)) 144 # endif 145 # if ((MAGICK_HAS_ATTRIBUTE(__malloc__)) || \ 146 (__GNUC__ >= 3)) /* 3.0+ */ 147 # define MAGICK_FUNC_MALLOC MAGICK_ATTRIBUTE((__malloc__)) 148 # endif 149 # if ((MAGICK_HAS_ATTRIBUTE(__nonnull__)) || \ 150 (((__GNUC__) > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))) /* 3.3+ */ 151 /* Supports argument syntax like MAGICK_ATTRIBUTE((nonnull (1, 2))) but 152 don't know how to support non-GCC fallback. */ 153 # define MAGICK_FUNC_NONNULL MAGICK_ATTRIBUTE((__nonnull__)) 154 # endif 155 # if ((MAGICK_HAS_ATTRIBUTE(__noreturn__)) || \ 156 (((__GNUC__) > 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 5)))) /* 2.5+ */ 157 # define MAGICK_FUNC_NORETURN MAGICK_ATTRIBUTE((__noreturn__)) 158 # endif 159 /* clang 3.0 seems to have difficulties with __has_attribute(__const__) but 160 clang 3.3 does not. Just assume that it is supported for clang since 161 Linux headers are riddled with it. */ 162 # if (defined(__clang__) || \ 163 (((__GNUC__) > 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 5)))) /* 2.5+ */ 164 # define MAGICK_FUNC_CONST MAGICK_ATTRIBUTE((__const__)) 165 # endif 166 # if ((MAGICK_HAS_ATTRIBUTE(__pure__)) || \ 167 ((__GNUC__) >= 3)) /* 2.96+ */ 168 # define MAGICK_FUNC_PURE MAGICK_ATTRIBUTE((__pure__)) 169 # endif 170 # if ((MAGICK_HAS_ATTRIBUTE(__unused__)) || \ 171 (((__GNUC__) > 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))) /* 2.7+ */ 172 # define MAGICK_FUNC_UNUSED MAGICK_ATTRIBUTE((__unused__)) 173 # endif 174 # if ((MAGICK_HAS_ATTRIBUTE(__warn_unused_result__)) || \ 175 (((__GNUC__) > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))) /* 3.3+ */ 176 # define MAGICK_FUNC_WARN_UNUSED_RESULT MAGICK_ATTRIBUTE((__warn_unused_result__)) 177 # endif 178 # if ((MAGICK_HAS_ATTRIBUTE(__noinline__)) || \ 179 (((__GNUC__) > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4)))) /* 3.4+ */ 180 # define MAGICK_FUNC_NOINLINE MAGICK_ATTRIBUTE((__noinline__)) 181 # endif 182 # if ((MAGICK_HAS_ATTRIBUTE(__always_inline__)) || \ 183 (((__GNUC__) > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4)))) /* 3.4+ */ 184 # define MAGICK_FUNC_ALWAYSINLINE MAGICK_ATTRIBUTE((__always_inline__)) 185 # endif 186 # if ((MAGICK_HAS_ATTRIBUTE(__alloc_size__)) || \ 187 (((__GNUC__) > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))) /* 4.3+ */ 188 # define MAGICK_FUNC_ALLOC_SIZE_1ARG(arg_num) MAGICK_ATTRIBUTE((__alloc_size__(arg_num))) 189 # define MAGICK_FUNC_ALLOC_SIZE_2ARG(arg_num1,arg_num2) MAGICK_ATTRIBUTE((__alloc_size__(arg_num1,arg_num2))) 190 # endif 191 # if ((MAGICK_HAS_ATTRIBUTE(__hot__)) || \ 192 (((__GNUC__) > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))) /* 4.3+ */ 193 # define MAGICK_FUNC_HOT MAGICK_ATTRIBUTE((__hot__)) 194 # endif 195 # if ((MAGICK_HAS_ATTRIBUTE(__cold__)) || \ 196 (((__GNUC__) > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))) /* 4.3+ */ 197 # define MAGICK_FUNC_COLD MAGICK_ATTRIBUTE((__cold__)) 198 # endif 199 # if ((MAGICK_HAS_ATTRIBUTE(__optimize__)) || \ 200 (((__GNUC__) > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))) /* 4.3+ */ 201 # define MAGICK_OPTIMIZE_FUNC(opt) MAGICK_ATTRIBUTE((__optimize__ (opt))) 202 # endif 203 /* 204 GCC 7 and later support a fallthrough attribute to mark switch statement 205 cases which are intended to fall through. Clang 3.5.0 supports a 206 clang::fallthrough statement attribute while Clang 10 supports the same 207 attribute as GCC 7. Some compilers support a FALLTHROUGH (or FALLTHRU) 208 pre-processor comment. C++ 17 supports a standard fallthrough attribute 209 of the form "[[fallthrough]]". See 210 https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/, 211 https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html, 212 https://clang.llvm.org/docs/AttributeReference.html#fallthrough, and 213 https://releases.llvm.org/3.7.0/tools/clang/docs/AttributeReference.html#fallthrough-clang-fallthrough 214 215 Usage is to put "MAGICK_FALLTHROUGH;" where a "break;" would go. 216 */ 217 # if ((MAGICK_HAS_ATTRIBUTE(__fallthrough__)) || \ 218 ((__GNUC__) >= 7)) /* 7+ */ 219 # define MAGICK_FALLTHROUGH MAGICK_ATTRIBUTE((__fallthrough__)) 220 # endif 221 /* 222 https://code.google.com/p/address-sanitizer/wiki/AddressSanitizer#Introduction 223 224 To ignore certain functions, one can use the no_sanitize_address attribute 225 supported by Clang (3.3+) and GCC (4.8+). 226 */ 227 # if ((MAGICK_HAS_ATTRIBUTE(__no_sanitize_address__)) || \ 228 (((__GNUC__) > 4) || ((__GNUC__ == 8) && (__GNUC_MINOR__ >= 0)))) /* 4.8+ */ 229 # define MAGICK_NO_SANITIZE_ADDRESS MAGICK_ATTRIBUTE((__no_sanitize_address__)) 230 # endif 231 # if ((MAGICK_CLANG_HAS_BUILTIN(__builtin_assume_aligned)) || \ 232 (((__GNUC__) > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)))) /* 4.7+ */ 233 # define MAGICK_ASSUME_ALIGNED(exp,align) __builtin_assume_aligned(exp,align) 234 # endif 235 # if ((MAGICK_CLANG_HAS_BUILTIN(__builtin_assume_aligned)) || \ 236 (((__GNUC__) > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)))) /* 4.7+ */ 237 # define MAGICK_ASSUME_ALIGNED_OFFSET(exp,align,offset) __builtin_assume_aligned(exp,align,offset) 238 # endif 239 # endif 240 #endif 241 #if !defined(MAGICK_FUNC_DEPRECATED) 242 # define MAGICK_FUNC_DEPRECATED /*nothing*/ 243 #endif 244 #if !defined(MAGICK_FUNC_MALLOC) 245 # define MAGICK_FUNC_MALLOC /*nothing*/ 246 #endif 247 #if !defined (MAGICK_FUNC_NONNULL) 248 # define MAGICK_FUNC_NONNULL /*nothing*/ 249 #endif 250 #if !defined (MAGICK_FUNC_NORETURN) 251 # define MAGICK_FUNC_NORETURN /*nothing*/ 252 #endif 253 #if !defined (MAGICK_FUNC_CONST) 254 # define MAGICK_FUNC_CONST /*nothing*/ 255 #endif 256 #if !defined (MAGICK_FUNC_PURE) 257 # define MAGICK_FUNC_PURE /*nothing*/ 258 #endif 259 #if !defined (MAGICK_FUNC_UNUSED) 260 # define MAGICK_FUNC_UNUSED /*nothing*/ 261 #endif 262 #if !defined(MAGICK_FUNC_WARN_UNUSED_RESULT) 263 # define MAGICK_FUNC_WARN_UNUSED_RESULT /*nothing*/ 264 #endif 265 #if !defined(MAGICK_FUNC_NOINLINE) 266 # define MAGICK_FUNC_NOINLINE /*nothing*/ 267 #endif 268 #if !defined(MAGICK_FUNC_ALWAYSINLINE) 269 # define MAGICK_FUNC_ALWAYSINLINE /*nothing*/ 270 #endif 271 #if !defined(MAGICK_FUNC_ALLOC_SIZE_1ARG) 272 # define MAGICK_FUNC_ALLOC_SIZE_1ARG(arg_num) /*nothing*/ 273 #endif 274 #if !defined(MAGICK_FUNC_ALLOC_SIZE_2ARG) 275 # define MAGICK_FUNC_ALLOC_SIZE_2ARG(arg_num1,arg_num2) /*nothing*/ 276 #endif 277 #if !defined(MAGICK_FUNC_HOT) 278 # define MAGICK_FUNC_HOT /*nothing*/ 279 #endif 280 #if !defined(MAGICK_FUNC_COLD) 281 # define MAGICK_FUNC_COLD /*nothing*/ 282 #endif 283 #if !defined(MAGICK_OPTIMIZE_FUNC) 284 # define MAGICK_OPTIMIZE_FUNC(opt) /*nothing*/ 285 #endif 286 #if !defined(MAGICK_FALLTHROUGH) 287 # define MAGICK_FALLTHROUGH /*nothing*/ 288 #endif 289 #if !defined(MAGICK_ASSUME_ALIGNED) 290 # define MAGICK_ASSUME_ALIGNED(exp,align) (exp) 291 #endif 292 #if !defined(MAGICK_ASSUME_ALIGNED_OFFSET) 293 # define MAGICK_ASSUME_ALIGNED_OFFSET(exp,align,offset) (exp) 294 #endif 295 296 /* 297 The isnan and isinf macros are defined by c99 but might not always be 298 available. If they (or a substitute) are not available, then define them 299 to a false value. 300 */ 301 #if defined(isnan) 302 #define MAGICK_ISNAN(d) isnan(d) 303 #else 304 #define MAGICK_ISNAN(d) (0) 305 #endif 306 #if defined(isinf) 307 #define MAGICK_ISINF(d) isinf(d) 308 #else 309 #define MAGICK_ISINF(d) (0) 310 #endif 311 #if defined(isnormal) 312 #define MAGICK_ISNORMAL(d) isnormal(d) 313 #else 314 #define MAGICK_ISNORMAL(d) (1) 315 #endif 316 317 #if defined(__cplusplus) || defined(c_plusplus) 318 } 319 #endif 320 321 #endif /* _MAGICK_COMMON_H */ 322 323 /* 324 * Local Variables: 325 * mode: c 326 * c-basic-offset: 2 327 * fill-column: 78 328 * End: 329 */