r273 - in trunk/code: qcommon unix

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Nov 4 19:29:41 EST 2005


Author: tma
Date: 2005-11-04 19:29:40 -0500 (Fri, 04 Nov 2005)
New Revision: 273

Modified:
   trunk/code/qcommon/common.c
   trunk/code/qcommon/q_platform.h
   trunk/code/unix/unix_main.c
Log:
* Centralise architecture defines in q_platform.h


Modified: trunk/code/qcommon/common.c
===================================================================
--- trunk/code/qcommon/common.c	2005-11-05 00:00:47 UTC (rev 272)
+++ trunk/code/qcommon/common.c	2005-11-05 00:29:40 UTC (rev 273)
@@ -2348,7 +2348,7 @@
 void Com_Init( char *commandLine ) {
 	char	*s;
 
-	Com_Printf( "%s %s %s\n", Q3_VERSION, CPUSTRING, __DATE__ );
+	Com_Printf( "%s %s %s\n", Q3_VERSION, PLATFORM_STRING, __DATE__ );
 
 	if ( setjmp (abortframe) ) {
 		Sys_Error ("Error during initialization");
@@ -2455,7 +2455,7 @@
 	Cmd_AddCommand ("changeVectors", MSG_ReportChangeVectors_f );
 	Cmd_AddCommand ("writeconfig", Com_WriteConfig_f );
 
-	s = va("%s %s %s", Q3_VERSION, CPUSTRING, __DATE__ );
+	s = va("%s %s %s", Q3_VERSION, PLATFORM_STRING, __DATE__ );
 	com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO );
 
 	Sys_Init();

Modified: trunk/code/qcommon/q_platform.h
===================================================================
--- trunk/code/qcommon/q_platform.h	2005-11-05 00:00:47 UTC (rev 272)
+++ trunk/code/qcommon/q_platform.h	2005-11-05 00:29:40 UTC (rev 273)
@@ -71,33 +71,31 @@
 #undef QDECL
 #define QDECL __cdecl
 
-// buildstring will be incorporated into the version string
 #ifdef _MSC_VER
-#ifdef NDEBUG
+#define OS_STRING "win_msvc"
+
 #ifdef _M_IX86
-#define CPUSTRING "win-x86"
+#define ARCH_STRING "x86"
 #elif defined _M_ALPHA
-#define CPUSTRING "win-AXP"
-#endif
+#define ARCH_STRING "AXP"
 #else
-#ifdef _M_IX86
-#define CPUSTRING "win-x86-debug"
-#elif defined _M_ALPHA
-#define CPUSTRING "win-AXP-debug"
+#error "Unsupported architecture"
 #endif
-#endif
+
 #elif defined __MINGW32__
-#ifdef NDEBUG
+#define OS_STRING "win_mingw"
+
 #ifdef __i386__
-#define CPUSTRING "mingw-x86"
+#define ARCH_STRING "x86"
+#else
+#error "Unsupported architecture"
 #endif
+
 #else
-#ifdef __i386__
-#define CPUSTRING "mingw-x86-debug"
+#error "Unsupported compiler"
 #endif
-#endif
-#endif
 
+
 #define ID_INLINE __inline
 
 static ID_INLINE short BigShort( short l) { return ShortSwap(l); }
@@ -120,12 +118,14 @@
 #define stricmp strcasecmp
 #define ID_INLINE inline
 
+#define OS_STRING "macosx"
+
 #ifdef __ppc__
-#define CPUSTRING "MacOSX-ppc"
+#define ARCH_STRING "ppc"
 #elif defined __i386__
-#define CPUSTRING "MacOSX-i386"
+#define ARCH_STRING "i386"
 #else
-#define CPUSTRING "MacOSX-other"
+#error "Unsupported architecture"
 #endif
 
 #define PATH_SEP '/'
@@ -174,7 +174,8 @@
 #include <MacTypes.h>
 #define ID_INLINE inline
 
-#define CPUSTRING "MacOS-PPC"
+#define OS_STRING "macos"
+#define ARCH_STRING "ppc"
 
 #define PATH_SEP ':'
 
@@ -200,24 +201,38 @@
 
 #define ID_INLINE inline
 
-#ifdef __i386__
-#define CPUSTRING "linux-i386"
-#elif defined __axp__
-#define CPUSTRING "linux-alpha"
+#define OS_STRING "linux"
+
+#if defined __i386__
+#define ARCH_STRING "i386"
 #elif defined __x86_64__
-#define CPUSTRING "linux-x86_64"
+#define ARCH_STRING "x86_64"
 #elif defined __powerpc64__
-#define CPUSTRING "linux-ppc64"
+#define ARCH_STRING "ppc64"
 #elif defined __powerpc__
-#define CPUSTRING "linux-ppc"
+#define ARCH_STRING "ppc"
 #elif defined __s390__
-#define CPUSTRING "linux-s390"
+#define ARCH_STRING "s390"
 #elif defined __s390x__
-#define CPUSTRING "linux-s390x"
+#define ARCH_STRING "s390x"
 #elif defined __ia64__
-#define CPUSTRING "linux-ia64"
+#define ARCH_STRING "ia64"
+#elif defined __alpha__
+#define ARCH_STRING "alpha"
+#elif defined __sparc__
+#define ARCH_STRING "sparc"
+#elif defined __arm__
+#define ARCH_STRING "arm"
+#elif defined __cris__
+#define ARCH_STRING "cris"
+#elif defined __hppa__
+#define ARCH_STRING "hppa"
+#elif defined __mips__
+#define ARCH_STRING "mips"
+#elif defined __sh__
+#define ARCH_STRING "sh"
 #else
-#define CPUSTRING "linux-other"
+#error "Unsupported architecture"
 #endif
 
 #define PATH_SEP '/'
@@ -248,12 +263,14 @@
 
 #define ID_INLINE inline
 
+#define OS_STRING "freebsd"
+
 #ifdef __i386__
-#define CPUSTRING "freebsd-i386"
+#define ARCH_STRING "i386"
 #elif defined __axp__
-#define CPUSTRING "freebsd-alpha"
+#define ARCH_STRING "alpha"
 #else
-#define CPUSTRING "freebsd-other"
+#error "Unsupported architecture"
 #endif
 
 #define PATH_SEP '/'
@@ -288,10 +305,12 @@
 
 #define ID_INLINE inline
 
+#define OS_STRING "solaris"
+
 #ifdef __i386__
-#define CPUSTRING "Solaris-i386"
+#define ARCH_STRING "i386"
 #elif defined __sparc
-#define CPUSTRING "Solaris-sparc"
+#define ARCH_STRING "sparc"
 #endif
 
 #define PATH_SEP '/'
@@ -324,7 +343,8 @@
 
 #define ID_INLINE
 
-#define CPUSTRING "q3vm"
+#define OS_STRING "q3vm"
+#define ARCH_STRING "bytecode"
 
 #define PATH_SEP '/'
 
@@ -340,8 +360,8 @@
 //===========================================================================
 
 //catch missing defines in above blocks
-#ifndef CPUSTRING
-#error "CPUSTRING not defined"
+#if !defined( OS_STRING ) || !defined( ARCH_STRING )
+#error "OS_STRING or ARCH_STRING not defined"
 #endif
 
 #ifndef ID_INLINE
@@ -356,6 +376,12 @@
 #error "Endianness not defined"
 #endif
 
+#ifdef NDEBUG
+#define PLATFORM_STRING OS_STRING "-" ARCH_STRING
+#else
+#define PLATFORM_STRING OS_STRING "-" ARCH_STRING "-debug"
 #endif
 
 #endif
+
+#endif

Modified: trunk/code/unix/unix_main.c
===================================================================
--- trunk/code/unix/unix_main.c	2005-11-05 00:00:47 UTC (rev 272)
+++ trunk/code/unix/unix_main.c	2005-11-05 00:29:40 UTC (rev 273)
@@ -353,66 +353,8 @@
 {
   Cmd_AddCommand ("in_restart", Sys_In_Restart_f);
 
-#if defined __linux__
-#  if defined __i386__
-  Cvar_Set( "arch", "linux i386" );
-#  elif defined __x86_64__
-  Cvar_Set( "arch", "linux x86_64" );
-#  elif defined __powerpc64__
-  Cvar_Set( "arch", "linux ppc64" );
-#  elif defined __powerpc__
-  Cvar_Set( "arch", "linux ppc" );
-#  elif defined __s390__
-  Cvar_Set( "arch", "linux s390" );
-#  elif defined __s390x__
-  Cvar_Set( "arch", "linux s390x" );
-#  elif defined __ia64__
-  Cvar_Set( "arch", "linux ia64" );
-#  elif defined __alpha__
-  Cvar_Set( "arch", "linux alpha" );
-#  elif defined __sparc__
-  Cvar_Set( "arch", "linux sparc" );
-#  elif defined __arm__
-  Cvar_Set( "arch", "linux arm" );
-#  elif defined __cris__
-  Cvar_Set( "arch", "linux cris" );
-#  elif defined __hppa__
-  Cvar_Set( "arch", "linux hppa" );
-#  elif defined __mips__
-  Cvar_Set( "arch", "linux mips" );
-#  elif defined __sh__
-  Cvar_Set( "arch", "linux sh" );
-# else
-# error unsupported architecture
-#endif
+  Cvar_Set( "arch", OS_STRING " " ARCH_STRING );
 
-#elif defined __FreeBSD__
-
-#if defined __i386__ // FreeBSD
-  Cvar_Set( "arch", "freebsd i386" );
-#elif defined __alpha__
-  Cvar_Set( "arch", "freebsd alpha" );
-#else
-  Cvar_Set( "arch", "freebsd unknown" );
-#endif
-#elif defined(__sun)
-#if defined __i386__
-  Cvar_Set( "arch", "solaris x86" );
-#elif defined __sparc__
-  Cvar_Set( "arch", "solaris sparc" );
-#else
-  Cvar_Set( "arch", "solaris unknown" );
-#endif
-#elif defined __sgi__
-#if defined __mips__
-  Cvar_Set( "arch", "sgi mips" );
-#else
-  Cvar_Set( "arch", "sgi unknown" );
-#endif
-#else
-  Cvar_Set( "arch", "unknown" );
-#endif
-
   Cvar_Set( "username", Sys_GetCurrentUser() );
 
   //IN_Init();   // rcg08312005 moved into glimp.
@@ -779,37 +721,7 @@
   assert( name );
 
   getcwd(curpath, sizeof(curpath));
-#if defined __i386__
-  snprintf (fname, sizeof(fname), "%si386.so", name);
-#elif defined __x86_64__
-  snprintf (fname, sizeof(fname), "%sx86_64.so", name);
-#elif defined __powerpc64__
-  snprintf (fname, sizeof(fname), "%sppc64.so", name);
-#elif defined __powerpc__   //rcg010207 - PPC support.
-  snprintf (fname, sizeof(fname), "%sppc.so", name);
-#elif defined __s390__
-  snprintf (fname, sizeof(fname), "%ss390.so", name);
-#elif defined __s390x__
-  snprintf (fname, sizeof(fname), "%ss390x.so", name);
-#elif defined __ia64__
-  snprintf (fname, sizeof(fname), "%sia64.so", name);
-#elif defined __alpha__
-  snprintf (fname, sizeof(fname), "%saxp.so", name);
-#elif defined __mips__
-  snprintf (fname, sizeof(fname), "%smips.so", name);
-#elif defined __arm__
-  snprintf (fname, sizeof(fname), "%sarm.so", name);
-#elif defined __cris__
-  snprintf (fname, sizeof(fname), "%scris.so", name);
-#elif defined __hppa__
-  snprintf (fname, sizeof(fname), "%shppa.so", name);
-#elif defined __sh__
-  snprintf (fname, sizeof(fname), "%ssh.so", name);
-#elif defined __sparc__
-  snprintf (fname, sizeof(fname), "%ssparc.so", name);
-#else
-#error Unknown arch
-#endif
+  snprintf (fname, sizeof(fname), "%s" ARCH_STRING ".so", name);
 
   // TODO: use fs_searchpaths from files.c
   pwdpath = Sys_Cwd();




More information about the quake3-commits mailing list