diff options
Diffstat (limited to 'code')
-rw-r--r-- | code/qcommon/common.c | 4 | ||||
-rw-r--r-- | code/qcommon/q_platform.h | 104 | ||||
-rw-r--r-- | code/unix/unix_main.c | 92 |
3 files changed, 69 insertions, 131 deletions
diff --git a/code/qcommon/common.c b/code/qcommon/common.c index 2386098..fac8cba 100644 --- a/code/qcommon/common.c +++ b/code/qcommon/common.c @@ -2348,7 +2348,7 @@ Com_Init 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 @@ void Com_Init( char *commandLine ) { 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(); diff --git a/code/qcommon/q_platform.h b/code/qcommon/q_platform.h index cf8a031..3339394 100644 --- a/code/qcommon/q_platform.h +++ b/code/qcommon/q_platform.h @@ -71,33 +71,31 @@ float FloatSwap (const float *f); #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" -#endif +#error "Unsupported architecture" #endif + #elif defined __MINGW32__ -#ifdef NDEBUG +#define OS_STRING "win_mingw" + #ifdef __i386__ -#define CPUSTRING "mingw-x86" -#endif +#define ARCH_STRING "x86" #else -#ifdef __i386__ -#define CPUSTRING "mingw-x86-debug" -#endif +#error "Unsupported architecture" #endif + +#else +#error "Unsupported compiler" #endif + #define ID_INLINE __inline static ID_INLINE short BigShort( short l) { return ShortSwap(l); } @@ -120,12 +118,14 @@ static ID_INLINE float BigFloat(const float l) { return FloatSwap(&l); } #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 @@ static ID_INLINE float LittleFloat(const float l) { return FloatSwap(&l); } #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 @@ static ID_INLINE float LittleFloat(const float l) { return FloatSwap(&l); } #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 @@ ID_INLINE static float LittleFloat(const float l) { return FloatSwap(&l); } #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 @@ static float LittleFloat(const float l) { return FloatSwap(&l); } #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 @@ ID_INLINE static float BigFloat(const float l) { return FloatSwap(&l); } #define ID_INLINE -#define CPUSTRING "q3vm" +#define OS_STRING "q3vm" +#define ARCH_STRING "bytecode" #define PATH_SEP '/' @@ -340,8 +360,8 @@ ID_INLINE static float BigFloat(const float l) { return FloatSwap(&l); } //=========================================================================== //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 @@ ID_INLINE static float BigFloat(const float l) { return FloatSwap(&l); } #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 diff --git a/code/unix/unix_main.c b/code/unix/unix_main.c index 7ee5620..050029e 100644 --- a/code/unix/unix_main.c +++ b/code/unix/unix_main.c @@ -353,65 +353,7 @@ void Sys_Init(void) { 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 - -#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( "arch", OS_STRING " " ARCH_STRING ); Cvar_Set( "username", Sys_GetCurrentUser() ); @@ -779,37 +721,7 @@ void *Sys_LoadDll( const char *name, char *fqpath , 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(); |