Because we only ever call Pos_ReadDirect (and through that, DataRead<T>)

from JIT generated code, the compiler may not get the heads-up to properly
prepare for run-time instantiation of those template functions.

Explicitly instantiating Pos_ReadDirect gets around that issue.

Also force DataRead* inline as gcc didn't always do that itself when the
DataRead functions in turn were called from (other) template functions.

I am far from a C++ language lawyer, so I cannot speak learnedly about the
correctness of this solution, but it works.

Dolphin.app built on OS X 10.6 now actually works on 10.5 as well.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5901 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang 2010-07-18 05:31:51 +00:00
parent 2c419382c9
commit faf586e8f1
4 changed files with 40 additions and 35 deletions

View File

@ -264,9 +264,9 @@ if sys.platform == 'darwin':
env['FRAMEWORKS'] += ['AppKit', 'CoreFoundation', 'CoreServices']
env['FRAMEWORKS'] += ['AudioUnit', 'CoreAudio']
env['FRAMEWORKS'] += ['IOBluetooth', 'IOKit', 'OpenGL']
env['LIBS'] += ['gcc_s.10.5', 'iconv']
env['LIBS'] += ['iconv']
env['LINKFLAGS'] += ['-arch', 'x86_64', '-arch', 'i386']
# XXX env['LINKFLAGS'] += ['-mmacosx-version-min=10.5']
env['LINKFLAGS'] += ['-mmacosx-version-min=10.5']
env['LINKFLAGS'] += ['-Z', '-L/Developer/SDKs/MacOSX10.5.sdk/usr/lib',
'-F/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks',
'-F/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks']
@ -287,6 +287,8 @@ if sys.platform == 'darwin':
env['FRAMEWORKS'].remove('AudioToolbox')
if env['FRAMEWORKS'].count('Carbon'):
env['FRAMEWORKS'].remove('Carbon')
if env['FRAMEWORKS'].count('System'):
env['FRAMEWORKS'].remove('System')
if env['FRAMEWORKS'].count('QuickTime'):
env['FRAMEWORKS'].remove('QuickTime')
env['CPPPATH'] += ['#Externals']

View File

