summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac1
-rw-r--r--m4/attributes.m48
-rw-r--r--src/xine-utils/attributes.h7
3 files changed, 16 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 671bd0c18..79c93f448 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2219,6 +2219,7 @@ CC_ATTRIBUTE_DEPRECATED
CC_ATTRIBUTE_UNUSED
CC_ATTRIBUTE_MALLOC
CC_ATTRIBUTE_PACKED
+CC_ATTRIBUTE_CONST
AC_OPTIMIZATIONS
diff --git a/m4/attributes.m4 b/m4/attributes.m4
index fa379a2fe..f71b3d0d0 100644
--- a/m4/attributes.m4
+++ b/m4/attributes.m4
@@ -188,6 +188,14 @@ AC_DEFUN([CC_ATTRIBUTE_PACKED], [
[$2])
])
+AC_DEFUN([CC_ATTRIBUTE_CONST], [
+ CC_CHECK_ATTRIBUTE(
+ [const], ,
+ [int __attribute__((const)) twopow(int n) { return 1 << n; } ],
+ [$1],
+ [$2])
+])
+
AC_DEFUN([CC_FLAG_VISIBILITY], [
AC_REQUIRE([CC_CHECK_WERROR])
AC_CACHE_CHECK([if $CC supports -fvisibility=hidden],
diff --git a/src/xine-utils/attributes.h b/src/xine-utils/attributes.h
index 29bb9f28f..3819818d5 100644
--- a/src/xine-utils/attributes.h
+++ b/src/xine-utils/attributes.h
@@ -45,6 +45,7 @@
# define SUPPORT_ATTRIBUTE_FORMAT_ARG 1
# define SUPPORT_ATTRIBUTE_MALLOC 1
# define SUPPORT_ATTRIBUTE_UNUSED 1
+# define SUPPORT_ATTRIBUTE_CONST 1
# endif
# if __GNUC__ >= 4
@@ -109,4 +110,10 @@
# define XINE_PACKED
#endif
+#ifdef SUPPORT_ATTRIBUTE_CONST
+# define XINE_CONST __attribute__((__const__))
+#else
+# define XINE_CONST
+#endif
+
#endif /* ATTRIBUTE_H_ */