Просмотр исходного кода

Use AV_GCC_VERSION_AT_LEAST() to simplify gcc version checks.

Originally committed as revision 16246 to svn://svn.ffmpeg.org/ffmpeg/trunk
Carl Eugen Hoyos 16 лет назад
Родитель
Сommit
52476c1bee
3 измененных файлов с 15 добавлено и 10 удалено
  1. 8 6
      libavutil/common.h
  2. 3 2
      libavutil/internal.h
  3. 4 2
      libavutil/mem.h

+ 8 - 6
libavutil/common.h

@@ -41,8 +41,10 @@
 #    include <math.h>
 #    include <math.h>
 #endif /* HAVE_AV_CONFIG_H */
 #endif /* HAVE_AV_CONFIG_H */
 
 
+#define AV_GCC_VERSION_AT_LEAST(x,y) (defined(__GNUC__) && (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y))
+
 #ifndef av_always_inline
 #ifndef av_always_inline
-#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
+#if AV_GCC_VERSION_AT_LEAST(3,1)
 #    define av_always_inline __attribute__((always_inline)) inline
 #    define av_always_inline __attribute__((always_inline)) inline
 #else
 #else
 #    define av_always_inline inline
 #    define av_always_inline inline
@@ -50,7 +52,7 @@
 #endif
 #endif
 
 
 #ifndef av_noinline
 #ifndef av_noinline
-#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
+#if AV_GCC_VERSION_AT_LEAST(3,1)
 #    define av_noinline __attribute__((noinline))
 #    define av_noinline __attribute__((noinline))
 #else
 #else
 #    define av_noinline
 #    define av_noinline
@@ -58,7 +60,7 @@
 #endif
 #endif
 
 
 #ifndef av_pure
 #ifndef av_pure
-#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
+#if AV_GCC_VERSION_AT_LEAST(3,1)
 #    define av_pure __attribute__((pure))
 #    define av_pure __attribute__((pure))
 #else
 #else
 #    define av_pure
 #    define av_pure
@@ -66,7 +68,7 @@
 #endif
 #endif
 
 
 #ifndef av_const
 #ifndef av_const
-#if defined(__GNUC__) && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ > 5)
+#if AV_GCC_VERSION_AT_LEAST(2,6)
 #    define av_const __attribute__((const))
 #    define av_const __attribute__((const))
 #else
 #else
 #    define av_const
 #    define av_const
@@ -74,7 +76,7 @@
 #endif
 #endif
 
 
 #ifndef av_cold
 #ifndef av_cold
-#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ > 2)
+#if AV_GCC_VERSION_AT_LEAST(4,3)
 #    define av_cold __attribute__((cold))
 #    define av_cold __attribute__((cold))
 #else
 #else
 #    define av_cold
 #    define av_cold
@@ -86,7 +88,7 @@
 #endif /* HAVE_AV_CONFIG_H */
 #endif /* HAVE_AV_CONFIG_H */
 
 
 #ifndef attribute_deprecated
 #ifndef attribute_deprecated
-#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
+#if AV_GCC_VERSION_AT_LEAST(3,1)
 #    define attribute_deprecated __attribute__((deprecated))
 #    define attribute_deprecated __attribute__((deprecated))
 #else
 #else
 #    define attribute_deprecated
 #    define attribute_deprecated

+ 3 - 2
libavutil/internal.h

@@ -33,9 +33,10 @@
 #include <stdint.h>
 #include <stdint.h>
 #include <stddef.h>
 #include <stddef.h>
 #include <assert.h>
 #include <assert.h>
+#include "common.h"
 
 
 #ifndef attribute_align_arg
 #ifndef attribute_align_arg
-#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__>1)
+#if AV_GCC_VERSION_AT_LEAST(4,2)
 #    define attribute_align_arg __attribute__((force_align_arg_pointer))
 #    define attribute_align_arg __attribute__((force_align_arg_pointer))
 #else
 #else
 #    define attribute_align_arg
 #    define attribute_align_arg
@@ -43,7 +44,7 @@
 #endif
 #endif
 
 
 #ifndef attribute_used
 #ifndef attribute_used
-#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
+#if AV_GCC_VERSION_AT_LEAST(3,1)
 #    define attribute_used __attribute__((used))
 #    define attribute_used __attribute__((used))
 #else
 #else
 #    define attribute_used
 #    define attribute_used

+ 4 - 2
libavutil/mem.h

@@ -26,6 +26,8 @@
 #ifndef AVUTIL_MEM_H
 #ifndef AVUTIL_MEM_H
 #define AVUTIL_MEM_H
 #define AVUTIL_MEM_H
 
 
+#include "common.h"
+
 #if defined(__ICC) || defined(__SUNPRO_C)
 #if defined(__ICC) || defined(__SUNPRO_C)
     #define DECLARE_ALIGNED(n,t,v)      t v __attribute__ ((aligned (n)))
     #define DECLARE_ALIGNED(n,t,v)      t v __attribute__ ((aligned (n)))
     #define DECLARE_ASM_CONST(n,t,v)    const t __attribute__ ((aligned (n))) v
     #define DECLARE_ASM_CONST(n,t,v)    const t __attribute__ ((aligned (n))) v
@@ -42,13 +44,13 @@
     #define DECLARE_ASM_CONST(n,t,v)    static const t v
     #define DECLARE_ASM_CONST(n,t,v)    static const t v
 #endif
 #endif
 
 
-#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
+#if AV_GCC_VERSION_AT_LEAST(3,1)
     #define av_malloc_attrib __attribute__((__malloc__))
     #define av_malloc_attrib __attribute__((__malloc__))
 #else
 #else
     #define av_malloc_attrib
     #define av_malloc_attrib
 #endif
 #endif
 
 
-#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ > 2)
+#if AV_GCC_VERSION_AT_LEAST(4,3)
     #define av_alloc_size(n) __attribute__((alloc_size(n)))
     #define av_alloc_size(n) __attribute__((alloc_size(n)))
 #else
 #else
     #define av_alloc_size(n)
     #define av_alloc_size(n)