mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-01 23:20:44 +00:00
Added some macro defines for Linux.
This commit is contained in:
parent
afaf66ef40
commit
37a6018233
9 changed files with 97 additions and 21 deletions
5
neo/cmake-eclipse-linux-debug.sh
Executable file
5
neo/cmake-eclipse-linux-debug.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
cd ..
|
||||
rm -rf build
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -G "Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ../neo
|
|
@ -431,7 +431,10 @@ ID_INLINE void idBlockAlloc<_type_, _blockSize_, memTag>::AllocNewBlock()
|
|||
{
|
||||
block->elements[i].next = free;
|
||||
free = &block->elements[i];
|
||||
assert( ( ( ( UINT_PTR )free ) & ( BLOCK_ALLOC_ALIGNMENT - 1 ) ) == 0 );
|
||||
|
||||
// RB: changed UINT_PTR to uintptr_t
|
||||
assert( ( ( ( uintptr_t )free ) & ( BLOCK_ALLOC_ALIGNMENT - 1 ) ) == 0 );
|
||||
// RB end
|
||||
}
|
||||
total += _blockSize_;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,6 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#endif
|
||||
// RB end
|
||||
|
||||
#include <basetsd.h> // for UINT_PTR
|
||||
#ifdef _MSC_VER
|
||||
#include <intrin.h>
|
||||
#pragma warning( disable : 4100 ) // unreferenced formal parameter
|
||||
|
|
|
@ -774,7 +774,9 @@ ID_INLINE void idMatX::SetData( int rows, int columns, float* data )
|
|||
{
|
||||
Mem_Free16( mat );
|
||||
}
|
||||
assert( ( ( ( UINT_PTR ) data ) & 15 ) == 0 ); // data must be 16 byte aligned
|
||||
// RB: changed UINT_PTR to uintptr_t
|
||||
assert( ( ( ( uintptr_t ) data ) & 15 ) == 0 ); // data must be 16 byte aligned
|
||||
// RB end
|
||||
mat = data;
|
||||
alloced = -1;
|
||||
numRows = rows;
|
||||
|
@ -793,7 +795,11 @@ ID_INLINE void idMatX::SetDataCacheLines( int rows, int columns, float* data, bo
|
|||
{
|
||||
Mem_Free( mat );
|
||||
}
|
||||
assert( ( ( ( UINT_PTR ) data ) & 127 ) == 0 ); // data must be 128 byte aligned
|
||||
|
||||
// RB: changed UINT_PTR to uintptr_t
|
||||
assert( ( ( ( uintptr_t ) data ) & 127 ) == 0 ); // data must be 128 byte aligned
|
||||
// RB end
|
||||
|
||||
mat = data;
|
||||
alloced = -1;
|
||||
numRows = rows;
|
||||
|
|
|
@ -55,7 +55,14 @@ bool AssertFailed( const char* file, int line, const char* expression );
|
|||
// We have the code analysis tools on the 360 compiler,
|
||||
// so let it know what our asserts are.
|
||||
// The VS ultimate editions also get it on win32, but not x86
|
||||
|
||||
// RB: __analysis_assume only necessary with MSVC
|
||||
#if defined(_MSC_VER)
|
||||
#define assert( x ) __analysis_assume( x ) ; idassert( x )
|
||||
#else
|
||||
#define assert( x ) idassert( x )
|
||||
#endif
|
||||
// RB end
|
||||
|
||||
#define verify( x ) ( ( x ) ? true : ( AssertFailed( __FILE__, __LINE__, #x ), false ) )
|
||||
|
||||
|
@ -80,14 +87,16 @@ bool AssertFailed( const char* file, int line, const char* expression );
|
|||
|
||||
#define release_assert( x ) idreleaseassert( x )
|
||||
|
||||
#define assert_2_byte_aligned( ptr ) assert( ( ((UINT_PTR)(ptr)) & 1 ) == 0 )
|
||||
#define assert_4_byte_aligned( ptr ) assert( ( ((UINT_PTR)(ptr)) & 3 ) == 0 )
|
||||
#define assert_8_byte_aligned( ptr ) assert( ( ((UINT_PTR)(ptr)) & 7 ) == 0 )
|
||||
#define assert_16_byte_aligned( ptr ) assert( ( ((UINT_PTR)(ptr)) & 15 ) == 0 )
|
||||
#define assert_32_byte_aligned( ptr ) assert( ( ((UINT_PTR)(ptr)) & 31 ) == 0 )
|
||||
#define assert_64_byte_aligned( ptr ) assert( ( ((UINT_PTR)(ptr)) & 63 ) == 0 )
|
||||
#define assert_128_byte_aligned( ptr ) assert( ( ((UINT_PTR)(ptr)) & 127 ) == 0 )
|
||||
#define assert_aligned_to_type_size( ptr ) assert( ( ((UINT_PTR)(ptr)) & ( sizeof( (ptr)[0] ) - 1 ) ) == 0 )
|
||||
// RB: changed UINT_PTR to uintptr_t
|
||||
#define assert_2_byte_aligned( ptr ) assert( ( ((uintptr_t)(ptr)) & 1 ) == 0 )
|
||||
#define assert_4_byte_aligned( ptr ) assert( ( ((uintptr_t)(ptr)) & 3 ) == 0 )
|
||||
#define assert_8_byte_aligned( ptr ) assert( ( ((uintptr_t)(ptr)) & 7 ) == 0 )
|
||||
#define assert_16_byte_aligned( ptr ) assert( ( ((uintptr_t)(ptr)) & 15 ) == 0 )
|
||||
#define assert_32_byte_aligned( ptr ) assert( ( ((uintptr_t)(ptr)) & 31 ) == 0 )
|
||||
#define assert_64_byte_aligned( ptr ) assert( ( ((uintptr_t)(ptr)) & 63 ) == 0 )
|
||||
#define assert_128_byte_aligned( ptr ) assert( ( ((uintptr_t)(ptr)) & 127 ) == 0 )
|
||||
#define assert_aligned_to_type_size( ptr ) assert( ( ((uintptr_t)(ptr)) & ( sizeof( (ptr)[0] ) - 1 ) ) == 0 )
|
||||
// RB end
|
||||
|
||||
#if !defined( __TYPEINFOGEN__ ) && !defined( _lint ) // pcLint has problems with assert_offsetof()
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 2012 Robert Beckebans
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
|
@ -31,11 +32,13 @@ If you have questions concerning this license or the applicable additional terms
|
|||
/*
|
||||
================================================================================================
|
||||
|
||||
PC Windows
|
||||
Non-portable system services.
|
||||
|
||||
================================================================================================
|
||||
*/
|
||||
|
||||
// Win32
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
|
||||
#define CPUSTRING "x86"
|
||||
|
||||
|
@ -99,6 +102,49 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#define WIN32
|
||||
#endif
|
||||
|
||||
|
||||
#elif defined(__linux__)
|
||||
|
||||
#if defined(__i386__)
|
||||
#define CPUSTRING "x86"
|
||||
#elif defined(__x86_64__)
|
||||
#define CPUSTRING "x86_86"
|
||||
#endif
|
||||
|
||||
#define BUILD_STRING "linux-" CPUSTRING
|
||||
#define BUILD_OS_ID 2
|
||||
|
||||
// DG: mingw/GCC (and probably clang) support
|
||||
#define ALIGN16( x ) x __attribute__ ((aligned (16)))
|
||||
// FIXME: change ALIGNTYPE* ?
|
||||
#define ALIGNTYPE16
|
||||
#define ALIGNTYPE128
|
||||
// DG end
|
||||
|
||||
|
||||
#define FORMAT_PRINTF( x )
|
||||
|
||||
#define PATHSEPARATOR_STR "/"
|
||||
#define PATHSEPARATOR_CHAR '/'
|
||||
#define NEWLINE "\n"
|
||||
|
||||
#define ID_INLINE inline
|
||||
|
||||
// DG: this should at least work with GCC/MinGW, probably with clang as well..
|
||||
#define ID_FORCE_INLINE inline // TODO: always_inline?
|
||||
// DG end
|
||||
|
||||
#define ID_INLINE_EXTERN extern inline
|
||||
|
||||
// DG: GCC/MinGW, probably clang
|
||||
#define ID_FORCE_INLINE_EXTERN extern inline // TODO: always_inline ?
|
||||
// DG end
|
||||
|
||||
#define ID_HDRSTOP
|
||||
|
||||
#endif
|
||||
// RB end
|
||||
|
||||
/*
|
||||
================================================================================================
|
||||
|
||||
|
@ -109,8 +155,10 @@ Defines and macros usable in all code
|
|||
|
||||
#define ALIGN( x, a ) ( ( ( x ) + ((a)-1) ) & ~((a)-1) )
|
||||
|
||||
#define _alloca16( x ) ((void *)ALIGN( (UINT_PTR)_alloca( ALIGN( x, 16 ) + 16 ), 16 ) )
|
||||
#define _alloca128( x ) ((void *)ALIGN( (UINT_PTR)_alloca( ALIGN( x, 128 ) + 128 ), 128 ) )
|
||||
// RB: changed UINT_PTR to uintptr_t
|
||||
#define _alloca16( x ) ((void *)ALIGN( (uintptr_t)_alloca( ALIGN( x, 16 ) + 16 ), 16 ) )
|
||||
#define _alloca128( x ) ((void *)ALIGN( (uintptr_t)_alloca( ALIGN( x, 128 ) + 128 ), 128 ) )
|
||||
// RB end
|
||||
|
||||
#define likely( x ) ( x )
|
||||
#define unlikely( x ) ( x )
|
||||
|
|
|
@ -107,11 +107,12 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#pragma warning(disable : 4996) // unsafe string operations
|
||||
#endif // _MSC_VER
|
||||
|
||||
#include <windows.h> // for qgl.h
|
||||
|
||||
#endif // #if defined(_WIN32)
|
||||
// RB end
|
||||
|
||||
#include <malloc.h> // no malloc.h on mac or unix
|
||||
#include <windows.h> // for qgl.h
|
||||
#undef FindText // fix namespace pollution
|
||||
|
||||
|
||||
|
|
|
@ -143,20 +143,22 @@ ID_INLINE_EXTERN int CACHE_LINE_CLEAR_OVERFLOW_COUNT( int size )
|
|||
}
|
||||
|
||||
// if the pointer is not on a cache line boundary this assumes the cache line the pointer starts in was already cleared
|
||||
// RB: changed UINT_PTR to uintptr_t
|
||||
#define CACHE_LINE_CLEAR_BLOCK( ptr, size ) \
|
||||
byte * startPtr = (byte *)( ( ( (UINT_PTR) ( ptr ) ) + CACHE_LINE_SIZE - 1 ) & ~( CACHE_LINE_SIZE - 1 ) ); \
|
||||
byte * endPtr = (byte *)( ( (UINT_PTR) ( ptr ) + ( size ) - 1 ) & ~( CACHE_LINE_SIZE - 1 ) ); \
|
||||
byte * startPtr = (byte *)( ( ( (uintptr_t) ( ptr ) ) + CACHE_LINE_SIZE - 1 ) & ~( CACHE_LINE_SIZE - 1 ) ); \
|
||||
byte * endPtr = (byte *)( ( (uintptr_t) ( ptr ) + ( size ) - 1 ) & ~( CACHE_LINE_SIZE - 1 ) ); \
|
||||
for ( ; startPtr <= endPtr; startPtr += CACHE_LINE_SIZE ) { \
|
||||
ZeroCacheLine( startPtr, 0 ); \
|
||||
}
|
||||
|
||||
#define CACHE_LINE_CLEAR_BLOCK_AND_FLUSH( ptr, size ) \
|
||||
byte * startPtr = (byte *)( ( ( (UINT_PTR) ( ptr ) ) + CACHE_LINE_SIZE - 1 ) & ~( CACHE_LINE_SIZE - 1 ) ); \
|
||||
byte * endPtr = (byte *)( ( (UINT_PTR) ( ptr ) + ( size ) - 1 ) & ~( CACHE_LINE_SIZE - 1 ) ); \
|
||||
byte * startPtr = (byte *)( ( ( (uintptr_t) ( ptr ) ) + CACHE_LINE_SIZE - 1 ) & ~( CACHE_LINE_SIZE - 1 ) ); \
|
||||
byte * endPtr = (byte *)( ( (uintptr_t) ( ptr ) + ( size ) - 1 ) & ~( CACHE_LINE_SIZE - 1 ) ); \
|
||||
for ( ; startPtr <= endPtr; startPtr += CACHE_LINE_SIZE ) { \
|
||||
ZeroCacheLine( startPtr, 0 ); \
|
||||
FlushCacheLine( startPtr, 0 ); \
|
||||
}
|
||||
// RB end
|
||||
|
||||
/*
|
||||
================================================================================================
|
||||
|
|
|
@ -187,7 +187,10 @@ vertCacheHandle_t idVertexCache::ActuallyAlloc( geoBufferSet_t& vcs, const void*
|
|||
return ( vertCacheHandle_t )0;
|
||||
}
|
||||
|
||||
assert( ( ( ( UINT_PTR )( data ) ) & 15 ) == 0 );
|
||||
// RB: changed UINT_PTR to uintptr_t
|
||||
assert( ( ( ( uintptr_t )( data ) ) & 15 ) == 0 );
|
||||
// RB end
|
||||
|
||||
assert( ( bytes & 15 ) == 0 );
|
||||
|
||||
// thread safe interlocked adds
|
||||
|
|
Loading…
Reference in a new issue