summaryrefslogtreecommitdiff
path: root/libavutil/common.h
diff options
context:
space:
mode:
authorZuxy Meng <zuxy.meng@gmail.com>2008-03-19 06:17:43 +0000
committerZuxy Meng <zuxy.meng@gmail.com>2008-03-19 06:17:43 +0000
commit85074d3c9388123d792995c8f98c9b5d807566b4 (patch)
tree54440eea962c4864599dd5403fc0244becb24875 /libavutil/common.h
parentd1928ac1296a09c658ba64fe5c503979e280a2e0 (diff)
Reapply r12489: Add pure, const and malloc attributes to proper functions
in libavutil. Fix a compilation failure in r12489. Originally committed as revision 12498 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