Path: blob/master/dep/ffmpeg/include/libavutil/attributes.h
4216 views
/*1* copyright (c) 2006 Michael Niedermayer <[email protected]>2*3* This file is part of FFmpeg.4*5* FFmpeg is free software; you can redistribute it and/or6* modify it under the terms of the GNU Lesser General Public7* License as published by the Free Software Foundation; either8* version 2.1 of the License, or (at your option) any later version.9*10* FFmpeg is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13* Lesser General Public License for more details.14*15* You should have received a copy of the GNU Lesser General Public16* License along with FFmpeg; if not, write to the Free Software17* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18*/1920/**21* @file22* Macro definitions for various function/variable attributes23*/2425#ifndef AVUTIL_ATTRIBUTES_H26#define AVUTIL_ATTRIBUTES_H2728#ifdef __GNUC__29# define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y))30# define AV_GCC_VERSION_AT_MOST(x,y) (__GNUC__ < (x) || __GNUC__ == (x) && __GNUC_MINOR__ <= (y))31#else32# define AV_GCC_VERSION_AT_LEAST(x,y) 033# define AV_GCC_VERSION_AT_MOST(x,y) 034#endif3536#ifdef __has_builtin37# define AV_HAS_BUILTIN(x) __has_builtin(x)38#else39# define AV_HAS_BUILTIN(x) 040#endif4142#ifndef av_always_inline43#if AV_GCC_VERSION_AT_LEAST(3,1)44# define av_always_inline __attribute__((always_inline)) inline45#elif defined(_MSC_VER)46# define av_always_inline __forceinline47#else48# define av_always_inline inline49#endif50#endif5152#ifndef av_extern_inline53#if defined(__ICL) && __ICL >= 1210 || defined(__GNUC_STDC_INLINE__)54# define av_extern_inline extern inline55#else56# define av_extern_inline inline57#endif58#endif5960#if AV_GCC_VERSION_AT_LEAST(3,4)61# define av_warn_unused_result __attribute__((warn_unused_result))62#else63# define av_warn_unused_result64#endif6566#if AV_GCC_VERSION_AT_LEAST(3,1)67# define av_noinline __attribute__((noinline))68#elif defined(_MSC_VER)69# define av_noinline __declspec(noinline)70#else71# define av_noinline72#endif7374#if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)75# define av_pure __attribute__((pure))76#else77# define av_pure78#endif7980#if AV_GCC_VERSION_AT_LEAST(2,6) || defined(__clang__)81# define av_const __attribute__((const))82#else83# define av_const84#endif8586#if AV_GCC_VERSION_AT_LEAST(4,3) || defined(__clang__)87# define av_cold __attribute__((cold))88#else89# define av_cold90#endif9192#if AV_GCC_VERSION_AT_LEAST(4,1) && !defined(__llvm__)93# define av_flatten __attribute__((flatten))94#else95# define av_flatten96#endif9798#if AV_GCC_VERSION_AT_LEAST(3,1)99# define attribute_deprecated __attribute__((deprecated))100#elif defined(_MSC_VER)101# define attribute_deprecated __declspec(deprecated)102#else103# define attribute_deprecated104#endif105106/**107* Disable warnings about deprecated features108* This is useful for sections of code kept for backward compatibility and109* scheduled for removal.110*/111#ifndef AV_NOWARN_DEPRECATED112#if AV_GCC_VERSION_AT_LEAST(4,6) || defined(__clang__)113# define AV_NOWARN_DEPRECATED(code) \114_Pragma("GCC diagnostic push") \115_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \116code \117_Pragma("GCC diagnostic pop")118#elif defined(_MSC_VER)119# define AV_NOWARN_DEPRECATED(code) \120__pragma(warning(push)) \121__pragma(warning(disable : 4996)) \122code; \123__pragma(warning(pop))124#else125# define AV_NOWARN_DEPRECATED(code) code126#endif127#endif128129#if defined(__GNUC__) || defined(__clang__)130# define av_unused __attribute__((unused))131#else132# define av_unused133#endif134135/**136* Mark a variable as used and prevent the compiler from optimizing it137* away. This is useful for variables accessed only from inline138* assembler without the compiler being aware.139*/140#if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)141# define av_used __attribute__((used))142#else143# define av_used144#endif145146#if AV_GCC_VERSION_AT_LEAST(3,3) || defined(__clang__)147# define av_alias __attribute__((may_alias))148#else149# define av_alias150#endif151152#if (defined(__GNUC__) || defined(__clang__)) && !defined(__INTEL_COMPILER)153# define av_uninit(x) x=x154#else155# define av_uninit(x) x156#endif157158#if defined(__GNUC__) || defined(__clang__)159# define av_builtin_constant_p __builtin_constant_p160# define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))161#else162# define av_builtin_constant_p(x) 0163# define av_printf_format(fmtpos, attrpos)164#endif165166#if AV_GCC_VERSION_AT_LEAST(2,5) || defined(__clang__)167# define av_noreturn __attribute__((noreturn))168#else169# define av_noreturn170#endif171172#endif /* AVUTIL_ATTRIBUTES_H */173174175