changeset 21290:efc774a1e5a4

fix compilation for win32 dll codec support for intel osx
author nplourde
date Mon, 27 Nov 2006 02:44:06 +0000
parents fdd55cd8eb2a
children efec4a336747
files help/help_mp-en.h loader/Makefile loader/ldt_keeper.c loader/module.c loader/stubs.S loader/stubs.s loader/wine/poppack.h mp_msg.h
diffstat 8 files changed, 70 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/help/help_mp-en.h	Mon Nov 27 02:20:15 2006 +0000
+++ b/help/help_mp-en.h	Mon Nov 27 02:44:06 2006 +0000
@@ -1924,6 +1924,11 @@
 "[VO_XV] See 'mplayer -vo help' for other (non-xv) video out drivers.\n"\
 "[VO_XV] Try -vo x11.\n"
 
+
+// loader/ldt_keeper.c
+
+#define MSGTR_LOADER_DYLD_Warning "WARNING: Attempting to use DLL codecs but environment variable DYLD_BIND_AT_LAUNCH not set.\nThis will likely crash.\n"
+
 // stream/stream_radio.c
 
 #define MSGTR_RADIO_ChannelNamesDetected "[radio] Radio channel names detected.\n"
--- a/loader/Makefile	Mon Nov 27 02:20:15 2006 +0000
+++ b/loader/Makefile	Mon Nov 27 02:44:06 2006 +0000
@@ -8,7 +8,12 @@
 SRCS= driver.c afl.c vfl.c
 ifneq ($(TARGET_WIN32),yes)
 SRCS+= ldt_keeper.c pe_image.c module.c ext.c win32.c \
-       pe_resource.c resource.c registry.c elfdll.c wrapper.S stubs.s
+       pe_resource.c resource.c registry.c elfdll.c stubs.S
+endif
+
+# QTX emulation is not supported in Darwin
+ifneq ($(TARGET_OS),Darwin)
+SRCS+= wrapper.S
 endif
 
 SRCS+= dshow/DS_AudioDecoder.c \
--- a/loader/ldt_keeper.c	Mon Nov 27 02:20:15 2006 +0000
+++ b/loader/ldt_keeper.c	Mon Nov 27 02:44:06 2006 +0000
@@ -29,6 +29,8 @@
 #include <stdio.h>
 #include <unistd.h>
 #include "osdep/mmap_anon.h"
+#include "mp_msg.h"
+#include "help_mp.h"
 #ifdef __linux__
 #include <asm/unistd.h>
 #include <asm/ldt.h>
@@ -103,8 +105,9 @@
 #define       LDT_SEL(idx) ((idx) << 3 | 1 << 2 | 3)
 
 /* i got this value from wine sources, it's the first free LDT entry */
-#if defined(__FreeBSD__) && defined(LDT_AUTO_ALLOC)
+#if (defined(__APPLE__) || defined(__FreeBSD__)) && defined(LDT_AUTO_ALLOC)
 #define       TEB_SEL_IDX     LDT_AUTO_ALLOC
+#define	      USE_LDT_AA
 #endif
 
 #ifndef       TEB_SEL_IDX
@@ -168,7 +171,7 @@
 #endif
 #endif
 
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__APPLE__)
 static void LDT_EntryToBytes( unsigned long *buffer, const struct modify_ldt_ldt_s *content )
 {
     *buffer++ = ((content->base_addr & 0x0000ffff) << 16) |
@@ -195,6 +198,11 @@
     if (!ldt_fs)
 	return NULL;
 
+#ifdef __APPLE__
+    if (getenv("DYLD_BIND_AT_LAUNCH") == NULL)
+        mp_msg(MSGT_LOADER, MSGL_WARN, MSGTR_LOADER_DYLD_Warning);
+#endif /* __APPLE__ */
+    
     fs_seg=
     ldt_fs->fs_seg = mmap_anon(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE, 0);
     if (ldt_fs->fs_seg == (void*)-1)
@@ -223,12 +231,12 @@
     }
 #endif /*linux*/
 
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__APPLE__)
     {
         unsigned long d[2];
 
         LDT_EntryToBytes( d, &array );
-#if defined(__FreeBSD__) && defined(LDT_AUTO_ALLOC)
+#ifdef USE_LDT_AA
         ret = i386_set_ldt(LDT_AUTO_ALLOC, (union descriptor *)d, 1);
         array.entry_number = ret;
         fs_ldt = ret;
@@ -245,7 +253,7 @@
 #endif
         }
     }
