From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 609 invoked by alias); 10 Dec 2001 03:07:06 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 587 invoked from network); 10 Dec 2001 03:07:05 -0000 Received: from unknown (HELO zwingli.cygnus.com) (208.245.165.35) by sources.redhat.com with SMTP; 10 Dec 2001 03:07:05 -0000 Received: by zwingli.cygnus.com (Postfix, from userid 442) id DA83F5E9D8; Sun, 9 Dec 2001 22:08:22 -0500 (EST) To: fnf@redhat.com Cc: gdb-patches@sources.redhat.com Subject: Re: RFA: Add missing type flag test macros References: <200112090757.fB97vGa17330@fishpond.ninemoons.com> From: Jim Blandy Date: Sun, 09 Dec 2001 19:07:00 -0000 In-Reply-To: Fred Fish's message of Sun, 9 Dec 2001 00:57:16 -0700 (MST) Message-ID: X-Mailer: Gnus v5.3/Emacs 19.34 X-SW-Source: 2001-12/txt/msg00261.txt.bz2 All this sounds good to me. I think `indent' is going to wipe out your nice indentation of the #definitions. Fred Fish writes: > Currently gdbtypes.h defines some macros to test only some of the > possible bits in type's flag member, such as the TYPE_FLAG_UNSIGNED, > where it defines a macro TYPE_UNSIGNED(t) to test if this bit is set. > So code that wants to test for this bit set, uses TYPE_UNSIGNED(t) > rather than something like "type->flags & TYPE_FLAG_UNSIGNED". > > However there are other flag bits, such as TYPE_FLAG_STUB, which have > no test macros, so the only choice is to write explicit tests of the > bit into the code > > This is inconsistent, so I've added macros for each defined flag bit. > In a future patch I'll fix all the locations that access the bits to > use these macros, and also fix the locations that should be using the > currently defined macros. > > In addition, and this is subject to revision if there are objections > to this style, I've moved the test macros to be next to the > definitions of the bits, so as to help prevent future situations like > this where new bits are defined but the corresponding macros to test > them are not. > > Lastly, I fixed a typo and tweaked some whitespace to make the > bit definitions and macros line up vertically. > > -Fred > > 2001-12-08 Fred Fish > > * gdbtypes.h (TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_CONST, > TYPE_VOLATILE, TYPE_INCOMPLETE): Move macros that test the > bits to location in file where the bits are defined. > (TYPE_STUB, TYPE_TARGET_STUB, TYPE_STATIC, TYPE_PROTOTYPED, > TYPE_CODE_SPACE, TYPE_DATA_SPACE): New test macros. > > Index: gdbtypes.h > =================================================================== > RCS file: /cvs/src/src/gdb/gdbtypes.h,v > retrieving revision 1.20 > diff -u -p -r1.20 gdbtypes.h > --- gdbtypes.h 2001/12/09 07:29:46 1.20 > +++ gdbtypes.h 2001/12/09 07:52:33 > @@ -142,24 +142,27 @@ enum type_code > > #define TYPE_CODE_CLASS TYPE_CODE_STRUCT > > -/* Some bits for the type's flags word. */ > +/* Some bits for the type's flags word, and macros to test them. */ > > /* Unsigned integer type. If this is not set for a TYPE_CODE_INT, the > type is signed (unless TYPE_FLAG_NOSIGN (below) is set). */ > > #define TYPE_FLAG_UNSIGNED (1 << 0) > +#define TYPE_UNSIGNED(t) ((t)->flags & TYPE_FLAG_UNSIGNED) > > /* No sign for this type. In C++, "char", "signed char", and "unsigned > char" are distinct types; so we need an extra flag to indicate the > absence of a sign! */ > > #define TYPE_FLAG_NOSIGN (1 << 1) > +#define TYPE_NOSIGN(t) ((t)->flags & TYPE_FLAG_NOSIGN) > > /* This appears in a type's flags word if it is a stub type (e.g., if > someone referenced a type that wasn't defined in a source file > via (struct sir_not_appearing_in_this_film *)). */ > > #define TYPE_FLAG_STUB (1 << 2) > +#define TYPE_STUB(t) ((t)->flags & TYPE_FLAG_STUB) > > /* The target type of this type is a stub type, and this type needs to > be updated if it gets un-stubbed in check_typedef. > @@ -167,7 +170,8 @@ enum type_code > gets set based on the TYPE_LENGTH of the target type. > Also, set for TYPE_CODE_TYPEDEF. */ > > -#define TYPE_FLAG_TARGET_STUB (1 << 3) > +#define TYPE_FLAG_TARGET_STUB (1 << 3) > +#define TYPE_TARGET_STUB(t) ((t)->flags & TYPE_FLAG_TARGET_STUB) > > /* Static type. If this is set, the corresponding type had > * a static modifier. > @@ -175,26 +179,30 @@ enum type_code > * are indicated by other means (bitpos == -1) > */ > > -#define TYPE_FLAG_STATIC (1 << 4) > +#define TYPE_FLAG_STATIC (1 << 4) > +#define TYPE_STATIC(t) ((t)->flags & TYPE_FLAG_STATIC) > > /* Constant type. If this is set, the corresponding type has a > * const modifier. > */ > > -#define TYPE_FLAG_CONST (1 << 5) > +#define TYPE_FLAG_CONST (1 << 5) > +#define TYPE_CONST(t) ((t)->flags & TYPE_FLAG_CONST) > > /* Volatile type. If this is set, the corresponding type has a > * volatile modifier. > */ > > -#define TYPE_FLAG_VOLATILE (1 << 6) > +#define TYPE_FLAG_VOLATILE (1 << 6) > +#define TYPE_VOLATILE(t) ((t)->flags & TYPE_FLAG_VOLATILE) > > > /* This is a function type which appears to have a prototype. We need this > for function calls in order to tell us if it's necessary to coerce the args, > or to just do the standard conversions. This is used with a short field. */ > > -#define TYPE_FLAG_PROTOTYPED (1 << 7) > +#define TYPE_FLAG_PROTOTYPED (1 << 7) > +#define TYPE_PROTOTYPED(t) ((t)->flags & TYPE_FLAG_PROTOTYPED) > > /* This flag is used to indicate that processing for this type > is incomplete. > @@ -204,7 +212,8 @@ enum type_code > info; the incomplete type has to be marked so that the class and > the method can be assigned correct types.) */ > > -#define TYPE_FLAG_INCOMPLETE (1 << 8) > +#define TYPE_FLAG_INCOMPLETE (1 << 8) > +#define TYPE_INCOMPLETE(t) ((t)->flags & TYPE_FLAG_INCOMPLETE) > > /* Instruction-space delimited type. This is for Harvard architectures > which have separate instruction and data address spaces (and perhaps > @@ -225,15 +234,19 @@ enum type_code > If neither flag is set, the default space for functions / methods > is instruction space, and for data objects is data memory. */ > > -#define TYPE_FLAG_CODE_SPACE (1 << 9) > -#define TYPE_FLAG_DATA_SPACE (1 << 10) > +#define TYPE_FLAG_CODE_SPACE (1 << 9) > +#define TYPE_CODE_SPACE(t) ((t)->flags & TYPE_FLAG_CODE_SPACE) > > +#define TYPE_FLAG_DATA_SPACE (1 << 10) > +#define TYPE_DATA_SPACE(t) ((t)->flags & TYPE_FLAG_DATA_SPACE) > + > /* FIXME: Kludge to mark a varargs function type for C++ member > function argument processing. Currently only used in dwarf2read.c, > but put it here so we won't accidentally overload the bit with > another flag. */ > > -#define TYPE_FLAG_VARARGS (1 << 11) > +#define TYPE_FLAG_VARARGS (1 << 11) > +#define TYPE_VARARGS(t) ((t)->flags & TYPE_FLAG_VARARGS) > > struct type > { > @@ -731,12 +744,7 @@ extern void allocate_cplus_struct_type ( > #define TYPE_LENGTH(thistype) (thistype)->length > #define TYPE_OBJFILE(thistype) (thistype)->objfile > #define TYPE_FLAGS(thistype) (thistype)->flags > -#define TYPE_UNSIGNED(thistype) ((thistype)->flags & TYPE_FLAG_UNSIGNED) > -#define TYPE_NOSIGN(thistype) ((thistype)->flags & TYPE_FLAG_NOSIGN) > -#define TYPE_CONST(thistype) ((thistype)->flags & TYPE_FLAG_CONST) > -#define TYPE_VOLATILE(thistype) ((thistype)->flags & TYPE_FLAG_VOLATILE) > -#define TYPE_INCOMPLETE(thistype) ((thistype)->flags & TYPE_FLAG_INCOMPLETE) > -/* Note that TYPE_CODE can be TYPE_CODE_TYPEDEF, so if you wan the real > +/* Note that TYPE_CODE can be TYPE_CODE_TYPEDEF, so if you want the real > type, you need to do TYPE_CODE (check_type (this_type)). */ > #define TYPE_CODE(thistype) (thistype)->code > #define TYPE_NFIELDS(thistype) (thistype)->nfields >