From f5f234c94e3c914bc76a33d892aef4e45be5fa6c Mon Sep 17 00:00:00 2001
From: nplourde <nplourde@b3059339-0415-0410-9bf9-f77b7e298cf2>
Date: Sun, 15 May 2005 20:11:34 +0000
Subject: [PATCH] set define for apple gcc altivec

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15484 b3059339-0415-0410-9bf9-f77b7e298cf2
---
 configure               |  5 +----
 libmpeg2/cpu_accel.c    |  6 +++---
 libmpeg2/cpu_state.c    | 14 +++++++-------
 libmpeg2/idct_altivec.c |  8 ++++----
 4 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/configure b/configure
index 6899201b62..6844088497 100755
--- a/configure
+++ b/configure
@@ -1973,7 +1973,7 @@ int main() {
 }
 EOF
         FSF_flags='-maltivec -mabi=altivec'
-        Darwin_flags='-faltivec'
+        Darwin_flags='-faltivec -D__APPLE_ALTIVEC__'
 
         # check for Darwin-style flags first, since
         # gcc-3.3 (August Update from Apple) on MacOS 10.2.8
@@ -3225,9 +3225,6 @@ EOF
     _aomodules="macosx $_aomodules"
     _vosrc="$_vosrc vo_quartz.c"
     _vomodules="quartz $_vomodules"
-    if test "$_cc_major" -ge "4" ; then
-      _def_altivec_h='#undef HAVE_ALTIVEC_H'
-    fi
   else
     _macosx=no
     _def_macosx='#undef MACOSX'
diff --git a/libmpeg2/cpu_accel.c b/libmpeg2/cpu_accel.c
index 62fa7b8dc5..715b126642 100644
--- a/libmpeg2/cpu_accel.c
+++ b/libmpeg2/cpu_accel.c
@@ -143,10 +143,10 @@ static inline uint32_t arch_accel (void)
 
     canjump = 1;
 
-#ifdef HAVE_ALTIVEC_H	/* gnu */
-#define VAND(a,b,c) "vand " #a "," #b "," #c "\n\t"
-#else			/* apple */
+#if defined( __APPLE_CC__ ) && defined( __APPLE_ALTIVEC__ ) /* apple */
 #define VAND(a,b,c) "vand v" #a ",v" #b ",v" #c "\n\t"
+#else			/* gnu */
+#define VAND(a,b,c) "vand " #a "," #b "," #c "\n\t"
 #endif
     asm volatile ("mtspr 256, %0\n\t"
 		  VAND (0, 0, 0)
diff --git a/libmpeg2/cpu_state.c b/libmpeg2/cpu_state.c
index 1e5ecdc26a..9244668b0a 100644
--- a/libmpeg2/cpu_state.c
+++ b/libmpeg2/cpu_state.c
@@ -48,18 +48,18 @@ static void state_restore_mmx (cpu_state_t * state)
 #endif
 
 #if defined( ARCH_PPC ) && defined( HAVE_ALTIVEC )
-#ifdef HAVE_ALTIVEC_H	/* gnu */
-#define LI(a,b) "li " #a "," #b "\n\t"
-#define STVX0(a,b,c) "stvx " #a ",0," #c "\n\t"
-#define STVX(a,b,c) "stvx " #a "," #b "," #c "\n\t"
-#define LVX0(a,b,c) "lvx " #a ",0," #c "\n\t"
-#define LVX(a,b,c) "lvx " #a "," #b "," #c "\n\t"
-#else			/* apple */
+#if defined( __APPLE_CC__ ) && defined( __APPLE_ALTIVEC__ )	/* apple */
 #define LI(a,b) "li r" #a "," #b "\n\t"
 #define STVX0(a,b,c) "stvx v" #a ",0,r" #c "\n\t"
 #define STVX(a,b,c) "stvx v" #a ",r" #b ",r" #c "\n\t"
 #define LVX0(a,b,c) "lvx v" #a ",0,r" #c "\n\t"
 #define LVX(a,b,c) "lvx v" #a ",r" #b ",r" #c "\n\t"
+#else			/* gnu */
+#define LI(a,b) "li " #a "," #b "\n\t"
+#define STVX0(a,b,c) "stvx " #a ",0," #c "\n\t"
+#define STVX(a,b,c) "stvx " #a "," #b "," #c "\n\t"
+#define LVX0(a,b,c) "lvx " #a ",0," #c "\n\t"
+#define LVX(a,b,c) "lvx " #a "," #b "," #c "\n\t"
 #endif
 
 static void state_save_altivec (cpu_state_t * state)
diff --git a/libmpeg2/idct_altivec.c b/libmpeg2/idct_altivec.c
index 6b1b8586c0..3eec6b49d0 100644
--- a/libmpeg2/idct_altivec.c
+++ b/libmpeg2/idct_altivec.c
@@ -41,7 +41,7 @@ typedef vector unsigned short vector_u16_t;
 typedef vector signed int vector_s32_t;
 typedef vector unsigned int vector_u32_t;
 
-#if defined(HAVE_ALTIVEC_H) && (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
+#if defined( HAVE_ALTIVEC_H ) && !defined( __APPLE_ALTIVEC__ ) && (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
 /* work around gcc <3.3 vec_mergel bug */
 static inline vector_s16_t my_vec_mergel (vector_s16_t const A,
 					  vector_s16_t const B)
@@ -56,10 +56,10 @@ static inline vector_s16_t my_vec_mergel (vector_s16_t const A,
 #define vec_mergel my_vec_mergel
 #endif
 
-#ifdef HAVE_ALTIVEC_H	/* gnu */
-#define VEC_S16(a,b,c,d,e,f,g,h) {a, b, c, d, e, f, g, h}
-#else			/* apple */
+#if defined( __APPLE_CC__ ) && defined( __APPLE_ALTIVEC__ ) /* apple */
 #define VEC_S16(a,b,c,d,e,f,g,h) (vector_s16_t) (a, b, c, d, e, f, g, h)
+#else			/* gnu */
+#define VEC_S16(a,b,c,d,e,f,g,h) {a, b, c, d, e, f, g, h}
 #endif
 
 static const vector_s16_t constants ATTR_ALIGN(16) =