@ -11,7 +11,7 @@ files = [
]
libs = [
'core', 'lzo2', 'discio', 'bdisasm', 'videocommon',
'core', 'lzo2', 'discio', 'bdisasm',
'inputcommon', 'common', 'lua', 'z', 'sfml-network',
]
@ -45,10 +45,6 @@ if wxenv['HAVE_WX']:
'NetWindow.cpp',
]
CPPDEFINES = [
'wxNEEDS_CHARPP',
],
libs = [ 'debwx', 'debugger_ui_util', 'inputuicommon'] + libs
else:
files+= [

View File

@ -20,61 +20,59 @@
extern u8* g_pVideoData;
inline void DataSkip(u32 skip)
__forceinline void DataSkip(u32 skip)
{
g_pVideoData += skip;
}
inline u8 DataPeek8(int _uOffset)
__forceinline u8 DataPeek8(int _uOffset)
{
return g_pVideoData[_uOffset];
}
inline u16 DataPeek16(int _uOffset)
__forceinline u16 DataPeek16(int _uOffset)
{
return Common::swap16(*(u16*)&g_pVideoData[_uOffset]);
return Common::swap16(*(u16*)&g_pVideoData[_uOffset]);
}
inline u32 DataPeek32(int _uOffset)
__forceinline u32 DataPeek32(int _uOffset)
{
return Common::swap32(*(u32*)&g_pVideoData[_uOffset]);
return Common::swap32(*(u32*)&g_pVideoData[_uOffset]);
}
inline u8 DataReadU8()
__forceinline u8 DataReadU8()
{
return *g_pVideoData++;
}
inline s8 DataReadS8()
__forceinline s8 DataReadS8()
{
return (s8)(*g_pVideoData++);
}
inline u16 DataReadU16()
__forceinline u16 DataReadU16()
{
u16 tmp = Common::swap16(*(u16*)g_pVideoData);
u16 tmp = Common::swap16(*(u16*)g_pVideoData);
g_pVideoData += 2;
return tmp;
}
inline u32 DataReadU32()
__forceinline u32 DataReadU32()
{
u32 tmp = Common::swap32(*(u32*)g_pVideoData);
g_pVideoData += 4;
return tmp;
}
inline u32 DataReadU32Unswapped()
__forceinline u32 DataReadU32Unswapped()
{
u32 tmp = *(u32*)g_pVideoData;
g_pVideoData += 4;
return tmp;
}
// These are not used yet. If they don't build under Linux, delete them and let me know. -ector
template<class T>
inline T DataRead()
__forceinline T DataRead()
{
T tmp = *(T*)g_pVideoData;
g_pVideoData += sizeof(T);
@ -82,48 +80,47 @@ inline T DataRead()
}
template <>
inline u16 DataRead()
__forceinline u16 DataRead()
{
u16 tmp = Common::swap16(*(u16*)g_pVideoData);
u16 tmp = Common::swap16(*(u16*)g_pVideoData);
g_pVideoData += 2;
return tmp;
}
template <>
inline s16 DataRead()
__forceinline s16 DataRead()
{
s16 tmp = (s16)Common::swap16(*(u16*)g_pVideoData);
s16 tmp = (s16)Common::swap16(*(u16*)g_pVideoData);
g_pVideoData += 2;
return tmp;
}
template <>
inline u32 DataRead()
__forceinline u32 DataRead()
{
u32 tmp = (u32)Common::swap32(*(u32*)g_pVideoData);
u32 tmp = (u32)Common::swap32(*(u32*)g_pVideoData);
g_pVideoData += 4;
return tmp;
}
template <>
inline s32 DataRead()
__forceinline s32 DataRead()
{
s32 tmp = (s32)Common::swap32(*(u32*)g_pVideoData);
s32 tmp = (s32)Common::swap32(*(u32*)g_pVideoData);
g_pVideoData += 4;
return tmp;
}
inline float DataReadF32()
__forceinline float DataReadF32()
{
union {u32 i; float f;} temp;
union {u32 i; float f;} temp;
temp.i = Common::swap32(*(u32*)g_pVideoData);
g_pVideoData += 4;
float tmp = temp.f;
return tmp;
}
inline u8* DataGetPosition()
__forceinline u8* DataGetPosition()
{
return g_pVideoData;
}

View File

@ -92,11 +92,21 @@ void Pos_ReadDirect()
VertexManager::s_pCurBufferPointer += 12;
}
// Explicitly instantiate these functions to decrease the possibility of
// symbol binding problems when (only) calling them from JIT compiled code.
template void Pos_ReadDirect<u8, true>();
template void Pos_ReadDirect<s8, true>();
template void Pos_ReadDirect<u16, true>();
template void Pos_ReadDirect<s16, true>();
template void Pos_ReadDirect<u8, false>();
template void Pos_ReadDirect<s8, false>();
template void Pos_ReadDirect<u16, false>();
template void Pos_ReadDirect<s16, false>();
void LOADERDECL Pos_ReadDirect_UByte3() { Pos_ReadDirect<u8, true>(); }
void LOADERDECL Pos_ReadDirect_Byte3() { Pos_ReadDirect<s8, true>(); }
void LOADERDECL Pos_ReadDirect_UShort3() { Pos_ReadDirect<u16, true>(); }
void LOADERDECL Pos_ReadDirect_Short3() { Pos_ReadDirect<s16, true>(); }
void LOADERDECL Pos_ReadDirect_UByte2() { Pos_ReadDirect<u8, false>(); }
void LOADERDECL Pos_ReadDirect_Byte2() { Pos_ReadDirect<s8, false>(); }
void LOADERDECL Pos_ReadDirect_UShort2() { Pos_ReadDirect<u16, false>(); }