Enhancement: Unix portability improvements

This commit is contained in:
Brad D 2024-09-07 09:19:49 -05:00
parent bbfd0dd909
commit f51454127f
21 changed files with 45 additions and 37 deletions

View file

@ -499,6 +499,12 @@ IF(APPLE)
FIND_LIBRARY(IOKIT NAMES IOKit) FIND_LIBRARY(IOKIT NAMES IOKit)
FIND_LIBRARY(COREAUDIO NAMES CoreAudio) FIND_LIBRARY(COREAUDIO NAMES CoreAudio)
TARGET_LINK_LIBRARIES(qc PUBLIC objc ${OPENGL} ${OPENAL} ${COCOA} ${IOKIT} ${COREAUDIO}) TARGET_LINK_LIBRARIES(qc PUBLIC objc ${OPENGL} ${OPENAL} ${COCOA} ${IOKIT} ${COREAUDIO})
# Included OpenAL library doesn't currently compile or link correctly
# Modern CMake versions include FindOpenAL module, so use it here
ELSEIF(UNIX AND NOT LINUX)
FIND_PACKAGE(OpenAL REQUIRED)
INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(qc PUBLIC ${OPENAL_LIBRARY})
ELSE() ELSE()
TARGET_LINK_LIBRARIES(qc PUBLIC openal) TARGET_LINK_LIBRARIES(qc PUBLIC openal)
ENDIF() ENDIF()

View file

