1
0
Fork 0

Add compiler testing for always_inline attribute

Add compiler testing for fastcall attribute
Add the FASTCALL define to visual c
Remove some overkill inline routines
Make sure that all the inline routines in headers are static


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3355
This commit is contained in:
Sjoerd van der Berg 2009-04-25 16:25:03 +00:00
parent 5f6236ee35
commit 88caf1dc71
20 changed files with 182 additions and 147 deletions

View file

@ -218,26 +218,26 @@ static inline Bits MakeVolume( Bitu wave, Bitu volume ) {
return (sig >> exp);
};
static Bits FASTCALL WaveForm0( Bitu i, Bitu volume ) {
static Bits DB_FASTCALL WaveForm0( Bitu i, Bitu volume ) {
Bits neg = 0 - (( i >> 9) & 1);//Create ~0 or 0
Bitu wave = SinTable[i & 511];
return (MakeVolume( wave, volume ) ^ neg) - neg;
}
static Bits FASTCALL WaveForm1( Bitu i, Bitu volume ) {
static Bits DB_FASTCALL WaveForm1( Bitu i, Bitu volume ) {
Bit32u wave = SinTable[i & 511];
wave |= ( ( (i ^ 512 ) & 512) - 1) >> ( 32 - 12 );
return MakeVolume( wave, volume );
}
static Bits FASTCALL WaveForm2( Bitu i, Bitu volume ) {
static Bits DB_FASTCALL WaveForm2( Bitu i, Bitu volume ) {
Bitu wave = SinTable[i & 511];
return MakeVolume( wave, volume );
}
static Bits FASTCALL WaveForm3( Bitu i, Bitu volume ) {
static Bits DB_FASTCALL WaveForm3( Bitu i, Bitu volume ) {
Bitu wave = SinTable[i & 255];
wave |= ( ( (i ^ 256 ) & 256) - 1) >> ( 32 - 12 );
return MakeVolume( wave, volume );
}
static Bits FASTCALL WaveForm4( Bitu i, Bitu volume ) {
static Bits DB_FASTCALL WaveForm4( Bitu i, Bitu volume ) {
//Twice as fast
i <<= 1;
Bits neg = 0 - (( i >> 9) & 1);//Create ~0 or 0
@ -245,18 +245,18 @@ static Bits FASTCALL WaveForm4( Bitu i, Bitu volume ) {
wave |= ( ( (i ^ 512 ) & 512) - 1) >> ( 32 - 12 );
return (MakeVolume( wave, volume ) ^ neg) - neg;
}
static Bits FASTCALL WaveForm5( Bitu i, Bitu volume ) {
static Bits DB_FASTCALL WaveForm5( Bitu i, Bitu volume ) {
//Twice as fast
i <<= 1;
Bitu wave = SinTable[i & 511];
wave |= ( ( (i ^ 512 ) & 512) - 1) >> ( 32 - 12 );
return MakeVolume( wave, volume );
}
static Bits FASTCALL WaveForm6( Bitu i, Bitu volume ) {
static Bits DB_FASTCALL WaveForm6( Bitu i, Bitu volume ) {
Bits neg = 0 - (( i >> 9) & 1);//Create ~0 or 0
return (MakeVolume( 0, volume ) ^ neg) - neg;
}
static Bits FASTCALL WaveForm7( Bitu i, Bitu volume ) {
static Bits DB_FASTCALL WaveForm7( Bitu i, Bitu volume ) {
//Negative is reversed here
Bits neg = (( i >> 9) & 1) - 1;
Bitu wave = (i << 3);

View file

@ -40,7 +40,7 @@ struct Operator;
struct Channel;
#if (DBOPL_WAVE == WAVE_HANDLER)
typedef Bits ( FASTCALL *WaveHandler) ( Bitu i, Bitu volume );
typedef Bits ( DB_FASTCALL *WaveHandler) ( Bitu i, Bitu volume );
#endif
typedef Bits ( DBOPL::Operator::*VolumeHandler) ( );
@ -247,4 +247,4 @@ struct Handler : public Adlib::Handler {
};
}; //Namespace
}; //Namespace

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: mixer.cpp,v 1.50 2009-03-19 20:45:42 c2woody Exp $ */
/* $Id: mixer.cpp,v 1.51 2009-04-25 16:25:03 harekiet Exp $ */
/*
Remove the sdl code from here and have it handeld in the sdlmain.
@ -55,7 +55,7 @@
#define MIXER_REMAIN ((1<<MIXER_SHIFT)-1)
#define MIXER_VOLSHIFT 13
static inline Bit16s MIXER_CLIP(Bits SAMP) {
static INLINE Bit16s MIXER_CLIP(Bits SAMP) {
if (SAMP < MAX_AUDIO) {
if (SAMP > MIN_AUDIO)
return SAMP;
@ -175,7 +175,7 @@ void MixerChannel::AddSilence(void) {
}
template<class Type,bool stereo,bool signeddata,bool nativeorder>
INLINE void MixerChannel::AddSamples(Bitu len, const Type* data) {
inline void MixerChannel::AddSamples(Bitu len, const Type* data) {
Bits diff[2];
Bitu mixpos=mixer.pos+done;
freq_index&=MIXER_REMAIN;

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: int10.h,v 1.37 2009-04-11 07:58:39 qbix79 Exp $ */
/* $Id: int10.h,v 1.38 2009-04-25 16:25:03 harekiet Exp $ */
#include "vga.h"
@ -146,11 +146,11 @@ typedef struct {
extern Int10Data int10;
INLINE Bit8u CURSOR_POS_COL(Bit8u page) {
static Bit8u CURSOR_POS_COL(Bit8u page) {
return real_readb(BIOSMEM_SEG,BIOSMEM_CURSOR_POS+page*2);
}
INLINE Bit8u CURSOR_POS_ROW(Bit8u page) {
static Bit8u CURSOR_POS_ROW(Bit8u page) {
return real_readb(BIOSMEM_SEG,BIOSMEM_CURSOR_POS+page*2+1);
}

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: int10_char.cpp,v 1.56 2008-11-09 11:22:03 qbix79 Exp $ */
/* $Id: int10_char.cpp,v 1.57 2009-04-25 16:25:03 harekiet Exp $ */
/* Character displaying moving functions */
@ -26,7 +26,7 @@
#include "inout.h"
#include "int10.h"
static INLINE void CGA2_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rnew,PhysPt base) {
static void CGA2_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rnew,PhysPt base) {
Bit8u cheight = real_readb(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT);
PhysPt dest=base+((CurMode->twidth*rnew)*(cheight/2)+cleft);
PhysPt src=base+((CurMode->twidth*rold)*(cheight/2)+cleft);
@ -39,7 +39,7 @@ static INLINE void CGA2_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rnew,P
}
}
static INLINE void CGA4_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rnew,PhysPt base) {
static void CGA4_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rnew,PhysPt base) {
Bit8u cheight = real_readb(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT);
PhysPt dest=base+((CurMode->twidth*rnew)*(cheight/2)+cleft)*2;
PhysPt src=base+((CurMode->twidth*rold)*(cheight/2)+cleft)*2;
@ -51,7 +51,7 @@ static INLINE void CGA4_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rnew,P
}
}
static INLINE void TANDY16_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rnew,PhysPt base) {
static void TANDY16_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rnew,PhysPt base) {
Bit8u cheight = real_readb(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT);
PhysPt dest=base+((CurMode->twidth*rnew)*(cheight/4)+cleft)*4;
PhysPt src=base+((CurMode->twidth*rold)*(cheight/4)+cleft)*4;
@ -65,7 +65,7 @@ static INLINE void TANDY16_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rne
}
}
static INLINE void EGA16_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rnew,PhysPt base) {
static void EGA16_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rnew,PhysPt base) {
PhysPt src,dest;Bitu copy;
Bit8u cheight = real_readb(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT);
dest=base+(CurMode->twidth*rnew)*cheight+cleft;
@ -85,7 +85,7 @@ static INLINE void EGA16_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rnew,
IO_Write(0x3ce,5);IO_Write(0x3cf,0); /* Normal transfer mode */
}
static INLINE void VGA_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rnew,PhysPt base) {
static void VGA_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rnew,PhysPt base) {
PhysPt src,dest;Bitu copy;
Bit8u cheight = real_readb(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT);
dest=base+8*((CurMode->twidth*rnew)*cheight+cleft);
@ -99,14 +99,14 @@ static INLINE void VGA_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rnew,Ph
}
}
static INLINE void TEXT_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rnew,PhysPt base) {
static void TEXT_CopyRow(Bit8u cleft,Bit8u cright,Bit8u rold,Bit8u rnew,PhysPt base) {
PhysPt src,dest;
src=base+(rold*CurMode->twidth+cleft)*2;
dest=base+(rnew*CurMode->twidth+cleft)*2;
MEM_BlockCopy(dest,src,(cright-cleft)*2);
}
static INLINE void CGA2_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt base,Bit8u attr) {
static void CGA2_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt base,Bit8u attr) {
Bit8u cheight = real_readb(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT);
PhysPt dest=base+((CurMode->twidth*row)*(cheight/2)+cleft);
Bitu copy=(cright-cleft);
@ -122,7 +122,7 @@ static INLINE void CGA2_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt base,B
}
static INLINE void CGA4_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt base,Bit8u attr) {
static void CGA4_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt base,Bit8u attr) {
Bit8u cheight = real_readb(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT);
PhysPt dest=base+((CurMode->twidth*row)*(cheight/2)+cleft)*2;
Bitu copy=(cright-cleft)*2;Bitu nextline=CurMode->twidth*2;
@ -136,7 +136,7 @@ static INLINE void CGA4_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt base,B
}
}
static INLINE void TANDY16_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt base,Bit8u attr) {
static void TANDY16_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt base,Bit8u attr) {
Bit8u cheight = real_readb(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT);
PhysPt dest=base+((CurMode->twidth*row)*(cheight/4)+cleft)*4;
Bitu copy=(cright-cleft)*4;Bitu nextline=CurMode->twidth*4;
@ -152,7 +152,7 @@ static INLINE void TANDY16_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt bas
}
}
static INLINE void EGA16_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt base,Bit8u attr) {
static void EGA16_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt base,Bit8u attr) {
/* Set Bitmask / Color / Full Set Reset */
IO_Write(0x3ce,0x8);IO_Write(0x3cf,0xff);
IO_Write(0x3ce,0x0);IO_Write(0x3cf,attr);
@ -169,7 +169,7 @@ static INLINE void EGA16_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt base,
IO_Write(0x3cf,0);
}
static INLINE void VGA_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt base,Bit8u attr) {
static void VGA_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt base,Bit8u attr) {
/* Write some bytes */
Bit8u cheight = real_readb(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT);
PhysPt dest=base+8*((CurMode->twidth*row)*cheight+cleft);
@ -181,7 +181,7 @@ static INLINE void VGA_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt base,Bi
}
}
static INLINE void TEXT_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt base,Bit8u attr) {
static void TEXT_FillRow(Bit8u cleft,Bit8u cright,Bit8u row,PhysPt base,Bit8u attr) {
/* Do some filing */
PhysPt dest;
dest=base+(row*CurMode->twidth+cleft)*2;
@ -549,7 +549,7 @@ void INT10_WriteChar(Bit8u chr,Bit8u attr,Bit8u page,Bit16u count,bool showattr)
}
}
static INLINE void INT10_TeletypeOutputAttr(Bit8u chr,Bit8u attr,bool useattr,Bit8u page) {
static void INT10_TeletypeOutputAttr(Bit8u chr,Bit8u attr,bool useattr,Bit8u page) {
BIOS_NCOLS;BIOS_NROWS;
Bit8u cur_row=CURSOR_POS_ROW(page);
Bit8u cur_col=CURSOR_POS_COL(page);

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: support.cpp,v 1.35 2008-08-06 18:32:35 c2woody Exp $ */
/* $Id: support.cpp,v 1.36 2009-04-25 16:25:03 harekiet Exp $ */
#include <string.h>
#include <stdlib.h>
@ -80,6 +80,17 @@ char *trim(char *str) {
return ltrim(rtrim(str));
}
char * upcase(char * str) {
for (char* idx = str; *idx ; idx++) *idx = toupper(*reinterpret_cast<unsigned char*>(idx));
return str;
}
char * lowcase(char * str) {
for(char* idx = str; *idx ; idx++) *idx = tolower(*reinterpret_cast<unsigned char*>(idx));
return str;
}
bool ScanCMDBool(char * cmd,char const * const check) {
char * scan=cmd;size_t c_len=strlen(check);

View file

@ -1,8 +1,5 @@
#define INLINE __forceinline
#define VERSION "0.72"
/* Define to 1 to enable internal debugger, requires libcurses */
#define C_DEBUG 0
@ -58,6 +55,9 @@
#define GCC_ATTRIBUTE(x) /* attribute not supported */
#define GCC_UNLIKELY(x) (x)
#define INLINE __forceinline
#define DB_FASTCALL __fastcall
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
#pragma warning(disable : 4996)
#endif