- change all inline declarations to one of two macros: BX_C_INLINE or

BX_CPP_INLINE.  Then in config.h.in you can define these two as you
  wish.
This commit is contained in:
Bryce Denney 2001-04-10 02:10:09 +00:00
parent b05159c112
commit 4e04f4cb58
8 changed files with 118 additions and 97 deletions

View File

@ -383,8 +383,29 @@ typedef unsigned int Boolean;
#define HAVE_SIGACTION 1
// configure will change the definition of "inline" to the value
// that the C compiler allows. It tests the following keywords to
// see if any is permitted: inline, __inline__, __inline. If none
// is permitted, it defines inline to be empty.
#define inline inline
// inline functions in headers that are compiled with C compiler
// (e.g. fpu code) are declared with BX_C_INLINE macro. Note that
// the word "inline" itself may now be redefined by the above #define.
// Many compilers are known to work with "static inline". If the
// compiler can put the function inline, it does so and never creates
// a symbol for the function. If optimization is off, or inline is
// defined to be empty, the static keyword causes the function to create
// a symbol that's visible only to that .c file. Each .c file that
// includes the header will produde another local version of the
// BX_C_INLINE function (not ideal). However without "static" you can
// duplicate symbol problems which are even worse.
#define BX_C_INLINE static inline
// Use BX_CPP_INLINE for all C++ inline functions. Note that the
// word "inline" itself may now be redefined by the above #define.
#define BX_CPP_INLINE inline
#define BX_DEBUGGER 0
#define BX_DISASM 0

View File