-#endif  /* __NetBSD__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ */
+#endif  /* __NetBSD__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __APPLE__ */
 
 #if defined(__svr4__)
     {
--- a/loader/module.c	Mon Nov 27 02:20:15 2006 +0000
+++ b/loader/module.c	Mon Nov 27 02:44:06 2006 +0000
@@ -10,7 +10,9 @@
  */
 
 // define for quicktime calls debugging and/or MacOS-level emulation:
+#ifndef __APPLE__
 #define EMU_QTX_API
+#endif /* __APPLE__ */
 
 // define for quicktime debugging (verbose logging):
 //#define DEBUG_QTX_API
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loader/stubs.S	Mon Nov 27 02:44:06 2006 +0000
@@ -0,0 +1,40 @@
+#if defined(__APPLE__) || defined(__OpenBSD__)
+# define SYM(x) _ ## x
+#else
+# define SYM(x) x
+#endif
+	.data
+.LC0:	.asciz	"Called unk_%s\n"
+       .p2align 4
+.globl SYM(unk_exp1)
+SYM(unk_exp1):
+	pushl %ebp
+	movl %esp,%ebp
+	subl $4,%esp
+	movl $1,-4(%ebp)
+	movl -4(%ebp),%eax
+	movl %eax,%ecx
+	movl %ecx,%edx
+	sall $4,%edx
+	subl %eax,%edx
+	leal 0(,%edx,2),%eax
+	movl %eax,%edx
+	addl $SYM(export_names),%edx
+	pushl %edx
+	pushl $.LC0
+	call SYM(printf)
+	addl $8,%esp
+	xorl %eax,%eax
+	leave
+	ret
+.globl SYM(exp_EH_prolog)
+SYM(exp_EH_prolog):
+	pushl $0xff
+	pushl %eax
+	pushl %fs:0
+	movl  %esp, %fs:0
+	movl  12(%esp), %eax
+	movl  %ebp, 12(%esp)
+	leal  12(%esp), %ebp
+	pushl %eax
+	ret
--- a/loader/stubs.s	Mon Nov 27 02:20:15 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-	.data
-.LC0:	.string	"Called unk_%s\n"
-       .balign 4
-.globl unk_exp1
-unk_exp1:
-	pushl %ebp
-	movl %esp,%ebp
-	subl $4,%esp
-	movl $1,-4(%ebp)
-	movl -4(%ebp),%eax
-	movl %eax,%ecx
-	movl %ecx,%edx
-	sall $4,%edx
-	subl %eax,%edx
-	leal 0(,%edx,2),%eax
-	movl %eax,%edx
-	addl $export_names,%edx
-	pushl %edx
-	pushl $.LC0
-	call printf
-	addl $8,%esp
-	xorl %eax,%eax
-	leave
-	ret
-.globl exp_EH_prolog
-exp_EH_prolog:
-	pushl $0xff
-	pushl %eax
-	pushl %fs:0
-	movl  %esp, %fs:0
-	movl  12(%esp), %eax
-	movl  %ebp, 12(%esp)
-	leal  12(%esp), %ebp
-	pushl %eax
-	ret
--- a/loader/wine/poppack.h	Mon Nov 27 02:20:15 2006 +0000
+++ b/loader/wine/poppack.h	Mon Nov 27 02:44:06 2006 +0000
@@ -1,9 +1,9 @@
 #ifdef __WINE_PSHPACK_H
 #undef __WINE_PSHPACK_H
 
-#if defined(__GNUC__) || defined(__SUNPRO_C)
+#if (defined(__GNUC__) || defined(__SUNPRO_C)) && !defined(__APPLE__)
 #pragma pack()
-#elif defined(__SUNPRO_CC)
+#elif defined(__SUNPRO_CC) || defined(__APPLE__)
 #warning "Assumes default alignment is 4"
 #pragma pack(4)
 #elif !defined(RC_INVOKED)
--- a/mp_msg.h	Mon Nov 27 02:20:15 2006 +0000
+++ b/mp_msg.h	Mon Nov 27 02:44:06 2006 +0000
@@ -101,6 +101,8 @@
 
 #define MSGT_ASS 43 // libass messages
 
+#define MSGT_LOADER 44 // dll loader messages
+
 #define MSGT_MAX 64
 
 void mp_msg_init(void);