aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/common.h
diff options
context:
space:
mode:
authorZuxy Meng <zuxy.meng@gmail.com>2008-03-18 15:27:15 +0000
committerBenoit Fouet <benoit.fouet@free.fr>2008-03-18 15:27:15 +0000
commit6544f48f038552973a552401cea5d4e8f1fc9c0a (patch)
treedf001b9633d7c0cd7407cc0566e21917edf73d7b /libavutil/common.h
parent38c669d853dfa60a73bf59695ff03e7104650623 (diff)
downloadffmpeg-6544f48f038552973a552401cea5d4e8f1fc9c0a.tar.gz
Pure, const and malloc attributes to libavutil.
Patch by Zuxy Meng: zuxy meng gmail com Original thread: [FFmpeg-devel] [PATCH] Pure, const and malloc attributes to libavutil Date: 03/18/2008 6:09 AM Originally committed as revision 12489 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/common.h')
-rw-r--r--libavutil/common.h32
1 files changed, 24 insertions, 8 deletions
diff --git a/libavutil/common.h b/libavutil/common.h
index fd1d00c7b3..d2489e3f32 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -57,6 +57,22 @@
#endif
#endif
+#ifndef av_pure
+#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
+# define av_pure __attribute__((pure))
+#else
+# define av_pure
+#endif
+#endif
+
+#ifndef av_const
+#if defined(__GNUC__) && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ > 5)
+# define av_const __attribute__((const))
+#else
+# define av_const
+#endif
+#endif
+
#ifdef HAVE_AV_CONFIG_H
# include "internal.h"
#endif /* HAVE_AV_CONFIG_H */
@@ -94,7 +110,7 @@
/* misc math functions */
extern const uint8_t ff_log2_tab[256];
-static inline int av_log2(unsigned int v)
+static inline av_const int av_log2(unsigned int v)
{
int n = 0;
if (v & 0xffff0000) {
@@ -110,7 +126,7 @@ static inline int av_log2(unsigned int v)
return n;
}
-static inline int av_log2_16bit(unsigned int v)
+static inline av_const int av_log2_16bit(unsigned int v)
{
int n = 0;
if (v & 0xff00) {
@@ -123,7 +139,7 @@ static inline int av_log2_16bit(unsigned int v)
}
/* median of 3 */
-static inline int mid_pred(int a, int b, int c)
+static inline av_const int mid_pred(int a, int b, int c)
{
#ifdef HAVE_CMOV
int i=b;
@@ -170,7 +186,7 @@ static inline int mid_pred(int a, int b, int c)
* @param amax maximum value of the clip range
* @return clipped value
*/
-static inline int av_clip(int a, int amin, int amax)
+static inline av_const int av_clip(int a, int amin, int amax)
{
if (a < amin) return amin;
else if (a > amax) return amax;
@@ -182,7 +198,7 @@ static inline int av_clip(int a, int amin, int amax)
* @param a value to clip
* @return clipped value
*/
-static inline uint8_t av_clip_uint8(int a)
+static inline av_const uint8_t av_clip_uint8(int a)
{
if (a&(~255)) return (-a)>>31;
else return a;
@@ -193,19 +209,19 @@ static inline uint8_t av_clip_uint8(int a)
* @param a value to clip
* @return clipped value
*/
-static inline int16_t av_clip_int16(int a)
+static inline av_const int16_t av_clip_int16(int a)
{
if ((a+32768) & ~65535) return (a>>31) ^ 32767;
else return a;
}
/* math */
-int64_t ff_gcd(int64_t a, int64_t b);
+int64_t av_const ff_gcd(int64_t a, int64_t b);
/**
* converts fourcc string to int
*/
-static inline int ff_get_fourcc(const char *s){
+static inline av_pure int ff_get_fourcc(const char *s){
#ifdef HAVE_AV_CONFIG_H
assert( strlen(s)==4 );
#endif