changeset 21040:c7d3523c74ee

fix mp3lib compilation on OSX
author nplourde
date Sun, 19 Nov 2006 15:21:50 +0000
parents 493b34d15885
children 456aef02280d
files mp3lib/Makefile mp3lib/dct64_sse.c mp3lib/decod386.c mp3lib/decode_MMX.c mp3lib/sr1.c
diffstat 5 files changed, 28 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mp3lib/Makefile	Sun Nov 19 14:35:39 2006 +0000
+++ b/mp3lib/Makefile	Sun Nov 19 15:21:50 2006 +0000
@@ -9,9 +9,17 @@
 SRCS = sr1.c
 ifeq ($(TARGET_ARCH_X86_32),yes)
 SRCS += decode_i586.c
+# Darwin can't compile tabinit_MMX.c. However, we need costab_mmx from
+# decode_mmx.c for dct64_sse.c.
+ifeq ($(TARGET_OS),Darwin)
+ifeq ($(TARGET_MMX),yes)
+SRCS += decode_MMX.c
+endif
+else
 ifeq ($(TARGET_MMX),yes)
 SRCS += decode_MMX.c dct64_MMX.c tabinit_MMX.c
 endif
+endif
 ifeq ($(TARGET_3DNOW),yes)
 SRCS += dct36_3dnow.c dct64_3dnow.c
 endif
--- a/mp3lib/dct64_sse.c	Sun Nov 19 14:35:39 2006 +0000
+++ b/mp3lib/dct64_sse.c	Sun Nov 19 15:21:50 2006 +0000
@@ -298,6 +298,13 @@
        To do saturation efficiently in x86 we can use fist(t)(p),
        pf2iw, or packssdw. We use fist(p) here.
     */
+
+#ifdef SYS_DARWIN
+#define FFREEP "fstp %%st(0)\n\t"
+#else
+#define FFREEP "ffreep %%st(0)\n\t"
+#endif /* SYS_DARWIN */
+
     asm(
         "flds       %0\n\t"
         "flds     (%2)\n\t"
@@ -426,7 +433,7 @@
         "fist  480(%4)\n\t"
         "fadds  92(%1)\n\t"
         "fistp 416(%4)\n\t"
-        "ffreep %%st(0)\n\t"
+        FFREEP
         :
         :"m"(costab_mmx[30]), "r"(b1), "r"(b2), "r"(a), "r"(b)
         :"memory"
--- a/mp3lib/decod386.c	Sun Nov 19 14:35:39 2006 +0000
+++ b/mp3lib/decod386.c	Sun Nov 19 15:21:50 2006 +0000
@@ -19,6 +19,11 @@
 
 #include "config.h"
 
+/* Can't compile MMX assembly on Darwin */
+#ifdef SYS_DARWIN
+#undef HAVE_MMX
+#endif /* SYS_DARWIN */
+
 #if 0
  /* old WRITE_SAMPLE */
    /* is portable */
--- a/mp3lib/decode_MMX.c	Sun Nov 19 14:35:39 2006 +0000
+++ b/mp3lib/decode_MMX.c	Sun Nov 19 15:21:50 2006 +0000
@@ -48,6 +48,7 @@
 	1060439283,
 };
 
+#ifndef SYS_DARWIN
 static int temp; // buggy gcc 3.x fails if this is moved into the function :(
 void synth_1to1_MMX_s(real *bandPtr, int channel, short *samples,
                       short *buffs, int *bo)
@@ -246,3 +247,4 @@
 	:"m"(bandPtr),"m"(channel),"m"(samples),"m"(buffs),"m"(bo), "m"(temp)
 	:"memory","%edi","%esi","%ebx","%esp");
 }
+#endif /* SYS_DARWIN */
--- a/mp3lib/sr1.c	Sun Nov 19 14:35:39 2006 +0000
+++ b/mp3lib/sr1.c	Sun Nov 19 15:21:50 2006 +0000
@@ -31,6 +31,11 @@
 
 #include "libvo/fastmemcpy.h"
 
+// Can't compile MMX assembly on Darwin
+#ifdef SYS_DARWIN
+#undef HAVE_MMX
+#endif /* SYS_DARWIN */
+
 #ifdef ARCH_X86_32
 #define CAN_COMPILE_X86_ASM
 #endif