]> git.sesse.net Git - ffmpeg/commitdiff
libavutil: Always use some GCC style attributes on clang
authorMartin Storsjö <martin@martin.st>
Mon, 18 Jul 2016 20:25:11 +0000 (23:25 +0300)
committerMartin Storsjö <martin@martin.st>
Thu, 21 Jul 2016 09:52:19 +0000 (12:52 +0300)
Clang normally disguises as GCC (defining __GNUC__), and thus get
all the normal GCC specific attributes.

Clang can also work as a drop-in replacement for MSVC, and in these
cases, it doesn't define __GNUC__, but defines _MSC_VER instead.

Even in these setups, it still supports the GCC style attributes,
thus use them, especially where there isn't any MSVC specific
version, or where the MSVC specific version doesn't work on clang
(for DECLARE_ASM_CONST).

Signed-off-by: Martin Storsjö <martin@martin.st>
libavutil/attributes.h
libavutil/mem.h

index d7f2bb5c6fc898956d60ff4b5072a87bbabf3bdb..c770f52a432deec0e40be7d0a058057668cb1563 100644 (file)
@@ -80,7 +80,7 @@
 #    define attribute_deprecated
 #endif
 
-#if defined(__GNUC__)
+#if defined(__GNUC__) || defined(__clang__)
 #    define av_unused __attribute__((unused))
 #else
 #    define av_unused
@@ -91,7 +91,7 @@
  * away.  This is useful for variables accessed only from inline
  * assembler without the compiler being aware.
  */
-#if AV_GCC_VERSION_AT_LEAST(3,1)
+#if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
 #    define av_used __attribute__((used))
 #else
 #    define av_used
index 9f667c270bf314ca2e7b56b1610ab027a82e2c35..f3cf56c498f45f24f334a1ba9d80847fdc0314ea 100644 (file)
@@ -48,7 +48,7 @@
     #define DECLARE_ASM_CONST(n,t,v)                    \
         AV_PRAGMA(DATA_ALIGN(v,n))                      \
         static const t __attribute__((aligned(n))) v
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) || defined(__clang__)
     #define DECLARE_ALIGNED(n,t,v)      t __attribute__ ((aligned (n))) v
     #define DECLARE_ASM_CONST(n,t,v)    static const t av_used __attribute__ ((aligned (n))) v
 #elif defined(_MSC_VER)