Added a couple macros which expand on GCC to __attribute__ directives

to give the compiler some hints:

    BX_CPP_AttrPrintf(formatArg, firstArg)
    BX_CPP_AttrNoReturn()

The first is to tell the compiler that a function receives printf-like
  arguments so it can do some smart argument checking w.r.t. the
  format string.  The 2nd tells the compiler that the function does
  not ever return; it's not used yet, but I'd like to use it on
  exception() after we fix the situation of it returning for debugging.

I fixed one parameter mismatch in cpu/ by deleting a deprecated
  debug print statement.  There are several other mismatches in
  other code modules.
This commit is contained in:
Kevin Lawton 2002-10-06 14:16:23 +00:00
parent 346e2747d3
commit 261badee5a
4 changed files with 35 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: bochs.h,v 1.99 2002-10-03 21:06:58 bdenney Exp $
// $Id: bochs.h,v 1.100 2002-10-06 14:16:13 kevinlawton Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -267,10 +267,10 @@ public:
logfunctions(class iofunctions *);
~logfunctions(void);
void info(const char *fmt, ...);
void error(const char *fmt, ...);
void panic(const char *fmt, ...);
void ldebug(const char *fmt, ...);
void info(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void error(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void panic(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void fatal (const char *prefix, const char *fmt, va_list ap);
void ask (int level, const char *prefix, const char *fmt, va_list ap);
void put(char *);

View File

@ -549,11 +549,36 @@ typedef
#define BX_CPP_INLINE inline
#ifdef __GNUC__
// KPL: We need to enhance this for other compilers that know about
// aligning variables/fields.
// Some helpful compiler hints for compilers that allow them; GCC for now.
//
// BX_CPP_AlignN(n):
// Align a construct on an n-byte boundary.
//
// BX_CPP_AttrPrintf(formatArg, firstArg):
// This function takes printf-like arguments, so the compiler can check
// the consistency of the format string and the matching arguments.
// 'formatArg' is the parameter number (starting from 1) of the format
// string argument. 'firstArg' is the parameter number of the 1st argument
// to check against the string argument. NOTE: For non-static member
// functions, the this-ptr is argument number 1 but is invisible on
// the function prototype declaration - but you still have to count it.
//
// BX_CPP_AttrNoReturn():
// This function never returns. The compiler can optimize-out following
// code accordingly.
#define BX_CPP_AlignN(n) __attribute__ ((aligned (n)))
#define BX_CPP_AttrPrintf(formatArg, firstArg) \
__attribute__ ((format (printf, formatArg, firstArg)))
#define BX_CPP_AttrNoReturn() __attribute__ ((noreturn))
#else
#define BX_CPP_AlignN(n) /* not supported */
#define BX_CPP_AlignN(n) /* Not supported. */
#define BX_CPP_AttrPrintf(formatArg, firstArg) /* Not supported. */
#define BX_CPP_AttrNoReturn() /* Not supported. */
#endif
#define BX_DEBUGGER 0

2
bochs/configure vendored
View File

@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in Id: configure.in,v 1.147 2002/10/03 21:03:16 bdenney Exp .
# From configure.in Id: configure.in,v 1.148 2002/10/05 12:07:51 bdenney Exp .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.53.
#

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: ctrl_xfer32.cc,v 1.21 2002-09-29 15:06:58 sshwarts Exp $
// $Id: ctrl_xfer32.cc,v 1.22 2002-10-06 14:16:23 kevinlawton Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -301,7 +301,6 @@ BailBigRSP("CALL_Ed");
if (protected_mode()) {
if (op1_32 >
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.limit_scaled) {
BX_DEBUG(("call_ev: EIP out of CS limits! at %s:%d"));
exception(BX_GP_EXCEPTION, 0, 0);
}
}