diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-05 21:59:42 +0200 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-05 21:59:42 +0200 |
commit | cfd7b72175341d19baf7a76cc3e66960df0012cd (patch) | |
tree | 32bb5e27e08a36102267bbed857bc9cd24660746 | |
parent | ac8886fbc94069026f5ad921145d0c9007df7411 (diff) | |
download | xine-lib-cfd7b72175341d19baf7a76cc3e66960df0012cd.tar.gz xine-lib-cfd7b72175341d19baf7a76cc3e66960df0012cd.tar.bz2 |
Check for malloc attribute and define XINE_MALLOC for use in xineutils.h, rather than just checking for GCC 3.
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | m4/attributes.m4 | 8 | ||||
-rw-r--r-- | src/xine-utils/attributes.h | 6 | ||||
-rw-r--r-- | src/xine-utils/xineutils.h | 6 |
4 files changed, 16 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac index de176fc9e..0c9168c7b 100644 --- a/configure.ac +++ b/configure.ac @@ -2217,6 +2217,7 @@ CC_ATTRIBUTE_FORMAT CC_ATTRIBUTE_FORMAT_ARG CC_ATTRIBUTE_DEPRECATED CC_ATTRIBUTE_UNUSED +CC_ATTRIBUTE_MALLOC AC_OPTIMIZATIONS diff --git a/m4/attributes.m4 b/m4/attributes.m4 index 436c36b87..d7fc94b12 100644 --- a/m4/attributes.m4 +++ b/m4/attributes.m4 @@ -160,6 +160,14 @@ AC_DEFUN([CC_ATTRIBUTE_ALIAS], [ [$2]) ]) +AC_DEFUN([CC_ATTRIBUTE_MALLOC], [ + CC_CHECK_ATTRIBUTE( + [malloc], , + [void * __attribute__((malloc)) my_alloc(int n);], + [$1], + [$2]) +]) + AC_DEFUN([CC_FLAG_VISIBILITY], [ AC_REQUIRE([CC_CHECK_WERROR]) ac_save_CFLAGS="$CFLAGS" diff --git a/src/xine-utils/attributes.h b/src/xine-utils/attributes.h index 2085be571..3d6e66359 100644 --- a/src/xine-utils/attributes.h +++ b/src/xine-utils/attributes.h @@ -89,4 +89,10 @@ # define XINE_FORMAT_PRINTF_ARG(fmt) #endif +#ifdef SUPPORT_ATTRIBUTE_MALLOC +# define XINE_MALLOC __attribute__((__malloc__)) +#else +# define XINE_MALLOC +#endif + #endif /* ATTRIBUTE_H_ */ diff --git a/src/xine-utils/xineutils.h b/src/xine-utils/xineutils.h index 01afc1631..2099bf7f3 100644 --- a/src/xine-utils/xineutils.h +++ b/src/xine-utils/xineutils.h @@ -621,11 +621,7 @@ void xine_profiler_print_results (void) XINE_PROTECTED; * Allocate and clean memory size_t 'size', then return the pointer * to the allocated memory. */ -#if !defined(__GNUC__) || __GNUC__ < 3 -void *xine_xmalloc(size_t size) XINE_PROTECTED; -#else -void *xine_xmalloc(size_t size) __attribute__ ((__malloc__)) XINE_PROTECTED; -#endif +void *xine_xmalloc(size_t size) XINE_MALLOC XINE_PROTECTED; /* * Same as above, but memory is aligned to 'alignement'. |