From e145f9dd67ffe588c8f36238b1725c7073682219 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Fri, 25 Jun 2010 11:12:24 +0000 Subject: [PATCH] Refactoring: Split FixedPointTypes.h into an h/inl setup. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3302 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/build/Utilities/Utilities.cbp | 1 + common/build/Utilities/utilities.vcproj | 4 + common/include/Utilities/FixedPointTypes.h | 235 ++---------- common/include/Utilities/FixedPointTypes.inl | 240 ++++++++++++ common/include/Utilities/IniInterface.h | 2 +- common/src/Utilities/CMakeLists.txt | 361 ++++++++++--------- common/src/Utilities/IniInterface.cpp | 6 + 7 files changed, 469 insertions(+), 380 deletions(-) create mode 100644 common/include/Utilities/FixedPointTypes.inl diff --git a/common/build/Utilities/Utilities.cbp b/common/build/Utilities/Utilities.cbp index 55fa269945..0e98314365 100644 --- a/common/build/Utilities/Utilities.cbp +++ b/common/build/Utilities/Utilities.cbp @@ -152,6 +152,7 @@ + diff --git a/common/build/Utilities/utilities.vcproj b/common/build/Utilities/utilities.vcproj index 10556538cb..9451b1a18c 100644 --- a/common/build/Utilities/utilities.vcproj +++ b/common/build/Utilities/utilities.vcproj @@ -381,6 +381,10 @@ RelativePath="..\..\include\Utilities\FixedPointTypes.h" > + + diff --git a/common/include/Utilities/FixedPointTypes.h b/common/include/Utilities/FixedPointTypes.h index 54ca61ae9f..71c4519112 100644 --- a/common/include/Utilities/FixedPointTypes.h +++ b/common/include/Utilities/FixedPointTypes.h @@ -18,221 +18,58 @@ #include "Dependencies.h" #include "Exceptions.h" -// Needed for pow(). -#include - template< int Precision > struct FixedInt { s32 Raw; - FixedInt() - { - Raw = 0; - } + FixedInt(); + FixedInt( int signedval ); + FixedInt( double doubval ); + FixedInt( float floval ); - FixedInt( int signedval ) - { - Raw = signedval * Precision; - } + bool operator ==( const FixedInt& right ) const { return Raw == right.Raw; } + bool operator !=( const FixedInt& right ) const { return Raw != right.Raw; } - FixedInt( double doubval ) - { - Raw = (int)(doubval * (double)Precision); - } + bool operator>( const FixedInt& right ) const { return Raw > right.Raw; }; + bool operator>=( const FixedInt& right ) const { return Raw >= right.Raw; }; + bool operator<( const FixedInt& right ) const { return Raw < right.Raw; }; + bool operator<=( const FixedInt& right ) const { return Raw <= right.Raw; }; - FixedInt( float floval ) - { - Raw = (int)(floval * (float)Precision); - } + FixedInt operator+( const FixedInt& right ) const; + FixedInt operator-( const FixedInt& right ) const; + FixedInt& operator+=( const FixedInt& right ); + FixedInt& operator-=( const FixedInt& right ); - bool operator ==( const FixedInt& right ) const - { - return Raw == right.Raw; - } + FixedInt& ConfineTo( const FixedInt& low, const FixedInt& high ); - bool operator !=( const FixedInt& right ) const - { - return Raw != right.Raw; - } + FixedInt operator*( const FixedInt& right ) const; + FixedInt operator/( const FixedInt& right ) const; + FixedInt& operator*=( const FixedInt& right ); + FixedInt& operator/=( const FixedInt& right ); - FixedInt operator+( const FixedInt& right ) const - { - return FixedInt().SetRaw( Raw + right.Raw ); - } + static bool OverflowCheck( int signedval ); + static bool OverflowCheck( double signedval ); - FixedInt operator-( const FixedInt& right ) const - { - return FixedInt().SetRaw( Raw + right.Raw ); - } + int GetWhole() const; + int GetFraction() const; - FixedInt& operator+=( const FixedInt& right ) - { - return SetRaw( Raw + right.Raw ); - } + FixedInt& SetRaw( s32 rawsrc ); + FixedInt& Round(); + FixedInt& SetWhole( s32 wholepart ); + FixedInt& SetFraction( u32 fracpart ); - FixedInt& operator-=( const FixedInt& right ) - { - return SetRaw( Raw + right.Raw ); - } + wxString ToString() const; + wxString ToString( int fracDigits ) const; - bool operator>( const FixedInt& right ) const { return Raw > right.Raw; } - bool operator>=( const FixedInt& right ) const { return Raw >= right.Raw; } - bool operator<( const FixedInt& right ) const { return Raw < right.Raw; } - bool operator<=( const FixedInt& right ) const { return Raw <= right.Raw; } + double ToDouble() const; + float ToFloat() const; + int ToIntTruncated() const; + int ToIntRounded() const; - FixedInt& ConfineTo( const FixedInt& low, const FixedInt& high ) - { - return SetRaw( std::min( std::max( Raw, low.Raw ), high.Raw ) ); - } - - // Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math - // you'll need to use the Raw values directly. - FixedInt operator*( const FixedInt& right ) const - { - s64 mulres = (s64)Raw * right.Raw; - return FixedInt().SetRaw( (s32)(mulres / Precision) ); - } - - // Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math - // you'll need to use the Raw values directly. - FixedInt operator/( const FixedInt& right ) const - { - s64 divres = Raw * Precision; - return FixedInt().SetRaw( (s32)(divres / right.Raw) ); - } - - // Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math - // you'll need to use the Raw values directly. - FixedInt& operator*=( const FixedInt& right ) - { - s64 mulres = (s64)Raw * right.Raw; - return SetRaw( (s32)(mulres / Precision) ); - } - - // Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math - // you'll need to use the Raw values directly. - FixedInt& operator/=( const FixedInt& right ) - { - s64 divres = Raw * Precision; - return SetRaw( (s32)(divres / right.Raw) ); - } - - // returns TRUE if the value overflows the legal integer range of this container. - static bool OverflowCheck( int signedval ) - { - return ( signedval >= (INT_MAX / Precision) ); - } - - // returns TRUE if the value overflows the legal integer range of this container. - static bool OverflowCheck( double signedval ) - { - return ( signedval >= (INT_MAX / Precision) ); - } - - int GetWhole() const { return Raw / Precision; } - int GetFraction() const { return Raw % Precision; } - - FixedInt& SetRaw( s32 rawsrc ) - { - Raw = rawsrc; - return *this; - } - - FixedInt& Round() - { - Raw = ToIntRounded(); - return *this; - } - - FixedInt& SetWhole( s32 wholepart ) - { - pxAssert( wholepart < (INT_MAX / Precision) ); - Raw = GetFraction() + (wholepart * Precision); - return *this; - } - - FixedInt& SetFraction( u32 fracpart ) - { - Raw = (GetWhole() * Precision) + fracpart; - return *this; - } - - wxString ToString() const - { - return wxsFormat( L"%d.%d", GetWhole(), (GetFraction() * 100) / Precision ); - } - - wxString ToString( int fracDigits ) const - { - if( fracDigits == 0 ) return wxsFormat( L"%d", GetWhole() ); - - pxAssert( fracDigits <= 7 ); // higher numbers would just cause overflows and bad mojo. - int mulby = (int)pow( 10.0, fracDigits ); - return wxsFormat( L"%d.%d", GetWhole(), (GetFraction() * mulby) / Precision ); - } - - double ToDouble() const - { - return ((double)Raw / (double)Precision); - } - - float ToFloat() const - { - return ((float)Raw / (float)Precision); - } - - int ToIntTruncated() const - { - return Raw / Precision; - } - - int ToIntRounded() const - { - return (Raw + (Precision/2)) / Precision; - } - - static bool TryFromString( FixedInt& dest, const wxString& parseFrom ) - { - long whole=0, frac=0; - const wxString beforeFirst( parseFrom.BeforeFirst( L'.' ) ); - const wxString afterFirst( parseFrom.AfterFirst( L'.' ).Mid(0, 5) ); - bool success = true; - - if( !beforeFirst.IsEmpty() ) - success = success && beforeFirst.ToLong( &whole ); - - if( !afterFirst.IsEmpty() ) - success = success && afterFirst.ToLong( &frac ); - - if( !success ) return false; - - dest.SetWhole( whole ); - - if( afterFirst.Length() != 0 && frac != 0 ) - { - int fracPower = (int)pow( 10.0, (int)afterFirst.Length() ); - dest.SetFraction( (frac * Precision) / fracPower ); - } - return true; - } - - static FixedInt FromString( const wxString& parseFrom, const FixedInt& defval ) - { - FixedInt dest; - if( !TryFromString( dest, parseFrom ) ) return defval; - return dest; - } - - // This version of FromString throws a ParseError exception if the conversion fails. - static FixedInt FromString( const wxString parseFrom ) - { - FixedInt dest; - if( !TryFromString( dest, parseFrom ) ) throw Exception::ParseError( - wxsFormat(L"Parse error on FixedInt<%d>::FromString", Precision), wxEmptyString - ); - return dest; - } + static bool TryFromString( FixedInt& dest, const wxString& parseFrom ); + static FixedInt FromString( const wxString& parseFrom, const FixedInt& defval ); + static FixedInt FromString( const wxString parseFrom ); }; typedef FixedInt<256> Fixed256; diff --git a/common/include/Utilities/FixedPointTypes.inl b/common/include/Utilities/FixedPointTypes.inl new file mode 100644 index 0000000000..d8d83439cf --- /dev/null +++ b/common/include/Utilities/FixedPointTypes.inl @@ -0,0 +1,240 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2010 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#pragma once + +#include "FixedPointTypes.h" +#include // for pow! + +template< int Precision > +FixedInt::FixedInt() +{ + Raw = 0; +} + +template< int Precision > +FixedInt::FixedInt( int signedval ) +{ + Raw = signedval * Precision; +} + +template< int Precision > +FixedInt::FixedInt( double doubval ) +{ + Raw = (int)(doubval * (double)Precision); +} + +template< int Precision > +FixedInt::FixedInt( float floval ) +{ + Raw = (int)(floval * (float)Precision); +} + +template< int Precision > +FixedInt FixedInt::operator+( const FixedInt& right ) const +{ + return FixedInt().SetRaw( Raw + right.Raw ); +} + +template< int Precision > +FixedInt FixedInt::operator-( const FixedInt& right ) const +{ + return FixedInt().SetRaw( Raw + right.Raw ); +} + +template< int Precision > +FixedInt& FixedInt::operator+=( const FixedInt& right ) +{ + return SetRaw( Raw + right.Raw ); +} + +template< int Precision > +FixedInt& FixedInt::operator-=( const FixedInt& right ) +{ + return SetRaw( Raw + right.Raw ); +} + +template< int Precision > +FixedInt& FixedInt::ConfineTo( const FixedInt& low, const FixedInt& high ) +{ + return SetRaw( std::min( std::max( Raw, low.Raw ), high.Raw ) ); +} + +// Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math +// you'll need to use the Raw values directly. +template< int Precision > +FixedInt FixedInt::operator*( const FixedInt& right ) const +{ + s64 mulres = (s64)Raw * right.Raw; + return FixedInt().SetRaw( (s32)(mulres / Precision) ); +} + +// Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math +// you'll need to use the Raw values directly. +template< int Precision > +FixedInt FixedInt::operator/( const FixedInt& right ) const +{ + s64 divres = Raw * Precision; + return FixedInt().SetRaw( (s32)(divres / right.Raw) ); +} + +// Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math +// you'll need to use the Raw values directly. +template< int Precision > +FixedInt& FixedInt::operator*=( const FixedInt& right ) +{ + s64 mulres = (s64)Raw * right.Raw; + return SetRaw( (s32)(mulres / Precision) ); +} + +// Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math +// you'll need to use the Raw values directly. +template< int Precision > +FixedInt& FixedInt::operator/=( const FixedInt& right ) +{ + s64 divres = Raw * Precision; + return SetRaw( (s32)(divres / right.Raw) ); +} + +// returns TRUE if the value overflows the legal integer range of this container. +template< int Precision > +bool FixedInt::OverflowCheck( int signedval ) +{ + return ( signedval >= (INT_MAX / Precision) ); +} + +// returns TRUE if the value overflows the legal integer range of this container. +template< int Precision > +bool FixedInt::OverflowCheck( double signedval ) +{ + return ( signedval >= (INT_MAX / Precision) ); +} + +template< int Precision > int FixedInt::GetWhole() const { return Raw / Precision; } +template< int Precision > int FixedInt::GetFraction() const { return Raw % Precision; } + +template< int Precision > +FixedInt& FixedInt::SetRaw( s32 rawsrc ) +{ + Raw = rawsrc; + return *this; +} + +template< int Precision > +FixedInt& FixedInt::Round() +{ + Raw = ToIntRounded(); + return *this; +} + +template< int Precision > +FixedInt& FixedInt::SetWhole( s32 wholepart ) +{ + pxAssert( wholepart < (INT_MAX / Precision) ); + Raw = GetFraction() + (wholepart * Precision); + return *this; +} + +template< int Precision > +FixedInt& FixedInt::SetFraction( u32 fracpart ) +{ + Raw = (GetWhole() * Precision) + fracpart; + return *this; +} + +template< int Precision > +wxString FixedInt::ToString() const +{ + return wxsFormat( L"%d.%d", GetWhole(), (GetFraction() * 100) / Precision ); +} + +template< int Precision > +wxString FixedInt::ToString( int fracDigits ) const +{ + if( fracDigits == 0 ) return wxsFormat( L"%d", GetWhole() ); + + pxAssert( fracDigits <= 7 ); // higher numbers would just cause overflows and bad mojo. + int mulby = (int)pow( 10.0, fracDigits ); + return wxsFormat( L"%d.%d", GetWhole(), (GetFraction() * mulby) / Precision ); +} + +template< int Precision > +double FixedInt::ToDouble() const +{ + return ((double)Raw / (double)Precision); +} + +template< int Precision > +float FixedInt::ToFloat() const +{ + return ((float)Raw / (float)Precision); +} + +template< int Precision > +int FixedInt::ToIntTruncated() const +{ + return Raw / Precision; +} + +template< int Precision > +int FixedInt::ToIntRounded() const +{ + return (Raw + (Precision/2)) / Precision; +} + +template< int Precision > +bool FixedInt::TryFromString( FixedInt& dest, const wxString& parseFrom ) +{ + long whole=0, frac=0; + const wxString beforeFirst( parseFrom.BeforeFirst( L'.' ) ); + const wxString afterFirst( parseFrom.AfterFirst( L'.' ).Mid(0, 5) ); + bool success = true; + + if( !beforeFirst.IsEmpty() ) + success = success && beforeFirst.ToLong( &whole ); + + if( !afterFirst.IsEmpty() ) + success = success && afterFirst.ToLong( &frac ); + + if( !success ) return false; + + dest.SetWhole( whole ); + + if( afterFirst.Length() != 0 && frac != 0 ) + { + int fracPower = (int)pow( 10.0, (int)afterFirst.Length() ); + dest.SetFraction( (frac * Precision) / fracPower ); + } + return true; +} + +template< int Precision > +FixedInt FixedInt::FromString( const wxString& parseFrom, const FixedInt& defval ) +{ + FixedInt dest; + if( !TryFromString( dest, parseFrom ) ) return defval; + return dest; +} + +// This version of FromString throws a ParseError exception if the conversion fails. +template< int Precision > +FixedInt FixedInt::FromString( const wxString parseFrom ) +{ + FixedInt dest; + if( !TryFromString( dest, parseFrom ) ) throw Exception::ParseError( + wxsFormat(L"Parse error on FixedInt<%d>::FromString", Precision), wxEmptyString + ); + return dest; +} diff --git a/common/include/Utilities/IniInterface.h b/common/include/Utilities/IniInterface.h index 63cf92a47f..2f325874cd 100644 --- a/common/include/Utilities/IniInterface.h +++ b/common/include/Utilities/IniInterface.h @@ -15,8 +15,8 @@ #pragma once -#include "FixedPointTypes.h" #include "Path.h" +#include "FixedPointTypes.h" #include // -------------------------------------------------------------------------------------- diff --git a/common/src/Utilities/CMakeLists.txt b/common/src/Utilities/CMakeLists.txt index 083cd1d995..984276d754 100644 --- a/common/src/Utilities/CMakeLists.txt +++ b/common/src/Utilities/CMakeLists.txt @@ -1,187 +1,188 @@ -# Check that people use the good file -if(NOT TOP_CMAKE_WAS_SOURCED) - message(FATAL_ERROR " - You did not 'cmake' the good CMakeLists.txt file. Use the one in the top dir. - It is advice to delete all wrongly generated cmake stuff => CMakeFiles & CMakeCache.txt") -endif(NOT TOP_CMAKE_WAS_SOURCED) - - -# library name -set(UtilitiesName Utilities) - -# Clear default flags -set(CMAKE_C_FLAGS "") -set(CMAKE_CXX_FLAGS "") -set(CMAKE_C_FLAGS_DEBUG "") -set(CMAKE_CXX_FLAGS_DEBUG "") -set(CMAKE_C_FLAGS_DEVEL "") -set(CMAKE_CXX_FLAGS_DEVEL "") -set(CMAKE_C_FLAGS_RELEASE "") -set(CMAKE_CXX_FLAGS_RELEASE "") - -# set common flags -set(CommonFlags - -pthread - -m32 - -march=i486 - -msse +# Check that people use the good file +if(NOT TOP_CMAKE_WAS_SOURCED) + message(FATAL_ERROR " + You did not 'cmake' the good CMakeLists.txt file. Use the one in the top dir. + It is advice to delete all wrongly generated cmake stuff => CMakeFiles & CMakeCache.txt") +endif(NOT TOP_CMAKE_WAS_SOURCED) + + +# library name +set(UtilitiesName Utilities) + +# Clear default flags +set(CMAKE_C_FLAGS "") +set(CMAKE_CXX_FLAGS "") +set(CMAKE_C_FLAGS_DEBUG "") +set(CMAKE_CXX_FLAGS_DEBUG "") +set(CMAKE_C_FLAGS_DEVEL "") +set(CMAKE_CXX_FLAGS_DEVEL "") +set(CMAKE_C_FLAGS_RELEASE "") +set(CMAKE_CXX_FLAGS_RELEASE "") + +# set common flags +set(CommonFlags + -pthread + -m32 + -march=i486 + -msse -msse2 - -fno-dse + -fno-dse -fno-guess-branch-probability - -fno-strict-aliasing + -fno-strict-aliasing -fno-tree-dse - -pipe + -pipe -Wno-format -Wno-unused-parameter -Wno-unused-value -Wunused-variable) - -# set warning flags -set(DebugFlags - -g - -W) - -# set optimization flags -set(OptimizationFlags - -falign-functions - -falign-jumps - -falign-labels - -falign-loops - -fcaller-saves - -fcprop-registers - -fcrossjumping - -fcse-follow-jumps - -fcse-skip-blocks - -fdefer-pop - -fdelete-null-pointer-checks - -fgcse - -fgcse-lm - -fif-conversion - -fif-conversion2 - -fmerge-constants - -foptimize-sibling-calls - -fpeephole2 - -fregmove - -freorder-blocks - -freorder-functions - -frerun-cse-after-loop - -fsched-interblock - -fsched-spec - -fstrict-overflow - -fthread-jumps - -ftree-ccp - -ftree-ch - -ftree-copyrename - -ftree-dce - -ftree-dominator-opts - -ftree-fre - -ftree-lrs - -ftree-pre - -ftree-sra - -ftree-ter - -ftree-vrp - -funit-at-a-time) - -# Debug - Build -if(CMAKE_BUILD_TYPE STREQUAL Debug) - - # add defines - add_definitions(${CommonFlags} ${DebugFlags} -DPCSX2_DEBUG -DPCSX2_DEVBUILD) -endif(CMAKE_BUILD_TYPE STREQUAL Debug) - -# Devel - Build -if(CMAKE_BUILD_TYPE STREQUAL Devel) - - # add defines - add_definitions(${CommonFlags} ${OptimizationFlags} -DPCSX2_DEVBUILD) -endif(CMAKE_BUILD_TYPE STREQUAL Devel) - -# Release - Build -if(CMAKE_BUILD_TYPE STREQUAL Release) - - # add defines - add_definitions(${CommonFlags} ${OptimizationFlags}) -endif(CMAKE_BUILD_TYPE STREQUAL Release) - -# variable with all sources of this library -set(UtilitiesSources - ../../include/Utilities/EventSource.inl - AlignedMalloc.cpp - CheckedStaticBox.cpp - Console.cpp - EventSource.cpp - Exceptions.cpp - FastFormatString.cpp - HashTools.cpp - IniInterface.cpp - Linux/LnxHostSys.cpp - Linux/LnxMisc.cpp - Linux/LnxThreads.cpp - Mutex.cpp - PathUtils.cpp - PrecompiledHeader.cpp - pxCheckBox.cpp - pxRadioPanel.cpp - pxStaticText.cpp - pxTextStream.cpp - pxWindowTextWriter.cpp - Semaphore.cpp - StringHelpers.cpp - ThreadingDialogs.cpp - ThreadTools.cpp - vssprintf.cpp - wxAppWithHelpers.cpp - wxGuiTools.cpp - wxHelpers.cpp -# x86/MemcpyFast.cpp - ) - -# collect .S files -set(UtilitiesSSources - x86/MemcpyFast.S) - -# variable with all headers of this library -set(UtilitiesHeaders - ../../include/Utilities/Assertions.h - ../../include/Utilities/CheckedStaticBox.h - ../../include/Utilities/Console.h - ../../include/Utilities/Dependencies.h - ../../include/Utilities/EventSource.h - ../../include/Utilities/Exceptions.h - ../../include/Utilities/FixedPointTypes.h - ../../include/Utilities/General.h - ../../include/Utilities/HashMap.h - ../../include/Utilities/lnx_memzero.h - ../../include/Utilities/MemcpyFast.h - ../../include/Utilities/Path.h - ../../include/Utilities/pxCheckBox.h - ../../include/Utilities/pxRadioPanel.h - ../../include/Utilities/pxStaticText.h - ../../include/Utilities/RedtapeWindows.h - ../../include/Utilities/SafeArray.h - ../../include/Utilities/ScopedPtr.h - ../../include/Utilities/ScopedPtrMT.h - ../../include/Utilities/StringHelpers.h - ../../include/Utilities/Threading.h - ../../include/Utilities/ThreadingDialogs.h - ../../include/Utilities/wxAppWithHelpers.h - ../../include/Utilities/wxBaseTools.h - ../../include/Utilities/wxGuiTools.h - PrecompiledHeader.h) - -# change language of .S-files to c++ -set_source_files_properties(${UtilitiesSSources} PROPERTIES LANGUAGE CXX) - -# add library -add_library(${UtilitiesName} STATIC ${UtilitiesSources} ${UtilitiesHeaders} ${UtilitiesSSources}) - -# link target with wx -target_link_libraries(${UtilitiesName} ${wxWidgets_LIBRARIES}) - -# Force the linker into 32 bits mode -target_link_libraries(${UtilitiesName} -m32) - -# Linker strip option -if (CMAKE_BUILD_STRIP) - target_link_libraries(${UtilitiesName} -s) -endif (CMAKE_BUILD_STRIP) + +# set warning flags +set(DebugFlags + -g + -W) + +# set optimization flags +set(OptimizationFlags + -falign-functions + -falign-jumps + -falign-labels + -falign-loops + -fcaller-saves + -fcprop-registers + -fcrossjumping + -fcse-follow-jumps + -fcse-skip-blocks + -fdefer-pop + -fdelete-null-pointer-checks + -fgcse + -fgcse-lm + -fif-conversion + -fif-conversion2 + -fmerge-constants + -foptimize-sibling-calls + -fpeephole2 + -fregmove + -freorder-blocks + -freorder-functions + -frerun-cse-after-loop + -fsched-interblock + -fsched-spec + -fstrict-overflow + -fthread-jumps + -ftree-ccp + -ftree-ch + -ftree-copyrename + -ftree-dce + -ftree-dominator-opts + -ftree-fre + -ftree-lrs + -ftree-pre + -ftree-sra + -ftree-ter + -ftree-vrp + -funit-at-a-time) + +# Debug - Build +if(CMAKE_BUILD_TYPE STREQUAL Debug) + + # add defines + add_definitions(${CommonFlags} ${DebugFlags} -DPCSX2_DEBUG -DPCSX2_DEVBUILD) +endif(CMAKE_BUILD_TYPE STREQUAL Debug) + +# Devel - Build +if(CMAKE_BUILD_TYPE STREQUAL Devel) + + # add defines + add_definitions(${CommonFlags} ${OptimizationFlags} -DPCSX2_DEVBUILD) +endif(CMAKE_BUILD_TYPE STREQUAL Devel) + +# Release - Build +if(CMAKE_BUILD_TYPE STREQUAL Release) + + # add defines + add_definitions(${CommonFlags} ${OptimizationFlags}) +endif(CMAKE_BUILD_TYPE STREQUAL Release) + +# variable with all sources of this library +set(UtilitiesSources + ../../include/Utilities/FixedPointTypes.inl + ../../include/Utilities/EventSource.inl + AlignedMalloc.cpp + CheckedStaticBox.cpp + Console.cpp + EventSource.cpp + Exceptions.cpp + FastFormatString.cpp + HashTools.cpp + IniInterface.cpp + Linux/LnxHostSys.cpp + Linux/LnxMisc.cpp + Linux/LnxThreads.cpp + Mutex.cpp + PathUtils.cpp + PrecompiledHeader.cpp + pxCheckBox.cpp + pxRadioPanel.cpp + pxStaticText.cpp + pxTextStream.cpp + pxWindowTextWriter.cpp + Semaphore.cpp + StringHelpers.cpp + ThreadingDialogs.cpp + ThreadTools.cpp + vssprintf.cpp + wxAppWithHelpers.cpp + wxGuiTools.cpp + wxHelpers.cpp +# x86/MemcpyFast.cpp + ) + +# collect .S files +set(UtilitiesSSources + x86/MemcpyFast.S) + +# variable with all headers of this library +set(UtilitiesHeaders + ../../include/Utilities/Assertions.h + ../../include/Utilities/CheckedStaticBox.h + ../../include/Utilities/Console.h + ../../include/Utilities/Dependencies.h + ../../include/Utilities/EventSource.h + ../../include/Utilities/Exceptions.h + ../../include/Utilities/FixedPointTypes.h + ../../include/Utilities/General.h + ../../include/Utilities/HashMap.h + ../../include/Utilities/lnx_memzero.h + ../../include/Utilities/MemcpyFast.h + ../../include/Utilities/Path.h + ../../include/Utilities/pxCheckBox.h + ../../include/Utilities/pxRadioPanel.h + ../../include/Utilities/pxStaticText.h + ../../include/Utilities/RedtapeWindows.h + ../../include/Utilities/SafeArray.h + ../../include/Utilities/ScopedPtr.h + ../../include/Utilities/ScopedPtrMT.h + ../../include/Utilities/StringHelpers.h + ../../include/Utilities/Threading.h + ../../include/Utilities/ThreadingDialogs.h + ../../include/Utilities/wxAppWithHelpers.h + ../../include/Utilities/wxBaseTools.h + ../../include/Utilities/wxGuiTools.h + PrecompiledHeader.h) + +# change language of .S-files to c++ +set_source_files_properties(${UtilitiesSSources} PROPERTIES LANGUAGE CXX) + +# add library +add_library(${UtilitiesName} STATIC ${UtilitiesSources} ${UtilitiesHeaders} ${UtilitiesSSources}) + +# link target with wx +target_link_libraries(${UtilitiesName} ${wxWidgets_LIBRARIES}) + +# Force the linker into 32 bits mode +target_link_libraries(${UtilitiesName} -m32) + +# Linker strip option +if (CMAKE_BUILD_STRIP) + target_link_libraries(${UtilitiesName} -s) +endif (CMAKE_BUILD_STRIP) diff --git a/common/src/Utilities/IniInterface.cpp b/common/src/Utilities/IniInterface.cpp index f1642f802c..7ce037d4d6 100644 --- a/common/src/Utilities/IniInterface.cpp +++ b/common/src/Utilities/IniInterface.cpp @@ -20,6 +20,12 @@ const wxRect wxDefaultRect( wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, wxDefaultCoord ); +// Implement FixedPointTypes (for lack of a better location, for now) + +#include "FixedPointTypes.inl" +template FixedInt<100>; +template FixedInt<256>; + static int _calcEnumLength( const wxChar* const* enumArray ) { int cnt = 0;