@ -1308,48 +1308,48 @@ public: // for now...
unsigned opa, unsigned opb);
#endif
BX_SMF inline void set_CF(Boolean val);
BX_SMF inline void set_AF(Boolean val);
BX_SMF inline void set_ZF(Boolean val);
BX_SMF inline void set_SF(Boolean val);
BX_SMF inline void set_OF(Boolean val);
BX_SMF inline void set_PF(Boolean val);
BX_SMF inline void set_PF_base(Bit8u val);
BX_SMF BX_CPP_INLINE void set_CF(Boolean val);
BX_SMF BX_CPP_INLINE void set_AF(Boolean val);
BX_SMF BX_CPP_INLINE void set_ZF(Boolean val);
BX_SMF BX_CPP_INLINE void set_SF(Boolean val);
BX_SMF BX_CPP_INLINE void set_OF(Boolean val);
BX_SMF BX_CPP_INLINE void set_PF(Boolean val);
BX_SMF BX_CPP_INLINE void set_PF_base(Bit8u val);
BX_SMF inline void set_AX(Bit16u ax);
BX_SMF inline void set_BX(Bit16u bx);
BX_SMF inline void set_CX(Bit16u cx);
BX_SMF inline void set_DX(Bit16u dx);
BX_SMF inline void set_AL(Bit8u al);
BX_SMF inline void set_AH(Bit8u ah);
BX_SMF inline void set_BL(Bit8u bl);
BX_SMF inline void set_BH(Bit8u bh);
BX_SMF inline void set_CL(Bit8u cl);
BX_SMF inline void set_CH(Bit8u ch);
BX_SMF inline void set_DL(Bit8u dl);
BX_SMF inline void set_DH(Bit8u dh);
BX_SMF BX_CPP_INLINE void set_AX(Bit16u ax);
BX_SMF BX_CPP_INLINE void set_BX(Bit16u bx);
BX_SMF BX_CPP_INLINE void set_CX(Bit16u cx);
BX_SMF BX_CPP_INLINE void set_DX(Bit16u dx);
BX_SMF BX_CPP_INLINE void set_AL(Bit8u al);
BX_SMF BX_CPP_INLINE void set_AH(Bit8u ah);
BX_SMF BX_CPP_INLINE void set_BL(Bit8u bl);
BX_SMF BX_CPP_INLINE void set_BH(Bit8u bh);
BX_SMF BX_CPP_INLINE void set_CL(Bit8u cl);
BX_SMF BX_CPP_INLINE void set_CH(Bit8u ch);
BX_SMF BX_CPP_INLINE void set_DL(Bit8u dl);
BX_SMF BX_CPP_INLINE void set_DH(Bit8u dh);
BX_SMF inline Bit8u get_AL(void);
BX_SMF inline Bit8u get_AH(void);
BX_SMF inline Bit8u get_BL(void);
BX_SMF inline Bit8u get_BH(void);
BX_SMF inline Bit8u get_CL(void);
BX_SMF inline Bit8u get_CH(void);
BX_SMF inline Bit8u get_DL(void);
BX_SMF inline Bit8u get_DH(void);
BX_SMF BX_CPP_INLINE Bit8u get_AL(void);
BX_SMF BX_CPP_INLINE Bit8u get_AH(void);
BX_SMF BX_CPP_INLINE Bit8u get_BL(void);
BX_SMF BX_CPP_INLINE Bit8u get_BH(void);
BX_SMF BX_CPP_INLINE Bit8u get_CL(void);
BX_SMF BX_CPP_INLINE Bit8u get_CH(void);
BX_SMF BX_CPP_INLINE Bit8u get_DL(void);
BX_SMF BX_CPP_INLINE Bit8u get_DH(void);
BX_SMF inline Bit16u get_AX(void);
BX_SMF inline Bit16u get_BX(void);
BX_SMF inline Bit16u get_CX(void);
BX_SMF inline Bit16u get_DX(void);
BX_SMF BX_CPP_INLINE Bit16u get_AX(void);
BX_SMF BX_CPP_INLINE Bit16u get_BX(void);
BX_SMF BX_CPP_INLINE Bit16u get_CX(void);
BX_SMF BX_CPP_INLINE Bit16u get_DX(void);
#if BX_CPU_LEVEL >= 2
BX_SMF inline Boolean real_mode(void);
BX_SMF BX_CPP_INLINE Boolean real_mode(void);
#endif
#if BX_CPU_LEVEL >= 3
BX_SMF inline Boolean protected_mode(void);
BX_SMF inline Boolean v8086_mode(void);
BX_SMF BX_CPP_INLINE Boolean protected_mode(void);
BX_SMF BX_CPP_INLINE Boolean v8086_mode(void);
#endif
};
@ -1365,105 +1365,105 @@ public: // for now...
extern BX_CPU_C BX_CPU;
BX_SMF inline void BX_CPU_C_PREFIX set_AX(Bit16u ax) { AX = ax; };
BX_SMF inline void BX_CPU_C_PREFIX set_BX(Bit16u bx) { BX = bx; };
BX_SMF inline void BX_CPU_C_PREFIX set_CX(Bit16u cx) { CX = cx; };
BX_SMF inline void BX_CPU_C_PREFIX set_DX(Bit16u dx) { DX = dx; };
BX_SMF inline void BX_CPU_C_PREFIX set_AL(Bit8u al) { AL = al; };
BX_SMF inline void BX_CPU_C_PREFIX set_AH(Bit8u ah) { AH = ah; };
BX_SMF inline void BX_CPU_C_PREFIX set_BL(Bit8u bl) { BL = bl; };
BX_SMF inline void BX_CPU_C_PREFIX set_BH(Bit8u bh) { BH = bh; };
BX_SMF inline void BX_CPU_C_PREFIX set_CL(Bit8u cl) { CL = cl; };
BX_SMF inline void BX_CPU_C_PREFIX set_CH(Bit8u ch) { CH = ch; };
BX_SMF inline void BX_CPU_C_PREFIX set_DL(Bit8u dl) { DL = dl; };
BX_SMF inline void BX_CPU_C_PREFIX set_DH(Bit8u dh) { DH = dh; };
BX_SMF BX_CPP_INLINE void BX_CPU_C_PREFIX set_AX(Bit16u ax) { AX = ax; };
BX_SMF BX_CPP_INLINE void BX_CPU_C_PREFIX set_BX(Bit16u bx) { BX = bx; };
BX_SMF BX_CPP_INLINE void BX_CPU_C_PREFIX set_CX(Bit16u cx) { CX = cx; };
BX_SMF BX_CPP_INLINE void BX_CPU_C_PREFIX set_DX(Bit16u dx) { DX = dx; };
BX_SMF BX_CPP_INLINE void BX_CPU_C_PREFIX set_AL(Bit8u al) { AL = al; };
BX_SMF BX_CPP_INLINE void BX_CPU_C_PREFIX set_AH(Bit8u ah) { AH = ah; };
BX_SMF BX_CPP_INLINE void BX_CPU_C_PREFIX set_BL(Bit8u bl) { BL = bl; };
BX_SMF BX_CPP_INLINE void BX_CPU_C_PREFIX set_BH(Bit8u bh) { BH = bh; };
BX_SMF BX_CPP_INLINE void BX_CPU_C_PREFIX set_CL(Bit8u cl) { CL = cl; };
BX_SMF BX_CPP_INLINE void BX_CPU_C_PREFIX set_CH(Bit8u ch) { CH = ch; };
BX_SMF BX_CPP_INLINE void BX_CPU_C_PREFIX set_DL(Bit8u dl) { DL = dl; };
BX_SMF BX_CPP_INLINE void BX_CPU_C_PREFIX set_DH(Bit8u dh) { DH = dh; };
BX_SMF inline Bit8u BX_CPU_C_PREFIX get_AL(void) { return(AL); };
BX_SMF inline Bit8u BX_CPU_C_PREFIX get_AH(void) { return(AH); };
BX_SMF inline Bit8u BX_CPU_C_PREFIX get_BL(void) { return(BL); };
BX_SMF inline Bit8u BX_CPU_C_PREFIX get_BH(void) { return(BH); };
BX_SMF inline Bit8u BX_CPU_C_PREFIX get_CL(void) { return(CL); };
BX_SMF inline Bit8u BX_CPU_C_PREFIX get_CH(void) { return(CH); };
BX_SMF inline Bit8u BX_CPU_C_PREFIX get_DL(void) { return(DL); };
BX_SMF inline Bit8u BX_CPU_C_PREFIX get_DH(void) { return(DH); };
BX_SMF BX_CPP_INLINE Bit8u BX_CPU_C_PREFIX get_AL(void) { return(AL); };
BX_SMF BX_CPP_INLINE Bit8u BX_CPU_C_PREFIX get_AH(void) { return(AH); };
BX_SMF BX_CPP_INLINE Bit8u BX_CPU_C_PREFIX get_BL(void) { return(BL); };
BX_SMF BX_CPP_INLINE Bit8u BX_CPU_C_PREFIX get_BH(void) { return(BH); };
BX_SMF BX_CPP_INLINE Bit8u BX_CPU_C_PREFIX get_CL(void) { return(CL); };
BX_SMF BX_CPP_INLINE Bit8u BX_CPU_C_PREFIX get_CH(void) { return(CH); };
BX_SMF BX_CPP_INLINE Bit8u BX_CPU_C_PREFIX get_DL(void) { return(DL); };
BX_SMF BX_CPP_INLINE Bit8u BX_CPU_C_PREFIX get_DH(void) { return(DH); };
BX_SMF inline Bit16u BX_CPU_C_PREFIX get_AX(void) { return(AX); };
BX_SMF inline Bit16u BX_CPU_C_PREFIX get_BX(void) { return(BX); };
BX_SMF inline Bit16u BX_CPU_C_PREFIX get_CX(void) { return(CX); };
BX_SMF inline Bit16u BX_CPU_C_PREFIX get_DX(void) { return(DX); };
BX_SMF BX_CPP_INLINE Bit16u BX_CPU_C_PREFIX get_AX(void) { return(AX); };
BX_SMF BX_CPP_INLINE Bit16u BX_CPU_C_PREFIX get_BX(void) { return(BX); };
BX_SMF BX_CPP_INLINE Bit16u BX_CPU_C_PREFIX get_CX(void) { return(CX); };
BX_SMF BX_CPP_INLINE Bit16u BX_CPU_C_PREFIX get_DX(void) { return(DX); };
#if BX_CPU_LEVEL >= 2
inline Boolean BX_CPU_C::real_mode(void) { return( !BX_CPU_THIS_PTR cr0.pe ); };
BX_CPP_INLINE Boolean BX_CPU_C::real_mode(void) { return( !BX_CPU_THIS_PTR cr0.pe ); };
#endif
#if BX_CPU_LEVEL == 2
inline Boolean BX_CPU_C::protected_mode(void) { return( BX_CPU_THIS_PTR cr0.pe ); };
BX_CPP_INLINE Boolean BX_CPU_C::protected_mode(void) { return( BX_CPU_THIS_PTR cr0.pe ); };
#endif
#if BX_CPU_LEVEL >= 3
# if BX_SUPPORT_V8086_MODE
inline Boolean
BX_CPP_INLINE Boolean
BX_CPU_C::v8086_mode(void) {
return(BX_CPU_THIS_PTR eflags.vm);
}
inline Boolean
BX_CPP_INLINE Boolean
BX_CPU_C::protected_mode(void) {
return(BX_CPU_THIS_PTR cr0.pe && !BX_CPU_THIS_PTR eflags.vm);
}
# else
inline Boolean
BX_CPP_INLINE Boolean
BX_CPU_C::v8086_mode(void) {
return(0);
}
inline Boolean
BX_CPP_INLINE Boolean
BX_CPU_C::protected_mode(void) {
return(BX_CPU_THIS_PTR cr0.pe);
}
# endif
#endif
inline void
BX_CPP_INLINE void
BX_CPU_C::set_CF(Boolean val) {
BX_CPU_THIS_PTR lf_flags_status &= 0xfffff0;
BX_CPU_THIS_PTR eflags.cf = val;
}
inline void
BX_CPP_INLINE void
BX_CPU_C::set_AF(Boolean val) {
BX_CPU_THIS_PTR lf_flags_status &= 0xfff0ff;
BX_CPU_THIS_PTR eflags.af = val;
}
inline void
BX_CPP_INLINE void
BX_CPU_C::set_ZF(Boolean val) {
BX_CPU_THIS_PTR lf_flags_status &= 0xff0fff;
BX_CPU_THIS_PTR eflags.zf = val;
}
inline void
BX_CPP_INLINE void
BX_CPU_C::set_SF(Boolean val) {
BX_CPU_THIS_PTR lf_flags_status &= 0xf0ffff;
BX_CPU_THIS_PTR eflags.sf = val;
}
inline void
BX_CPP_INLINE void
BX_CPU_C::set_OF(Boolean val) {
BX_CPU_THIS_PTR lf_flags_status &= 0x0fffff;
BX_CPU_THIS_PTR eflags.of = val;
}
inline void
BX_CPP_INLINE void
BX_CPU_C::set_PF(Boolean val) {
BX_CPU_THIS_PTR lf_flags_status &= 0xffff0f;
BX_CPU_THIS_PTR lf_pf = val;
}
inline void
BX_CPP_INLINE void
BX_CPU_C::set_PF_base(Bit8u val) {
BX_CPU_THIS_PTR eflags.pf_byte = val;
BX_CPU_THIS_PTR lf_flags_status = (BX_CPU_THIS_PTR lf_flags_status & 0xffff0f) | BX_LF_MASK_P;

View File

@ -69,14 +69,14 @@ private:
char *index_name16[8];
char *index_name32[8];
inline Bit8u fetch_byte(void) {
BX_CPP_INLINE Bit8u fetch_byte(void) {
return(*instruction++);
};
inline Bit8u peek_byte(void) {
BX_CPP_INLINE Bit8u peek_byte(void) {
return(*instruction);
};
inline Bit16u fetch_word(void) {
BX_CPP_INLINE Bit16u fetch_word(void) {
Bit16u ret16;
Bit8u b1, b0;
@ -86,7 +86,7 @@ private:
return(ret16);
};
inline Bit32u fetch_dword(void) {
BX_CPP_INLINE Bit32u fetch_dword(void) {
Bit32u ret32;
Bit8u b3, b2, b1, b0;

View File

@ -198,7 +198,8 @@ extern u_char const data_sizes_16[32];
#define significand(x) ( ((u64 *)&((x)->sigl))[0] )
#endif
static inline void reg_copy(FPU_REG const *x, FPU_REG *y)
BX_C_INLINE
void reg_copy(FPU_REG const *x, FPU_REG *y)
{
y->exp = x->exp;
significand(y) = significand(x);

View File

@ -74,14 +74,9 @@ asmlinkage void div_Xsig(const Xsig *x1, const Xsig *x2, Xsig *dest);
*/
/* Multiply two fixed-point 32 bit numbers, producing a 32 bit result.
The answer is the ms word of the product.
bbd: this and all other inline functions in this file used to be
declared extern inline. But if the compiler does not inline the function,
each .c declares its own external symbol for the function, leading to
symbol conflicts. static inline seems to be safe in either case.
*/
static inline u32 mul_32_32(const u32 arg1, const u32 arg2)
The answer is the ms word of the product. */
BX_C_INLINE
u32 mul_32_32(const u32 arg1, const u32 arg2)
{
#ifdef NO_ASSEMBLER
return (((u64)arg1) * arg2) >> 32;
@ -100,7 +95,8 @@ static inline u32 mul_32_32(const u32 arg1, const u32 arg2)
/* Add the 12 byte Xsig x2 to Xsig dest, with no checks for overflow. */
static inline void add_Xsig_Xsig(Xsig *dest, const Xsig *x2)
BX_C_INLINE
void add_Xsig_Xsig(Xsig *dest, const Xsig *x2)
{
#ifdef NO_ASSEMBLER
dest->lsw += x2->lsw;
@ -128,7 +124,8 @@ static inline void add_Xsig_Xsig(Xsig *dest, const Xsig *x2)
/* Add the 12 byte Xsig x2 to Xsig dest, adjust exp if overflow occurs. */
static inline void add_two_Xsig(Xsig *dest, const Xsig *x2, s32 *exp)
BX_C_INLINE
void add_two_Xsig(Xsig *dest, const Xsig *x2, s32 *exp)
{
#ifdef NO_ASSEMBLER
int ovfl = 0;
@ -188,7 +185,8 @@ static inline void add_two_Xsig(Xsig *dest, const Xsig *x2, s32 *exp)
/* Negate the 12 byte Xsig */
static inline void negate_Xsig(Xsig *x)
BX_C_INLINE
void negate_Xsig(Xsig *x)
{
#ifdef NO_ASSEMBLER
x->lsw = ~x->lsw;

View File

@ -119,10 +119,10 @@ struct {
} bx_tool_pixmap[BX_MAX_PIXMAPS];
// Event handlers
inline void HandleKey(EventRecord *event, Bit32u keyState);
inline void HandleToolClick(Point where);
BX_CPP_INLINE void HandleKey(EventRecord *event, Bit32u keyState);
BX_CPP_INLINE void HandleToolClick(Point where);
void HandleMenuChoice(long menuChoice);
inline void HandleClick(EventRecord *event);
BX_CPP_INLINE void HandleClick(EventRecord *event);
// Update routines
void UpdateWindow(WindowPtr window);
@ -363,7 +363,7 @@ void bx_gui_c::specific_init(bx_gui_c *th, int argc, char **argv, unsigned tilew
//
// Handles keyboard-related events.
inline void HandleKey(EventRecord *event, Bit32u keyState)
BX_CPP_INLINE void HandleKey(EventRecord *event, Bit32u keyState)
{
int key;
UInt32 trans;
@ -412,7 +412,7 @@ inline void HandleKey(EventRecord *event, Bit32u keyState)
//
// Handles mouse clicks in the Bochs tool window
inline void HandleToolClick(Point where)
BX_CPP_INLINE void HandleToolClick(Point where)
{
unsigned i;
int xorigin;
@ -433,7 +433,7 @@ inline void HandleToolClick(Point where)
thisGUI->show_headerbar();
}
inline void ResetPointer(void)
BX_CPP_INLINE void ResetPointer(void)
{
#if 0
CursorDevice *theMouse;
@ -567,7 +567,7 @@ void HandleMenuChoice(long menuChoice)
HiliteMenu(0);
}
inline void HandleClick(EventRecord *event)
BX_CPP_INLINE void HandleClick(EventRecord *event)
{
short part;
WindowPtr whichWindow;

View File

@ -42,7 +42,8 @@
#endif
// If the buffer commands are to be inlined:
#define BX_SB16_BUFINL inline
#define BX_SB16_BUFINL BX_CPP_INLINE
// BX_CPP_INLINE is defined to the inline keyword for the C++ compiler.
// maximum number of patch translations
#define BX_SB16_PATCHTABLESIZE 1024

View File

@ -109,7 +109,7 @@ public:
void activate_timer( unsigned timer_index, Bit32u useconds,
Boolean continuous );
void deactivate_timer( unsigned timer_index );
static inline void tick1(void) {
static BX_CPP_INLINE void tick1(void) {
#if BX_SHOW_IPS
{
extern unsigned long ips_count;
@ -120,7 +120,7 @@ public:
bx_pc_system.timer_handler();
}
}
static inline void tickn(Bit64u n) {
static BX_CPP_INLINE void tickn(Bit64u n) {
#if BX_SHOW_IPS
{
extern unsigned long ips_count;