File 0003-enable-64bit-build.diff of Package enemy-territory

From f4f288ffe87255bd611c07d4578080360dc47b02 Mon Sep 17 00:00:00 2001
From: Ludwig Nussel <ludwig.nussel@suse.de>
Date: Fri, 13 Aug 2010 14:54:25 +0200
Subject: [PATCH 3/3] enable 64bit build

---
 src/SConscript.core  |   13 +++++++++----
 src/SConstruct       |   15 +++++++++++----
 src/client/snd_mix.c |    2 +-
 src/qcommon/vm.c     |   19 +++++++++++++------
 src/unix/unix_main.c |   14 ++++++++++++++
 5 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/src/SConscript.core b/src/SConscript.core
index 3e09479..abe47d4 100644
--- a/src/SConscript.core
+++ b/src/SConscript.core
@@ -243,7 +243,7 @@ botlib_objs = []
 for i in botlib_list:
 	botlib_objs.append( botlib_env.StaticObject( os.path.join( 'botlib', i ) ) )
 
-if ( g_os == 'Linux' ):
+if ( g_os == 'Linux' and cpu == 'x86'):
 	nasm_env = Environment( tools = [ 'nasm' ] )
 	nasm_env['ASFLAGS'] = '-f elf'
 	snapvector = nasm_env.StaticObject( 'unix/snapvector.asm' )
@@ -251,7 +251,7 @@ if ( g_os == 'Linux' ):
 	# gas assembly, with preprocessing
 	gas_env = Environment( tools = [ 'gcc', 'gas' ] )
 	gas_env.Append( CPPDEFINES = [ 'ELF' ] )
-	gas_env.Append( ASFLAGS = [ '-m32', '-x', 'assembler-with-cpp' ] )
+	gas_env.Append( ASFLAGS = [ '-x', 'assembler-with-cpp' ] )
 	matha = gas_env.StaticObject( 'unix/matha.spp' )
         snd_mixa = gas_env.StaticObject( 'unix/snd_mixa.spp' )
 
@@ -291,7 +291,11 @@ if ( MASTER != '' ):
 
 source_list = server_list + qcommon_list
 if ( g_os == 'Linux' ):
-	source_list += linux_sources + snapvector + matha
+	source_list += linux_sources
+	if cpu == 'x86':
+		source_list += snapvector + matha
+	else:
+		local_env.Append( CPPDEFINES = [ 'NO_VM_COMPILED=1'] )
 elif ( g_os == 'win32' ):
 	source_list += win32_sources
 elif ( g_os == 'Darwin' ):
@@ -313,7 +317,8 @@ if ( local_dedicated == 0 ):
 	source_list += [ 'qcommon/dl_main_curl.c' ]
 	source_list += curl_lib
 	if ( g_os == 'Linux' ):
-		source_list += snd_mixa
+		if cpu == 'x86':
+			source_list += snd_mixa
 		source_list += linux_full_sources
 	if ( g_os == 'win32' ):
 		source_list += win32_full_sources
diff --git a/src/SConstruct b/src/SConstruct
index dc69c93..125676f 100644
--- a/src/SConstruct
+++ b/src/SConstruct
@@ -92,16 +92,20 @@ EnsureSConsVersion( 0, 96 )
 # CPU type
 cpu = commands.getoutput('uname -m')
 dll_cpu = '???' # grmbl, alternative naming for .so
-exp = re.compile('.*i?86.*')
+exp = re.compile('i.86')
 if exp.match(cpu):
 	cpu = 'x86'
 	dll_cpu = 'i386'
+elif cpu == 'x86_64':
+	dll_cpu = 'x86_64'
 else:
 	cpu = commands.getoutput('uname -p')
 	if ( cpu == 'powerpc' ):
 		cpu = 'ppc'
 		dll_cpu = cpu
 	else:
+		print >>sys.stderr, "unkown cpu: ", cpu
+		sys.exit(1)
 		cpu = 'cpu'
 		dll_cpu = cpu
 OS = commands.getoutput( 'uname -s' )
@@ -117,8 +121,8 @@ print 'cpu: ' + cpu
 
 # default settings -------------------------------
 
-CC = 'gcc -m32'
-CXX = 'g++ -m32'
+CC = 'gcc'
+CXX = 'g++'
 JOBS = '1'
 BUILD = 'debug'
 DEDICATED = '2'
@@ -256,7 +260,10 @@ elif ( BUILD == 'release' ):
 		# -fschedule-insns2: implicit at -O3
 		# -funroll-loops ?
 		# -mfpmath=sse -msse ?
