From: uz Date: Tue, 17 Aug 2010 20:47:27 +0000 (+0000) Subject: Renamed the defines in symdefs.h to something more meaningful. They were named X-Git-Tag: V2.13.3~639 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=112ae0e3db511ddd92e769c11328646ebe2a6240;p=cc65 Renamed the defines in symdefs.h to something more meaningful. They were named EXP_xxx for historic reasons, but SYM_ does make much more sense now. git-svn-id: svn://svn.cc65.org/cc65/trunk@4812 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/ar65/library.c b/src/ar65/library.c index 6f73816cd..1214f2343 100644 --- a/src/ar65/library.c +++ b/src/ar65/library.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2003 Ullrich von Bassewitz */ -/* Römerstraße 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ +/* (C) 1998-2010, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -411,17 +411,17 @@ static void LibCheckExports (ObjData* O) const char* Name; /* Get the export tag and skip the address size */ - unsigned char Type = *Exports++; + unsigned Type = GetVar (&Exports); ++Exports; /* condes decls may follow */ - Exports += GET_EXP_CONDES_COUNT (Type); + Exports += SYM_GET_CONDES_COUNT (Type); /* Next thing is index of name of symbol */ Name = GetObjString (O, GetVar (&Exports)); /* Skip value of symbol */ - if (Type & EXP_EXPR) { + if (SYM_IS_EXPR (Type)) { /* Expression tree */ SkipExpr (&Exports); } else { diff --git a/src/ca65/symentry.c b/src/ca65/symentry.c index 0603f16b5..b957c0a67 100644 --- a/src/ca65/symentry.c +++ b/src/ca65/symentry.c @@ -37,6 +37,7 @@ /* common */ #include "addrsize.h" +#include "symdefs.h" #include "xmalloc.h" /* ca65 */ @@ -606,7 +607,7 @@ void SymImportFromGlobal (SymEntry* S) -int SymIsConst (SymEntry* S, long* Val) +int SymIsConst (const SymEntry* S, long* Val) /* Return true if the given symbol has a constant value. If Val is not NULL * and the symbol has a constant value, store it's value there. */ @@ -673,3 +674,21 @@ unsigned GetSymImportId (const SymEntry* S) +unsigned GetSymInfoFlags (const SymEntry* S, long* ConstVal) +/* Return a set of flags used when writing symbol information into a file. + * If the SYM_CONST bit is set, ConstVal will contain the constant value + * of the symbol. The result does not include the condes count. + * See common/symdefs.h for more information. + */ +{ + /* Setup info flags */ + unsigned Flags = 0; + Flags |= SymIsConst (S, ConstVal)? SYM_CONST : SYM_EXPR; + Flags |= (S->Flags & SF_LABEL)? SYM_LABEL : SYM_EQUATE; + + /* Return the result */ + return Flags; +} + + + diff --git a/src/ca65/symentry.h b/src/ca65/symentry.h index 01a4af2fb..633b3b457 100644 --- a/src/ca65/symentry.h +++ b/src/ca65/symentry.h @@ -246,7 +246,7 @@ INLINE int SymIsVar (const SymEntry* S) # define SymIsVar(S) (((S)->Flags & SF_VAR) != 0) #endif -int SymIsConst (SymEntry* Sym, long* Val); +int SymIsConst (const SymEntry* Sym, long* Val); /* Return true if the given symbol has a constant value. If Val is not NULL * and the symbol has a constant value, store it's value there. */ @@ -338,6 +338,13 @@ long GetSymVal (SymEntry* Sym); unsigned GetSymImportId (const SymEntry* Sym); /* Return the import id for the given symbol */ +unsigned GetSymInfoFlags (const SymEntry* Sym, long* ConstVal); +/* Return a set of flags used when writing symbol information into a file. + * If the SYM_CONST bit is set, ConstVal will contain the constant value + * of the symbol. The result does not include the condes count. + * See common/symdefs.h for more information. + */ + #if defined(HAVE_INLINE) INLINE const FilePos* GetSymPos (const SymEntry* S) /* Return the position of first occurence in the source for the given symbol */ diff --git a/src/ca65/symtab.c b/src/ca65/symtab.c index aed5c4a44..8356d34b5 100644 --- a/src/ca65/symtab.c +++ b/src/ca65/symtab.c @@ -717,38 +717,36 @@ void WriteExports (void) while (S) { if ((S->Flags & (SF_UNUSED | SF_EXPORT)) == SF_EXPORT) { + /* Get the expression bits and the value */ long ConstVal; - - /* Get the expression bits */ - unsigned char ExprMask = SymIsConst (S, &ConstVal)? EXP_CONST : EXP_EXPR; - ExprMask |= (S->Flags & SF_LABEL)? EXP_LABEL : EXP_EQUATE; + unsigned ExprMask = GetSymInfoFlags (S, &ConstVal); /* Count the number of ConDes types */ for (Type = 0; Type < CD_TYPE_COUNT; ++Type) { - if (S->ConDesPrio[Type] != CD_PRIO_NONE) { - INC_EXP_CONDES_COUNT (ExprMask); - } + if (S->ConDesPrio[Type] != CD_PRIO_NONE) { + SYM_INC_CONDES_COUNT (ExprMask); + } } /* Write the type and the export size */ - ObjWrite8 (ExprMask); + ObjWriteVar (ExprMask); ObjWrite8 (S->ExportSize); /* Write any ConDes declarations */ - if (GET_EXP_CONDES_COUNT (ExprMask) > 0) { - for (Type = 0; Type < CD_TYPE_COUNT; ++Type) { - unsigned char Prio = S->ConDesPrio[Type]; - if (Prio != CD_PRIO_NONE) { - ObjWrite8 (CD_BUILD (Type, Prio)); - } - } + if (SYM_GET_CONDES_COUNT (ExprMask) > 0) { + for (Type = 0; Type < CD_TYPE_COUNT; ++Type) { + unsigned char Prio = S->ConDesPrio[Type]; + if (Prio != CD_PRIO_NONE) { + ObjWrite8 (CD_BUILD (Type, Prio)); + } + } } /* Write the name */ ObjWriteVar (S->Name); /* Write the value */ - if ((ExprMask & EXP_MASK_VAL) == EXP_CONST) { + if (SYM_IS_CONST (ExprMask)) { /* Constant value */ ObjWrite32 (ConstVal); } else { @@ -798,14 +796,12 @@ void WriteDbgSyms (void) while (S) { if ((S->Flags & SF_DBGINFOMASK) == SF_DBGINFOVAL) { + /* Get the expression bits and the value */ long ConstVal; - - /* Get the expression bits */ - unsigned char ExprMask = (SymIsConst (S, &ConstVal))? EXP_CONST : EXP_EXPR; - ExprMask |= (S->Flags & SF_LABEL)? EXP_LABEL : EXP_EQUATE; + unsigned ExprMask = GetSymInfoFlags (S, &ConstVal); /* Write the type */ - ObjWrite8 (ExprMask); + ObjWriteVar (ExprMask); /* Write the address size */ ObjWrite8 (S->AddrSize); @@ -814,7 +810,7 @@ void WriteDbgSyms (void) ObjWriteVar (S->Name); /* Write the value */ - if ((ExprMask & EXP_MASK_VAL) == EXP_CONST) { + if (SYM_IS_CONST (ExprMask)) { /* Constant value */ ObjWrite32 (ConstVal); } else { diff --git a/src/common/symdefs.h b/src/common/symdefs.h index b0d4bf643..6ffb4515e 100644 --- a/src/common/symdefs.h +++ b/src/common/symdefs.h @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2003 Ullrich von Bassewitz */ -/* Römerstraße 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ +/* (C) 1998-2010, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -49,33 +49,33 @@ /* Number of module constructor/destructor declarations for an export */ -#define EXP_CONDES_MASK 0x07 +#define SYM_CONDES_MASK 0x07U -#define IS_EXP_CONDES(x) (((x) & EXP_CONDES_MASK) != 0) -#define GET_EXP_CONDES_COUNT(x) ((x) & EXP_CONDES_MASK) -#define INC_EXP_CONDES_COUNT(x) ((x)++) +#define SYM_IS_CONDES(x) (((x) & SYM_CONDES_MASK) != 0) +#define SYM_GET_CONDES_COUNT(x) ((x) & SYM_CONDES_MASK) +#define SYM_INC_CONDES_COUNT(x) ((x)++) -/* Export value type */ -#define EXP_CONST 0x00 /* Mask bit for const values */ -#define EXP_EXPR 0x10 /* Mask bit for expr values */ -#define EXP_MASK_VAL 0x10 /* Value mask */ +/* Symbol value type */ +#define SYM_CONST 0x00U /* Mask bit for const values */ +#define SYM_EXPR 0x10U /* Mask bit for expr values */ +#define SYM_MASK_VAL 0x10U /* Value mask */ -#define IS_EXP_CONST(x) (((x) & EXP_MASK_VAL) == EXP_CONST) -#define IS_EXP_EXPR(x) (((x) & EXP_MASK_VAL) == EXP_EXPR) +#define SYM_IS_CONST(x) (((x) & SYM_MASK_VAL) == SYM_CONST) +#define SYM_IS_EXPR(x) (((x) & SYM_MASK_VAL) == SYM_EXPR) -/* Export usage */ -#define EXP_EQUATE 0x00 /* Mask bit for an equate */ -#define EXP_LABEL 0x20 /* Mask bit for a label */ -#define EXP_MASK_LABEL 0x20 /* Value mask */ +/* Symbol usage */ +#define SYM_EQUATE 0x00U /* Mask bit for an equate */ +#define SYM_LABEL 0x20U /* Mask bit for a label */ +#define SYM_MASK_LABEL 0x20U /* Value mask */ -#define IS_EXP_EQUATE(x) (((x) & EXP_MASK_LABEL) == EXP_EQUATE) -#define IS_EXP_LABEL(x) (((x) & EXP_MASK_LABEL) == EXP_LABEL) +#define SYM_IS_EQUATE(x) (((x) & SYM_MASK_LABEL) == SYM_EQUATE) +#define SYM_IS_LABEL(x) (((x) & SYM_MASK_LABEL) == SYM_LABEL) /* End of symdefs.h */ #endif - + diff --git a/src/ld65/dbgsyms.c b/src/ld65/dbgsyms.c index a06145aa9..071ccdc64 100644 --- a/src/ld65/dbgsyms.c +++ b/src/ld65/dbgsyms.c @@ -142,7 +142,7 @@ DbgSym* ReadDbgSym (FILE* F, ObjData* O) /* Read a debug symbol from a file, insert and return it */ { /* Read the type and address size */ - unsigned char Type = Read8 (F); + unsigned char Type = ReadVar (F); unsigned char AddrSize = Read8 (F); /* Create a new debug symbol */ @@ -152,7 +152,7 @@ DbgSym* ReadDbgSym (FILE* F, ObjData* O) D->Name = MakeGlobalStringId (O, ReadVar (F)); /* Read the value */ - if (IS_EXP_EXPR (D->Type)) { + if (SYM_IS_EXPR (D->Type)) { D->Expr = ReadExpr (F, O); } else { D->Expr = LiteralExpr (Read32 (F), O); @@ -221,7 +221,7 @@ void PrintDbgSyms (ObjData* O, FILE* F) GetString (D->Name), Val, AddrSizeToStr (D->AddrSize), - IS_EXP_LABEL (D->Type)? "label" : "equate"); + SYM_IS_LABEL (D->Type)? "label" : "equate"); /* Insert the symbol into the table */ InsertDbgSym (D, Val); @@ -245,7 +245,7 @@ void PrintDbgSymLabels (ObjData* O, FILE* F) DbgSym* D = CollAt (&O->DbgSyms, I); /* Emit this symbol only if it is a label (ignore equates) */ - if (IS_EXP_EQUATE (D->Type)) { + if (SYM_IS_EQUATE (D->Type)) { continue; } diff --git a/src/ld65/exports.c b/src/ld65/exports.c index a5415bf82..b97130899 100644 --- a/src/ld65/exports.c +++ b/src/ld65/exports.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1998-2009, Ullrich von Bassewitz */ +/* (C) 1998-2010, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -326,7 +326,7 @@ void InsertExport (Export* E) E->Flags |= EXP_INLIST; /* Insert the export into any condes tables if needed */ - if (IS_EXP_CONDES (E->Type)) { + if (SYM_IS_CONDES (E->Type)) { ConDesAddExport (E); } @@ -395,7 +395,7 @@ Export* ReadExport (FILE* F, ObjData* O) Export* E; /* Read the type */ - unsigned char Type = Read8 (F); + unsigned char Type = ReadVar (F); /* Read the address size */ unsigned char AddrSize = Read8 (F); @@ -404,7 +404,7 @@ Export* ReadExport (FILE* F, ObjData* O) E = NewExport (Type, AddrSize, INVALID_STRING_ID, O); /* Read the constructor/destructor decls if we have any */ - ConDesCount = GET_EXP_CONDES_COUNT (Type); + ConDesCount = SYM_GET_CONDES_COUNT (Type); if (ConDesCount > 0) { unsigned char ConDes[CD_TYPE_COUNT]; @@ -430,7 +430,7 @@ Export* ReadExport (FILE* F, ObjData* O) E->Name = MakeGlobalStringId (O, ReadVar (F)); /* Read the value */ - if (IS_EXP_EXPR (Type)) { + if (SYM_IS_EXPR (Type)) { E->Expr = ReadExpr (F, O); } else { E->Expr = LiteralExpr (Read32 (F), O); @@ -449,7 +449,7 @@ Export* CreateConstExport (unsigned Name, long Value) /* Create an export for a literal date */ { /* Create a new export */ - Export* E = NewExport (EXP_CONST | EXP_EQUATE, ADDR_SIZE_ABS, Name, 0); + Export* E = NewExport (SYM_CONST | SYM_EQUATE, ADDR_SIZE_ABS, Name, 0); /* Assign the value */ E->Expr = LiteralExpr (Value, 0); @@ -467,7 +467,7 @@ Export* CreateMemoryExport (unsigned Name, Memory* Mem, unsigned long Offs) /* Create an relative export for a memory area offset */ { /* Create a new export */ - Export* E = NewExport (EXP_EXPR | EXP_LABEL, ADDR_SIZE_ABS, Name, 0); + Export* E = NewExport (SYM_EXPR | SYM_LABEL, ADDR_SIZE_ABS, Name, 0); /* Assign the value */ E->Expr = MemoryExpr (Mem, Offs, 0); @@ -485,7 +485,7 @@ Export* CreateSegmentExport (unsigned Name, Segment* Seg, unsigned long Offs) /* Create a relative export to a segment */ { /* Create a new export */ - Export* E = NewExport (EXP_EXPR | EXP_LABEL, Seg->AddrSize, Name, 0); + Export* E = NewExport (SYM_EXPR | SYM_LABEL, Seg->AddrSize, Name, 0); /* Assign the value */ E->Expr = SegmentExpr (Seg, Offs, 0); @@ -503,7 +503,7 @@ Export* CreateSectionExport (unsigned Name, Section* Sec, unsigned long Offs) /* Create a relative export to a section */ { /* Create a new export */ - Export* E = NewExport (EXP_EXPR | EXP_LABEL, Sec->AddrSize, Name, 0); + Export* E = NewExport (SYM_EXPR | SYM_LABEL, Sec->AddrSize, Name, 0); /* Assign the value */ E->Expr = SectionExpr (Sec, Offs, 0); @@ -762,15 +762,15 @@ void PrintExportMap (FILE* F) const Export* E = ExpPool [I]; /* Print unreferenced symbols only if explictly requested */ - if (VerboseMap || E->ImpCount > 0 || IS_EXP_CONDES (E->Type)) { + if (VerboseMap || E->ImpCount > 0 || SYM_IS_CONDES (E->Type)) { fprintf (F, "%-25s %06lX %c%c%c%c ", GetString (E->Name), GetExportVal (E), E->ImpCount? 'R' : ' ', - IS_EXP_LABEL (E->Type)? 'L' : 'E', + SYM_IS_LABEL (E->Type)? 'L' : 'E', GetAddrSizeCode (E->AddrSize), - IS_EXP_CONDES (E->Type)? 'I' : ' '); + SYM_IS_CONDES (E->Type)? 'I' : ' '); if (++Count == 2) { Count = 0; fprintf (F, "\n"); diff --git a/src/od65/dump.c b/src/od65/dump.c index 2db9b964d..8eb54f02c 100644 --- a/src/od65/dump.c +++ b/src/od65/dump.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 2002-2009, Ullrich von Bassewitz */ +/* (C) 2002-2010, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -174,16 +174,16 @@ static const char* GetExportFlags (unsigned Flags, const unsigned char* ConDes) /* Type of expression */ TypeDesc[0] = '\0'; - switch (Flags & EXP_MASK_VAL) { - case EXP_CONST: strcat (TypeDesc, "EXP_CONST"); break; - case EXP_EXPR: strcat (TypeDesc, "EXP_EXPR"); break; + switch (Flags & SYM_MASK_VAL) { + case SYM_CONST: strcat (TypeDesc, "SYM_CONST"); break; + case SYM_EXPR: strcat (TypeDesc, "SYM_EXPR"); break; } /* Constructor/destructor declarations */ T = TypeDesc + strlen (TypeDesc); - Count = GET_EXP_CONDES_COUNT (Flags); + Count = SYM_GET_CONDES_COUNT (Flags); if (Count > 0 && ConDes) { - T += sprintf (T, ",EXP_CONDES="); + T += sprintf (T, ",SYM_CONDES="); for (I = 0; I < Count; ++I) { unsigned Type = CD_GET_TYPE (ConDes[I]); unsigned Prio = CD_GET_PRIO (ConDes[I]); @@ -545,10 +545,10 @@ void DumpObjExports (FILE* F, unsigned long Offset) /* Read the data for one export */ unsigned char Type = Read8 (F); unsigned char AddrSize = Read8 (F); - ReadData (F, ConDes, GET_EXP_CONDES_COUNT (Type)); + ReadData (F, ConDes, SYM_GET_CONDES_COUNT (Type)); Name = GetString (&StrPool, ReadVar (F)); Len = strlen (Name); - if (IS_EXP_EXPR (Type)) { + if (SYM_IS_EXPR (Type)) { SkipExpr (F); HaveValue = 0; } else { @@ -621,7 +621,7 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset) unsigned char AddrSize = Read8 (F); const char* Name = GetString (&StrPool, ReadVar (F)); unsigned Len = strlen (Name); - if (IS_EXP_EXPR (Type)) { + if (SYM_IS_EXPR (Type)) { SkipExpr (F); HaveValue = 0; } else {