From e74947be2c52722a3ddab3eb751fd2f6895884a6 Mon Sep 17 00:00:00 2001
From: Tim Angus <tim@ngus.net>
Date: Sun, 15 Jan 2006 15:22:13 +0000
Subject: [PATCH] * x86 OS X support

---
 code/qcommon/vm_x86.c     | 16 ++++++++--------
 code/tools/lcc/cpp/unix.c |  2 ++
 code/unix/ftola.s         | 16 ++++++++--------
 code/unix/qasm.h          |  2 +-
 code/unix/snapvectora.s   |  4 ++--
 5 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/code/qcommon/vm_x86.c b/code/qcommon/vm_x86.c
index 15e99184..79074d9c 100644
--- a/code/qcommon/vm_x86.c
+++ b/code/qcommon/vm_x86.c
@@ -170,7 +170,7 @@ _asm {
 
 #else //!_MSC_VER
 
-#ifdef __MINGW32__ // _ is prepended to compiled symbols
+#if defined(__MINGW32__) || defined(MACOS_X) // _ is prepended to compiled symbols
 #define CMANG(sym) "_"#sym
 #else
 #define CMANG(sym) #sym
@@ -1174,13 +1174,13 @@ int	VM_CallCompiled( vm_t *vm, int *args ) {
 		memOpStack      = opStack;     
 		memEntryPoint   = entryPoint;  
 		
-		__asm__("	pushal				\r\n" \
-				"	movl %0,%%esi		\r\n" \
-				"	movl %1,%%edi		\r\n" \
-				"	call *%2			\r\n" \
-				"	movl %%esi,%0		\r\n" \
-				"	movl %%edi,%1		\r\n" \
-				"	popal				\r\n" \
+		__asm__("	pushal				\n" \
+				"	movl %0,%%esi		\n" \
+				"	movl %1,%%edi		\n" \
+				"	call *%2			\n" \
+				"	movl %%esi,%0		\n" \
+				"	movl %%edi,%1		\n" \
+				"	popal				\n" \
 				: "=m" (memProgramStack), "=m" (memOpStack) \
 				: "m" (memEntryPoint), "m" (memProgramStack), "m" (memOpStack) \
 				: "si", "di" \
diff --git a/code/tools/lcc/cpp/unix.c b/code/tools/lcc/cpp/unix.c
index f58b51ef..9d8e5683 100644
--- a/code/tools/lcc/cpp/unix.c
+++ b/code/tools/lcc/cpp/unix.c
@@ -93,6 +93,7 @@ char *basepath( char *fname )
 /* memmove is defined here because some vendors don't provide it at
    all and others do a terrible job (like calling malloc) */
 // -- ouch, that hurts -- ln
+#ifndef MACOS_X   /* always use the system memmove() on Mac OS X. --ryan. */
 #ifdef memmove
 #undef memmove
 #endif
@@ -118,3 +119,4 @@ memmove(void *dp, const void *sp, size_t n)
 	}
 	return 0;
 }
+#endif
diff --git a/code/unix/ftola.s b/code/unix/ftola.s
index 7fb24c0e..7e9c523e 100644
--- a/code/unix/ftola.s
+++ b/code/unix/ftola.s
@@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 .data
 
-temp:   .float    0.0
+temp:   .single   0.0
 fpucw:  .long     0
 
 // Precision Control Field , 2 bits / 0x0300
@@ -63,7 +63,7 @@ cw0F7F: .long     0x0F7F
 // int qftol( void ) - default control word
 //
 
-.global C(qftol)
+.globl C(qftol)
 
 C(qftol):
         fistpl temp
@@ -75,7 +75,7 @@ C(qftol):
 // int qftol027F( void ) - DirectX FPU
 //
 
-.global C(qftol027F)
+.globl C(qftol027F)
 
 C(qftol027F):
         fnstcw fpucw
@@ -89,7 +89,7 @@ C(qftol027F):
 // int qftol037F( void ) - Linux FPU
 //
 
-.global C(qftol037F)
+.globl C(qftol037F)
 
 C(qftol037F):
         fnstcw fpucw
@@ -104,7 +104,7 @@ C(qftol037F):
 // int qftol0F7F( void ) - ANSI
 //
 
-.global C(qftol0F7F)
+.globl C(qftol0F7F)
 
 C(qftol0F7F):
         fnstcw fpucw
@@ -118,7 +118,7 @@ C(qftol0F7F):
 // int qftol0E7F( void )
 //
 
-.global C(qftol0E7F)
+.globl C(qftol0E7F)
 
 C(qftol0E7F):
         fnstcw fpucw
@@ -134,7 +134,7 @@ C(qftol0E7F):
 // long Q_ftol( float q )
 //
 
-.global C(Q_ftol)
+.globl C(Q_ftol)
 
 C(Q_ftol):
         flds 4(%esp)
@@ -147,7 +147,7 @@ C(Q_ftol):
 // long qftol0F7F( float q ) - Linux FPU
 //
 
-.global C(Q_ftol0F7F)
+.globl C(Q_ftol0F7F)
 
 C(Q_ftol0F7F):
         fnstcw fpucw
diff --git a/code/unix/qasm.h b/code/unix/qasm.h
index 6c634098..c32aafcb 100644
--- a/code/unix/qasm.h
+++ b/code/unix/qasm.h
@@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include "../qcommon/q_platform.h"
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(MACOS_X)
 #undef ELF
 #endif
 
diff --git a/code/unix/snapvectora.s b/code/unix/snapvectora.s
index 3f9d3300..11294a05 100644
--- a/code/unix/snapvectora.s
+++ b/code/unix/snapvectora.s
@@ -46,7 +46,7 @@ cw037F: .long   0x037F
 .text
 
 // void Sys_SnapVector( float *v )
-.global C(Sys_SnapVector)
+.globl C(Sys_SnapVector)
 C(Sys_SnapVector):
         pushl   %eax
         pushl   %ebp
@@ -74,7 +74,7 @@ C(Sys_SnapVector):
         ret
 
 // void Sys_SnapVectorCW( float *v, unsigned short int cw )
-.global C(Sys_SnapVectorCW)
+.globl C(Sys_SnapVectorCW)
 C(Sys_SnapVectorCW):
         pushl   %eax
         pushl   %ebp