-		OPTCPPFLAGS = [ '-O3', '-march=i686', '-Winline', '-ffast-math', '-fomit-frame-pointer', '-finline-functions', '-fschedule-insns2' ]
+		if ( cpu == 'x86'):
+			OPTCPPFLAGS = [ '-O3', '-march=i686', '-Winline', '-ffast-math', '-fomit-frame-pointer', '-finline-functions', '-fschedule-insns2' ]
+		else:
+			OPTCPPFLAGS = [ '-O3', '-Winline', '-ffast-math']
 	elif ( OS == 'Darwin' ):
 		OPTCPPFLAGS = []
 else:
diff --git a/src/client/snd_mix.c b/src/client/snd_mix.c
index d6d1a00..ab4c933 100644
--- a/src/client/snd_mix.c
+++ b/src/client/snd_mix.c
@@ -46,7 +46,7 @@ int     *snd_p;
 int snd_linear_count;
 short   *snd_out;
 
-#ifdef __linux__
+#if defined __linux__ && defined __i386__
 
 // snd_mixa.s
 void S_WriteLinearBlastStereo16( void );
diff --git a/src/qcommon/vm.c b/src/qcommon/vm.c
index ba777fe..3b16af8 100644
--- a/src/qcommon/vm.c
+++ b/src/qcommon/vm.c
@@ -539,13 +539,17 @@ vm_t *VM_Create( const char *module, int ( *systemCalls )(int *),
 	// copy or compile the instructions
 	vm->codeLength = header->codeLength;
 
+#ifdef NO_VM_COMPILED
+	if(interpret >= VMI_COMPILED) {
+		Com_Printf("Architecture doesn't have a bytecode compiler, using interpreter\n");
+		interpret = VMI_BYTECODE;
+	}
+#else
 	if ( interpret >= VMI_COMPILED ) {
 		vm->compiled = qtrue;
 		VM_Compile( vm, header );
-	} else {
-		vm->compiled = qfalse;
-		VM_PrepareInterpreter( vm, header );
 	}
+#endif
 
 	// free the original file
 	FS_FreeFile( header );
@@ -703,10 +707,13 @@ int QDECL VM_Call( vm_t *vm, int callnum, ... ) {
 							( &callnum )[4], ( &callnum )[5], ( &callnum )[6], ( &callnum )[7],
 							( &callnum )[8],  ( &callnum )[9],  ( &callnum )[10],  ( &callnum )[11],  ( &callnum )[12] );
 #endif
-	} else if ( vm->compiled ) {
-		r = VM_CallCompiled( vm, &callnum );
 	} else {
-		r = VM_CallInterpreted( vm, &callnum );
+#ifndef NO_VM_COMPILED
+		if ( vm->compiled ) {
+			r = VM_CallCompiled( vm, &callnum );
+		} else
+#endif
+			r = VM_CallInterpreted( vm, &callnum );
 	}
 
 	if ( oldVM != NULL ) { // bk001220 - assert(currentVM!=NULL) for oldVM==NULL
diff --git a/src/unix/unix_main.c b/src/unix/unix_main.c
index 291b84b..1430e44 100644
--- a/src/unix/unix_main.c
+++ b/src/unix/unix_main.c
@@ -296,6 +296,8 @@ void Sys_Init( void ) {
 #if defined __linux__
 #if defined __i386__
 	Cvar_Set( "arch", "linux i386" );
+#elif defined __x86_64__
+	Cvar_Set( "arch", "linux x86_64" );
 #elif defined __alpha__
 	Cvar_Set( "arch", "linux alpha" );
 #elif defined __sparc__
@@ -701,9 +703,12 @@ qboolean CopyDLLForMod( char **p_fn, const char* gamedir, const char *pwdpath, c
 }
 
 // TTimo - Wolf MP specific, adding .mp. to shared objects
+// XXX: use dll_cpu
 char* Sys_GetDLLName( const char *name ) {
 #if defined __i386__
 	return va( "%s.mp.i386.so", name );
+#elif defined __x86_64__
+	return va( "%s.mp.x86_64.so", name );
 #elif defined __ppc__
 	return va( "%s.mp.ppc.so", name );
 #elif defined __axp__
@@ -1465,3 +1470,12 @@ qboolean Sys_IsNumLockDown( void ) {
 	// Gordon: FIXME for timothee
 	return qfalse;
 }
+
+#ifndef __i386__
+void Sys_SnapVector( float *v )
+{
+	v[0] = rint(v[0]);
+	v[1] = rint(v[1]);
+	v[2] = rint(v[2]);
+}
+#endif
-- 
1.7.1

openSUSE Build Service is sponsored by