diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-09 15:16:17 +0200 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-09 15:16:17 +0200 |
commit | c99cd9519a56b2d7c60fa30e9fecd02f08336671 (patch) | |
tree | d897b2e3e31a2386a16dc6b5f4c3500ac66f601f | |
parent | ed72565137c93ab0385a10036d234f5f4dd1b960 (diff) | |
download | xine-lib-c99cd9519a56b2d7c60fa30e9fecd02f08336671.tar.gz xine-lib-c99cd9519a56b2d7c60fa30e9fecd02f08336671.tar.bz2 |
Cleanup handling of packed attribute.
- Add a configure test for the attribute, during xine build process.
- Define the attribute as supported when using GCC 2.95 or later
outside xine build process.
- Use the new XINE_PACKED define instead of the attribute directly.
- Check for SUPPORT_ATTRIBUTE_PACKED rather than doing strange
subdefines.
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | m4/attributes.m4 | 8 | ||||
-rw-r--r-- | src/combined/combined_wavpack.h | 3 | ||||
-rw-r--r-- | src/xine-engine/alphablend.h | 21 | ||||
-rw-r--r-- | src/xine-engine/buffer.h | 8 | ||||
-rw-r--r-- | src/xine-utils/attributes.h | 23 |
6 files changed, 28 insertions, 36 deletions
diff --git a/configure.ac b/configure.ac index 0c9168c7b..188a0e0d3 100644 --- a/configure.ac +++ b/configure.ac @@ -2218,6 +2218,7 @@ CC_ATTRIBUTE_FORMAT_ARG CC_ATTRIBUTE_DEPRECATED CC_ATTRIBUTE_UNUSED CC_ATTRIBUTE_MALLOC +CC_ATTRIBUTE_PACKED AC_OPTIMIZATIONS diff --git a/m4/attributes.m4 b/m4/attributes.m4 index 393ee0ba7..bb53cca41 100644 --- a/m4/attributes.m4 +++ b/m4/attributes.m4 @@ -166,6 +166,14 @@ AC_DEFUN([CC_ATTRIBUTE_MALLOC], [ [$2]) ]) +AC_DEFUN([CC_ATTRIBUTE_PACKED], [ + CC_CHECK_ATTRIBUTE( + [packed], , + [struct astructure { char a; int b; long c; void *d; } __attribute__((packed));], + [$1], + [$2]) +]) + AC_DEFUN([CC_FLAG_VISIBILITY], [ AC_REQUIRE([CC_CHECK_WERROR]) ac_save_CFLAGS="$CFLAGS" diff --git a/src/combined/combined_wavpack.h b/src/combined/combined_wavpack.h index 61a504a4f..3cfa78509 100644 --- a/src/combined/combined_wavpack.h +++ b/src/combined/combined_wavpack.h @@ -21,6 +21,7 @@ */ #include "os_types.h" +#include "attributes.h" typedef struct { uint32_t idcode; /* This should always be the string "wvpk" */ @@ -35,7 +36,7 @@ typedef struct { uint32_t samples_count; /* Count of samples in the current frame */ uint32_t flags; /* Misc flags */ uint32_t decoded_crc32; /* CRC32 of the decoded data */ -} __attribute__((packed)) wvheader_t; +} XINE_PACKED wvheader_t; #ifdef WORDS_BIGENDIAN static const uint32_t wvpk_signature = ('k' + ('p' << 8) + ('v' << 16) + ('w' << 24)); diff --git a/src/xine-engine/alphablend.h b/src/xine-engine/alphablend.h index 3c9a693d9..7aa63b306 100644 --- a/src/xine-engine/alphablend.h +++ b/src/xine-engine/alphablend.h @@ -39,22 +39,7 @@ typedef struct { void _x_alphablend_init(alphablend_t *extra_data, xine_t *xine) XINE_PROTECTED; void _x_alphablend_free(alphablend_t *extra_data) XINE_PROTECTED; -/* _MSC_VER port changes */ -#undef ATTRIBUTE_PACKED -#undef PRAGMA_PACK_BEGIN -#undef PRAGMA_PACK_END - -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) || defined(__ICC) -#define ATTRIBUTE_PACKED __attribute__ ((packed)) -#define PRAGMA_PACK 0 -#endif - -#if !defined(ATTRIBUTE_PACKED) -#define ATTRIBUTE_PACKED -#define PRAGMA_PACK 1 -#endif - -#if PRAGMA_PACK +#if !SUPPORT_ATTRIBUTE_PACKED #pragma pack(8) #endif @@ -63,10 +48,10 @@ typedef struct { /* CLUT == Color LookUp Table */ uint8_t cr; uint8_t y; uint8_t foo; -} ATTRIBUTE_PACKED clut_t; +} XINE_PACKED clut_t; -#if PRAGMA_PACK +#if !SUPPORT_ATTRIBUTE_PACKED #pragma pack() #endif diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h index ebb308a04..e0dc88bc7 100644 --- a/src/xine-engine/buffer.h +++ b/src/xine-engine/buffer.h @@ -627,7 +627,7 @@ uint32_t _x_formattag_to_buf_audio( uint32_t formattag ) XINE_PROTECTED; char * _x_buf_audio_name( uint32_t buf_type ) XINE_PROTECTED; -#ifndef ATTRIBUTE_PACKED +#ifndef SUPPORT_ATTRIBUTE_PACKED /* no attribute packed? let's try with pragma pack as a last resort */ #pragma pack(2) #endif @@ -636,7 +636,7 @@ char * _x_buf_audio_name( uint32_t buf_type ) XINE_PROTECTED; * - will always use machine endian format, so demuxers reading * stuff from win32 formats must use the function below. */ -typedef struct __attribute__((__packed__)) { +typedef struct XINE_PACKED { int32_t biSize; int32_t biWidth; int32_t biHeight; @@ -653,7 +653,7 @@ typedef struct __attribute__((__packed__)) { /* this is xine version of WAVEFORMATEX * (the same comments from xine_bmiheader) */ -typedef struct __attribute__((__packed__)) { +typedef struct XINE_PACKED { int16_t wFormatTag; int16_t nChannels; int32_t nSamplesPerSec; @@ -662,7 +662,7 @@ typedef struct __attribute__((__packed__)) { int16_t wBitsPerSample; int16_t cbSize; } xine_waveformatex; -#ifndef ATTRIBUTE_PACKED +#ifndef SUPPORT_ATTRIBUTE_PACKED #pragma pack() #endif diff --git a/src/xine-utils/attributes.h b/src/xine-utils/attributes.h index cb861303d..29bb9f28f 100644 --- a/src/xine-utils/attributes.h +++ b/src/xine-utils/attributes.h @@ -32,27 +32,18 @@ #define ATTR_ALIGN(align) #endif -/* disable GNU __attribute__ extension, when not compiling with GNU C */ -#if defined(__GNUC__) || defined (__ICC) -#ifndef ATTRIBUTE_PACKED -#define ATTRIBUTE_PACKED 1 -#endif -#else -#undef ATTRIBUTE_PACKED -#ifndef __attribute__ -#define __attribute__(x) /**/ -#endif /* __attribute __*/ -#endif - #ifdef XINE_COMPILE # include "configure.h" #else +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95 ) +# define SUPPORT_ATTRIBUTE_PACKED 1 +# endif + # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3 ) # define SUPPORT_ATTRIBUTE_DEPRECATED 1 # define SUPPORT_ATTRIBUTE_FORMAT 1 # define SUPPORT_ATTRIBUTE_FORMAT_ARG 1 # define SUPPORT_ATTRIBUTE_MALLOC 1 -# define SUPPORT_ATTRIBUTE_PACKED 1 # define SUPPORT_ATTRIBUTE_UNUSED 1 # endif @@ -112,4 +103,10 @@ # define XINE_MALLOC #endif +#ifdef SUPPORT_ATTRIBUTE_PACKED +# define XINE_PACKED __attribute__((__packed__)) +#else +# define XINE_PACKED +#endif + #endif /* ATTRIBUTE_H_ */ |