@ -802,7 +802,7 @@ void idTypeInfoGen::CreateTypeInfo( const char *path ) {
idFileList *files; idFileList *files;
idParser src; idParser src;
common->Printf( "Type Info Generator v"TYPE_INFO_GEN_VERSION" (c) 2004 id Software\n" ); common->Printf( "Type Info Generator v" TYPE_INFO_GEN_VERSION " (c) 2004 id Software\n" );
common->Printf( "%s\n", path ); common->Printf( "%s\n", path );
files = fileSystem->ListFilesTree( path, ".cpp" ); files = fileSystem->ListFilesTree( path, ".cpp" );
@ -904,7 +904,7 @@ void idTypeInfoGen::WriteTypeInfo( const char *fileName ) const {
"/*\n" "/*\n"
"===================================================================================\n" "===================================================================================\n"
"\n" "\n"
"\tThis file has been generated with the Type Info Generator v"TYPE_INFO_GEN_VERSION" (c) 2004 id Software\n" "\tThis file has been generated with the Type Info Generator v" TYPE_INFO_GEN_VERSION " (c) 2004 id Software\n"
"\n" "\n"
"\t%d constants\n" "\t%d constants\n"
"\t%d enums\n" "\t%d enums\n"

View file

@ -2003,7 +2003,7 @@ void idMultiplayerGame::UpdateMainGui( void ) {
mainGui->SetStateString( keyval->GetKey(), keyval->GetValue() ); mainGui->SetStateString( keyval->GetKey(), keyval->GetValue() );
} }
mainGui->StateChanged( gameLocal.time ); mainGui->StateChanged( gameLocal.time );
#if defined( __linux__ ) #if defined( __unix__ )
// replacing the oh-so-useful s_reverse with sound backend prompt // replacing the oh-so-useful s_reverse with sound backend prompt
mainGui->SetStateString( "driver_prompt", "1" ); mainGui->SetStateString( "driver_prompt", "1" );
#else #else

View file

@ -108,7 +108,7 @@ If you have questions concerning this license or the applicable additional terms
// atm, we have no useful way to reconstruct the trace, so let's leave it off // atm, we have no useful way to reconstruct the trace, so let's leave it off
#define ID_BT_STUB #define ID_BT_STUB
#ifndef ID_BT_STUB #ifndef ID_BT_STUB
#if defined( __linux__ ) #if defined( __unix__ ) && !defined(MACOS_X)
#if defined( _DEBUG ) #if defined( _DEBUG )
#define ID_BT_STUB #define ID_BT_STUB
#endif #endif

View file

@ -66,7 +66,7 @@ idCVar com_asyncInput( "com_asyncInput", "0", CVAR_BOOL|CVAR_SYSTEM, "sample inp
#define ASYNCSOUND_INFO "0: mix sound inline, 1: memory mapped async mix, 2: callback mixing, 3: write async mix" #define ASYNCSOUND_INFO "0: mix sound inline, 1: memory mapped async mix, 2: callback mixing, 3: write async mix"
#if defined( MACOS_X ) #if defined( MACOS_X )
idCVar com_asyncSound( "com_asyncSound", "3", CVAR_INTEGER|CVAR_SYSTEM|CVAR_ROM, ASYNCSOUND_INFO ); idCVar com_asyncSound( "com_asyncSound", "3", CVAR_INTEGER|CVAR_SYSTEM|CVAR_ROM, ASYNCSOUND_INFO );
#elif defined( __linux__ ) #elif defined( __unix__ )
idCVar com_asyncSound( "com_asyncSound", "3", CVAR_INTEGER|CVAR_SYSTEM|CVAR_ROM, ASYNCSOUND_INFO ); idCVar com_asyncSound( "com_asyncSound", "3", CVAR_INTEGER|CVAR_SYSTEM|CVAR_ROM, ASYNCSOUND_INFO );
#else #else
idCVar com_asyncSound( "com_asyncSound", "1", CVAR_INTEGER|CVAR_SYSTEM, ASYNCSOUND_INFO, 0, 1 ); idCVar com_asyncSound( "com_asyncSound", "1", CVAR_INTEGER|CVAR_SYSTEM, ASYNCSOUND_INFO, 0, 1 );
@ -2814,7 +2814,7 @@ void idCommonLocal::Init( int argc, const char **argv, const char *cmdline ) {
#endif #endif
// This hint improves relative mouse movement on linux // This hint improves relative mouse movement on linux
#ifdef __LINUX__ #ifdef __unix__
SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1"); SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1");
#endif #endif

View file

@ -474,7 +474,7 @@ void idSessionLocal::SetMainMenuGuiVars( void ) {
//bc //bc
//guiMsg->SetStateString( "visible_hasxp", fileSystem->HasD3XP() ? "1" : "0" ); //guiMsg->SetStateString( "visible_hasxp", fileSystem->HasD3XP() ? "1" : "0" );
#if defined( __linux__ ) #if defined( __unix__ )
guiMainMenu->SetStateString( "driver_prompt", "1" ); guiMainMenu->SetStateString( "driver_prompt", "1" );
#else #else
guiMainMenu->SetStateString( "driver_prompt", "0" ); guiMainMenu->SetStateString( "driver_prompt", "0" );
@ -1358,7 +1358,7 @@ void idSessionLocal::HandleMainMenuCommands( const char *menuCommand ) {
break; break;
} }
} else { } else {
#ifndef __linux__ #ifndef __unix__
// also turn off OpenAL so we fully go back to legacy mixer // also turn off OpenAL so we fully go back to legacy mixer
cvarSystem->SetCVarBool( "s_useOpenAL", false ); cvarSystem->SetCVarBool( "s_useOpenAL", false );
#endif #endif

View file

@ -1485,7 +1485,7 @@ void idMultiplayerGame::UpdateMainGui( void ) {
mainGui->SetStateString( keyval->GetKey(), keyval->GetValue() ); mainGui->SetStateString( keyval->GetKey(), keyval->GetValue() );
} }
mainGui->StateChanged( gameLocal.time ); mainGui->StateChanged( gameLocal.time );
#if defined( __linux__ ) #if defined( __unix__ )
// replacing the oh-so-useful s_reverse with sound backend prompt // replacing the oh-so-useful s_reverse with sound backend prompt
mainGui->SetStateString( "driver_prompt", "1" ); mainGui->SetStateString( "driver_prompt", "1" );
#else #else

View file

@ -29,7 +29,7 @@ If you have questions concerning this license or the applicable additional terms
#include "precompiled.h" #include "precompiled.h"
#pragma hdrstop #pragma hdrstop
#if defined( MACOS_X ) #if defined(__unix__)
#include <signal.h> #include <signal.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
@ -152,7 +152,7 @@ dword PackColor( const idVec4 &color ) {
dz = ColorFloatToByte( color.z ); dz = ColorFloatToByte( color.z );
dw = ColorFloatToByte( color.w ); dw = ColorFloatToByte( color.w );
#if defined(_WIN32) || defined(__linux__) || (defined(MACOS_X) && !defined(__ppc__)) #if defined(_WIN32) || defined(__unix__) || (defined(MACOS_X) && !defined(__ppc__))
return ( dx << 0 ) | ( dy << 8 ) | ( dz << 16 ) | ( dw << 24 ); return ( dx << 0 ) | ( dy << 8 ) | ( dz << 16 ) | ( dw << 24 );
#elif (defined(MACOS_X) && defined(__ppc__)) #elif (defined(MACOS_X) && defined(__ppc__))
return ( dx << 24 ) | ( dy << 16 ) | ( dz << 8 ) | ( dw << 0 ); return ( dx << 24 ) | ( dy << 16 ) | ( dz << 8 ) | ( dw << 0 );
@ -167,7 +167,7 @@ UnpackColor
================ ================
*/ */
void UnpackColor( const dword color, idVec4 &unpackedColor ) { void UnpackColor( const dword color, idVec4 &unpackedColor ) {
#if defined(_WIN32) || defined(__linux__) || (defined(MACOS_X) && !defined(__ppc__)) #if defined(_WIN32) || defined(__unix__) || (defined(MACOS_X) && !defined(__ppc__))
unpackedColor.Set( ( ( color >> 0 ) & 255 ) * ( 1.0f / 255.0f ), unpackedColor.Set( ( ( color >> 0 ) & 255 ) * ( 1.0f / 255.0f ),
( ( color >> 8 ) & 255 ) * ( 1.0f / 255.0f ), ( ( color >> 8 ) & 255 ) * ( 1.0f / 255.0f ),
( ( color >> 16 ) & 255 ) * ( 1.0f / 255.0f ), ( ( color >> 16 ) & 255 ) * ( 1.0f / 255.0f ),
@ -194,7 +194,7 @@ dword PackColor( const idVec3 &color ) {
dy = ColorFloatToByte( color.y ); dy = ColorFloatToByte( color.y );
dz = ColorFloatToByte( color.z ); dz = ColorFloatToByte( color.z );
#if defined(_WIN32) || defined(__linux__) || (defined(MACOS_X) && !defined(__ppc__)) #if defined(_WIN32) || defined(__unix__) || (defined(MACOS_X) && !defined(__ppc__))
return ( dx << 0 ) | ( dy << 8 ) | ( dz << 16 ); return ( dx << 0 ) | ( dy << 8 ) | ( dz << 16 );
#elif (defined(MACOS_X) && defined(__ppc__)) #elif (defined(MACOS_X) && defined(__ppc__))
return ( dy << 16 ) | ( dz << 8 ) | ( dx << 0 ); return ( dy << 16 ) | ( dz << 8 ) | ( dx << 0 );
@ -209,7 +209,7 @@ UnpackColor
================ ================
*/ */
void UnpackColor( const dword color, idVec3 &unpackedColor ) { void UnpackColor( const dword color, idVec3 &unpackedColor ) {
#if defined(_WIN32) || defined(__linux__) || (defined(MACOS_X) && !defined(__ppc__)) #if defined(_WIN32) || defined(__unix__) || (defined(MACOS_X) && !defined(__ppc__))
unpackedColor.Set( ( ( color >> 0 ) & 255 ) * ( 1.0f / 255.0f ), unpackedColor.Set( ( ( color >> 0 ) & 255 ) * ( 1.0f / 255.0f ),
( ( color >> 8 ) & 255 ) * ( 1.0f / 255.0f ), ( ( color >> 8 ) & 255 ) * ( 1.0f / 255.0f ),
( ( color >> 16 ) & 255 ) * ( 1.0f / 255.0f ) ); ( ( color >> 16 ) & 255 ) * ( 1.0f / 255.0f ) );
@ -581,7 +581,7 @@ void AssertFailed( const char *file, int line, const char *expression ) {
#else #else
__asm int 0x03 __asm int 0x03
#endif #endif
#elif defined( __linux__ ) #elif defined( __unix__ )
#ifdef __i386__ #ifdef __i386__
__asm__ __volatile__ ("int $0x03"); __asm__ __volatile__ ("int $0x03");
#else #else

View file

@ -709,9 +709,9 @@ int idParser::ExpandBuiltinDefine( idToken *deftoken, define_t *define, idToken
curtime = ctime(&t); curtime = ctime(&t);
(*token) = "\""; (*token) = "\"";
token->Append( curtime+4 ); token->Append( curtime+4 );
token[7] = '\0'; token[7] = (const idStr) '\0';
token->Append( curtime+20 ); token->Append( curtime+20 );
token[10] = '\0'; token[10] = (const idStr) '\0';
token->Append( "\"" ); token->Append( "\"" );
free(curtime); free(curtime);
token->type = TT_STRING; token->type = TT_STRING;
@ -728,7 +728,7 @@ int idParser::ExpandBuiltinDefine( idToken *deftoken, define_t *define, idToken
curtime = ctime(&t); curtime = ctime(&t);
(*token) = "\""; (*token) = "\"";
token->Append( curtime+11 ); token->Append( curtime+11 );
token[8] = '\0'; token[8] = (const idStr) '\0';
token->Append( "\"" ); token->Append( "\"" );
free(curtime); free(curtime);
token->type = TT_STRING; token->type = TT_STRING;

View file

@ -2044,7 +2044,7 @@ bool idFrustum::ProjectionBounds( const idBounds &bounds, idBounds &projectionBo
return ProjectionBounds( idBox( bounds, vec3_origin, mat3_identity ), projectionBounds ); return ProjectionBounds( idBox( bounds, vec3_origin, mat3_identity ), projectionBounds );
} }
#ifndef __linux__ #ifndef __unix__
/* /*
============ ============

View file

@ -103,11 +103,12 @@ If you have questions concerning this license or the applicable additional terms
#include <typeinfo> #include <typeinfo>
#include <errno.h> #include <errno.h>
#include <math.h> #include <math.h>
#ifdef __linux__ #if defined __APPLE__
#include <unistd.h>
#elif defined __APPLE__
#include <algorithm> #include <algorithm>
using std::min; using std::min;
// This covers Linux and the BSDs
#elif defined __unix__
#include <unistd.h>
#endif #endif
//----------------------------------------------------- //-----------------------------------------------------

View file

@ -361,7 +361,7 @@ void idTextureLevel::UpdateTile( int localX, int localY, int globalX, int global
if ( idMegaTexture::r_showMegaTextureLabels.GetBool() ) { if ( idMegaTexture::r_showMegaTextureLabels.GetBool() ) {
// put a color marker in it // put a color marker in it
byte color[4] = { 255 * localX / TILE_PER_LEVEL, 255 * localY / TILE_PER_LEVEL, 0, 0 }; byte color[4] = { (byte)(255 * localX / TILE_PER_LEVEL), (byte)(255 * localY / TILE_PER_LEVEL), 0, 0 };
for ( int x = 0 ; x < 8 ; x++ ) { for ( int x = 0 ; x < 8 ; x++ ) {
for ( int y = 0 ; y < 8 ; y++ ) { for ( int y = 0 ; y < 8 ; y++ ) {
*(int *)&data[ ( ( y + TILE_SIZE/2 - 4 ) * TILE_SIZE + x + TILE_SIZE/2 - 4 ) * 4 ] = *(int *)color; *(int *)&data[ ( ( y + TILE_SIZE/2 - 4 ) * TILE_SIZE + x + TILE_SIZE/2 - 4 ) * 4 ] = *(int *)color;

View file

@ -20,8 +20,8 @@
#include "jversion.h" #include "jversion.h"
#include "jerror.h" #include "jerror.h"
extern jpg_Error( const char *fmt, ... ); extern void jpg_Error( const char *fmt, ... );
extern jpg_Printf( const char *fmt, ... ); extern void jpg_Printf( const char *fmt, ... );
#ifndef EXIT_FAILURE /* define exit() codes if not provided */ #ifndef EXIT_FAILURE /* define exit() codes if not provided */
#define EXIT_FAILURE 1 #define EXIT_FAILURE 1

View file

@ -42,7 +42,7 @@ If you have questions concerning this license or the applicable additional terms
#define GL_GLEXT_LEGACY #define GL_GLEXT_LEGACY
#include <OpenGL/gl.h> #include <OpenGL/gl.h>
#elif defined( __linux__ ) #elif defined( __unix__ )
// using our local glext.h // using our local glext.h
// http://oss.sgi.com/projects/ogl-sample/ABI/ // http://oss.sgi.com/projects/ogl-sample/ABI/
@ -572,7 +572,7 @@ extern BOOL ( WINAPI * qwglSwapLayerBuffers)(HDC, UINT);
#endif // _WIN32 #endif // _WIN32
#if defined( __linux__ ) #if defined( __unix__ )
//GLX Functions //GLX Functions
extern XVisualInfo * (*qglXChooseVisual)( Display *dpy, int screen, int *attribList ); extern XVisualInfo * (*qglXChooseVisual)( Display *dpy, int screen, int *attribList );

View file

@ -366,7 +366,8 @@ void idSoundSystemLocal::Init() {
soundCache = new idSoundCache(); soundCache = new idSoundCache();
} }
#if defined(__linux__) || defined(__APPLE__) // Changed this since __unix__ covers Mac OSX, Linux and the BSDs
#if defined(__unix__)
idSoundSystemLocal::s_useOpenAL.SetBool( true ); idSoundSystemLocal::s_useOpenAL.SetBool( true );
#endif #endif

View file

@ -36,7 +36,7 @@ If you have questions concerning this license or the applicable additional terms
#include "../renderer/tr_local.h" #include "../renderer/tr_local.h"
#if !defined(ID_GL_HARDLINK) && defined(__linux__) #if !defined(ID_GL_HARDLINK) && defined(__unix__)
#include "linux/local.h" #include "linux/local.h"
#endif #endif
@ -68,7 +68,7 @@ GLimp_Init
bool GLimp_Init(glimpParms_t parms) { bool GLimp_Init(glimpParms_t parms) {
common->Printf("Initializing OpenGL subsystem\n"); common->Printf("Initializing OpenGL subsystem\n");
#if !defined(ID_GL_HARDLINK) && defined(__linux__) #if !defined(ID_GL_HARDLINK) && defined(__unix__)
if ( !GLimp_dlopen() ) { if ( !GLimp_dlopen() ) {
return false; return false;
} }
@ -184,7 +184,7 @@ bool GLimp_Init(glimpParms_t parms) {
parms.width, parms.height, flags); parms.width, parms.height, flags);
// set the icon for linux. // set the icon for linux.
#ifdef __linux__ #ifdef __unix__
SDL_Surface* iconSurface = SDL_LoadBMP("Icon.bmp"); SDL_Surface* iconSurface = SDL_LoadBMP("Icon.bmp");
if (iconSurface) if (iconSurface)
{ {

View file

@ -125,10 +125,10 @@ void idSysLocal::DLL_Unload( void* dllHandle ) {
void idSysLocal::DLL_GetFileName( const char *baseName, char *dllName, int maxLength ) { void idSysLocal::DLL_GetFileName( const char *baseName, char *dllName, int maxLength ) {
#ifdef _WIN32 #ifdef _WIN32
idStr::snPrintf( dllName, maxLength, "%s" CPUSTRING ".dll", baseName ); idStr::snPrintf( dllName, maxLength, "%s" CPUSTRING ".dll", baseName );
#elif defined( __linux__ )
idStr::snPrintf( dllName, maxLength, "%s" CPUSTRING ".so", baseName );
#elif defined( MACOS_X ) #elif defined( MACOS_X )
idStr::snPrintf( dllName, maxLength, "%s" ".dylib", baseName ); idStr::snPrintf( dllName, maxLength, "%s" ".dylib", baseName );
#elif defined( __unix__ )
idStr::snPrintf( dllName, maxLength, "%s" CPUSTRING ".so", baseName );
#else #else
#error OS define is required #error OS define is required
#endif #endif

View file

@ -133,7 +133,7 @@ If you have questions concerning this license or the applicable additional terms
// Linux // Linux
#ifdef __linux__ #ifdef __unix__
#ifdef __i386__ #ifdef __i386__
#define BUILD_STRING "linux-x86" #define BUILD_STRING "linux-x86"

View file

@ -1871,7 +1871,7 @@ static void APIENTRY logViewport(GLint x, GLint y, GLsizei width, GLsizei height
} }
#ifdef __linux__ #ifdef __unix__
static XVisualInfo * APIENTRY logChooseVisual(Display *dpy, int screen, int *attribList) { static XVisualInfo * APIENTRY logChooseVisual(Display *dpy, int screen, int *attribList) {
// unknown type: "Display *" name: "dpy" // unknown type: "Display *" name: "dpy"

View file

@ -1386,7 +1386,7 @@ EXCEPTION_DISPOSITION __cdecl _except_handler( struct _EXCEPTION_RECORD *Excepti
#if defined(MACOS_X) #if defined(MACOS_X)
#define UMP_SKU "OSX" #define UMP_SKU "OSX"
#elif defined( __linux__ ) #elif defined( __unix__ )
#define UMP_SKU "Linux" #define UMP_SKU "Linux"
#else #else
#define UMP_SKU "Win32" #define UMP_SKU "Win32"

View file

@ -181,7 +181,7 @@ static void LinkEdge( optEdge_t *e ) {
e->v2->edges = e; e->v2->edges = e;
} }
#ifdef __linux__ #ifdef __unix__
optVertex_t *FindOptVertex( idDrawVert *v, optimizeGroup_t *opt ); optVertex_t *FindOptVertex( idDrawVert *v, optimizeGroup_t *opt );