]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/mem.h
Fixed-point LSP and LPC decoding routines for ACELP-based codecs
[ffmpeg] / libavutil / mem.h
index 09159f7ee8e91101d36d338b347daef4c34fddce..e51976f0f7c3eb1ff91535613d531c4bc7220f67 100644 (file)
 #define FFMPEG_MEM_H
 
 #ifdef __ICC
-  #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_ALIGNED(n,t,v)      t v __attribute__ ((aligned (n)))
+    #define DECLARE_ASM_CONST(n,t,v)    const t __attribute__ ((aligned (n))) v
 #elif defined(__GNUC__)
-  #define DECLARE_ALIGNED(n,t,v)       t v __attribute__ ((aligned (n)))
-  #define DECLARE_ASM_CONST(n,t,v)     static const t v attribute_used __attribute__ ((aligned (n)))
-#elif defined(_MSVC)
-  #define DECLARE_ALIGNED(n,t,v)      __declspec(align(n)) t v
-  #define DECLARE_ASM_CONST(n,t,v)    __declspec(align(n)) static const t v
+    #define DECLARE_ALIGNED(n,t,v)      t v __attribute__ ((aligned (n)))
+    #define DECLARE_ASM_CONST(n,t,v)    static const t v attribute_used __attribute__ ((aligned (n)))
+#elif defined(_MSC_VER)
+    #define DECLARE_ALIGNED(n,t,v)      __declspec(align(n)) t v
+    #define DECLARE_ASM_CONST(n,t,v)    __declspec(align(n)) static const t v
+#elif defined(HAVE_INLINE_ASM)
+    #error The asm code needs alignment, but we do not know how to do it for this compiler.
 #else
-  #warning No align and asm directives, this might fail.
-  #define DECLARE_ALIGNED(n,t,v)      t v
-  #define DECLARE_ASM_CONST(n,t,v)    static const t v
+    #define DECLARE_ALIGNED(n,t,v)      t v
+    #define DECLARE_ASM_CONST(n,t,v)    static const t v
+#endif
+
+#if defined(__GNUC__) && (__GNU__ > 3 || __GNU__ == 3 && __GNU_MINOR__ > 0)
+    #define av_malloc_attrib __attribute__((__malloc__))
+#else
+    #define av_malloc_attrib
+#endif
+
+#if defined(__GNUC__) && (__GNU__ > 4 || __GNU__ == 4 && __GNU_MINOR__ > 1)
+    #define av_alloc_size(n) __attribute__((alloc_size(n)))
+#else
+    #define av_alloc_size(n)
 #endif
 
 /**
@@ -49,7 +62,7 @@
  * it.
  * @see av_mallocz()
  */
-void *av_malloc(unsigned int size);
+void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1);
 
 /**
  * Allocate or reallocate a block of memory.
@@ -63,7 +76,7 @@ void *av_malloc(unsigned int size);
  * reallocate or the function is used to free the memory block.
  * @see av_fast_realloc()
  */
-void *av_realloc(void *ptr, unsigned int size);
+void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2);
 
 /**
  * Free a memory block which has been allocated with av_malloc(z)() or
@@ -84,7 +97,7 @@ void av_free(void *ptr);
  * it.
  * @see av_malloc()
  */
-void *av_mallocz(unsigned int size);
+void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1);
 
 /**
  * Duplicate the string \p s.
@@ -92,7 +105,7 @@ void *av_mallocz(unsigned int size);
  * @return Pointer to a newly allocated string containing a
  * copy of \p s or NULL if it cannot be allocated.
  */
-char *av_strdup(const char *s);
+char *av_strdup(const char *s) av_malloc_attrib;
 
 /**
  * Free a memory block which has been allocated with av_malloc(z)() or