From: cuz Date: Thu, 2 Nov 2000 22:11:25 +0000 (+0000) Subject: Removed underlines from structure names. X-Git-Tag: V2.12.0~3098 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=18840117ec255797f7685ca82f493750a7812e35;p=cc65 Removed underlines from structure names. Moved the fragment type into its own module. git-svn-id: svn://svn.cc65.org/cc65/trunk@430 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/ld65/bin.c b/src/ld65/bin.c index 1a9aabbec..abc873e67 100644 --- a/src/ld65/bin.c +++ b/src/ld65/bin.c @@ -36,9 +36,11 @@ #include #include #include - -#include "../common/xmalloc.h" - + +/* common */ +#include "xmalloc.h" + +/* ld65 */ #include "global.h" #include "error.h" #include "fileio.h" @@ -91,7 +93,7 @@ void FreeBinDesc (BinDesc* D) /* Free a binary format descriptor */ { xfree (D); -} +} @@ -206,7 +208,7 @@ static int BinUnresolved (const char* Name, void* D) -void BinWriteTarget (BinDesc* D, struct File_* F) +void BinWriteTarget (BinDesc* D, struct File* F) /* Write a binary output file */ { Memory* M; diff --git a/src/ld65/config.h b/src/ld65/config.h index 2f5c8114b..b5e608245 100644 --- a/src/ld65/config.h +++ b/src/ld65/config.h @@ -49,52 +49,52 @@ /* File list entry */ -typedef struct File_ File; -struct File_ { +typedef struct File File; +struct File { File* Next; /* Pointer to next entry in list */ unsigned Flags; unsigned Format; /* Output format */ - struct Memory_* MemList; /* List of memory areas in this file */ - struct Memory_* MemLast; /* Last memory area in this file */ - char Name [1]; /* Name of file */ + struct Memory* MemList; /* List of memory areas in this file */ + struct Memory* MemLast; /* Last memory area in this file */ + char Name [1]; /* Name of file */ }; /* Segment list node. Needed because there are two lists (RUN & LOAD) */ -typedef struct MemListNode_ MemListNode; -struct MemListNode_ { - MemListNode* Next; /* Next entry */ - struct SegDesc_* Seg; /* Segment */ +typedef struct MemListNode MemListNode; +struct MemListNode { + MemListNode* Next; /* Next entry */ + struct SegDesc* Seg; /* Segment */ }; /* Memory list entry */ -typedef struct Memory_ Memory; -struct Memory_ { - Memory* Next; /* Pointer to next entry in list */ +typedef struct Memory Memory; +struct Memory { + Memory* Next; /* Pointer to next entry in list */ Memory* FNext; /* Next in file list */ unsigned Attr; /* Which values are valid? */ - unsigned Flags; /* Set of bitmapped flags */ + unsigned Flags; /* Set of bitmapped flags */ unsigned long Start; /* Start address */ unsigned long Size; /* Length of memory section */ unsigned long FillLevel; /* Actual fill level of segment */ unsigned char FillVal; /* Value used to fill rest of seg */ MemListNode* SegList; /* List of segments for this section */ MemListNode* SegLast; /* Last segment in this section */ - File* F; /* File that contains the entry */ - char Name [1]; /* Name of the memory section */ + File* F; /* File that contains the entry */ + char Name [1]; /* Name of the memory section */ }; /* Segment descriptor entry */ -typedef struct SegDesc_ SegDesc; -struct SegDesc_ { - SegDesc* Next; /* Pointer to next entry in list */ - Segment* Seg; /* Pointer to segment structure */ - unsigned Attr; /* Attributes for segment */ - unsigned Flags; /* Set of bitmapped flags */ - Memory* Load; /* Load memory section */ - Memory* Run; /* Run memory section */ +typedef struct SegDesc SegDesc; +struct SegDesc { + SegDesc* Next; /* Pointer to next entry in list */ + Segment* Seg; /* Pointer to segment structure */ + unsigned Attr; /* Attributes for segment */ + unsigned Flags; /* Set of bitmapped flags */ + Memory* Load; /* Load memory section */ + Memory* Run; /* Run memory section */ unsigned long Addr; /* Start address or offset into segment */ - unsigned char Align; /* Alignment if given */ - char Name [1]; /* Copy of name */ + unsigned char Align; /* Alignment if given */ + char Name [1]; /* Copy of name */ }; /* Segment list */ @@ -107,17 +107,17 @@ extern unsigned SegDescCount; /* Number of entries in list */ #define MF_RO 0x0004 /* Read only memory area */ /* Segment flags */ -#define SF_RO 0x0001 /* Read only segment */ -#define SF_BSS 0x0002 /* Segment is BSS style segment */ -#define SF_ZP 0x0004 /* Zeropage segment (o65 only) */ -#define SF_WPROT 0x0008 /* Write protected segment */ +#define SF_RO 0x0001 /* Read only segment */ +#define SF_BSS 0x0002 /* Segment is BSS style segment */ +#define SF_ZP 0x0004 /* Zeropage segment (o65 only) */ +#define SF_WPROT 0x0008 /* Write protected segment */ #define SF_DEFINE 0x0010 /* Define start and size */ -#define SF_ALIGN 0x0020 /* Align the segment */ -#define SF_OFFSET 0x0040 /* Segment has offset in memory */ -#define SF_START 0x0080 /* Segment has fixed start address */ +#define SF_ALIGN 0x0020 /* Align the segment */ +#define SF_OFFSET 0x0040 /* Segment has offset in memory */ +#define SF_START 0x0080 /* Segment has fixed start address */ #define SF_LOAD_AND_RUN 0x1000 /* LOAD and RUN given */ #define SF_RUN_DEF 0x2000 /* RUN symbols already defined */ -#define SF_LOAD_DEF 0x4000 /* LOAD symbols already defined */ +#define SF_LOAD_DEF 0x4000 /* LOAD symbols already defined */ @@ -145,3 +145,4 @@ void CfgWriteTarget (void); + diff --git a/src/ld65/dbgsyms.h b/src/ld65/dbgsyms.h index 1c65a5501..7f8e98f18 100644 --- a/src/ld65/dbgsyms.h +++ b/src/ld65/dbgsyms.h @@ -43,7 +43,7 @@ /* common */ #include "exprdefs.h" #include "filepos.h" - + /* ld65 */ #include "objdata.h" @@ -56,8 +56,8 @@ /* Debug symbol structure */ -typedef struct DbgSym_ DbgSym; -struct DbgSym_ { +typedef struct DbgSym DbgSym; +struct DbgSym { DbgSym* Next; /* Pool linear list link */ unsigned Flags; /* Generic flags */ ObjData* Obj; /* Object file that exports the name */ @@ -92,4 +92,5 @@ void PrintDbgSymLabels (ObjData* O, FILE* F); - + + diff --git a/src/ld65/exports.c b/src/ld65/exports.c index 971db1558..1b58fb84a 100644 --- a/src/ld65/exports.c +++ b/src/ld65/exports.c @@ -2,7 +2,7 @@ /* */ /* exports.c */ /* */ -/* Exports handing for the ld65 linker */ +/* Exports handling for the ld65 linker */ /* */ /* */ /* */ diff --git a/src/ld65/exports.h b/src/ld65/exports.h index 075c5ca48..df3567610 100644 --- a/src/ld65/exports.h +++ b/src/ld65/exports.h @@ -43,7 +43,7 @@ /* common */ #include "exprdefs.h" #include "filepos.h" - + /* ld65 */ #include "objdata.h" #include "config.h" @@ -57,29 +57,29 @@ /* Import symbol structure */ -typedef struct Import_ Import; -struct Import_ { - Import* Next; /* Single linked list */ - ObjData* Obj; /* Object file that imports the name */ - FilePos Pos; /* File position of reference */ +typedef struct Import Import; +struct Import { + Import* Next; /* Single linked list */ + ObjData* Obj; /* Object file that imports the name */ + FilePos Pos; /* File position of reference */ union { - struct Export_* Exp; /* Matching export for this import */ - const char* Name; /* Name if not in table */ + struct Export* Exp; /* Matching export for this import */ + const char* Name; /* Name if not in table */ } V; - unsigned char Type; /* Type of import */ + unsigned char Type; /* Type of import */ }; /* Export symbol structure */ -typedef struct Export_ Export; -struct Export_ { +typedef struct Export Export; +struct Export { Export* Next; /* Hash table link */ - unsigned Flags; /* Generic flags */ - ObjData* Obj; /* Object file that exports the name */ - unsigned ImpCount; /* How many imports for this symbol? */ - Import* ImpList; /* List of imports for this symbol */ - FilePos Pos; /* File position of definition */ + unsigned Flags; /* Generic flags */ + ObjData* Obj; /* Object file that exports the name */ + unsigned ImpCount; /* How many imports for this symbol? */ + Import* ImpList; /* List of imports for this symbol */ + FilePos Pos; /* File position of definition */ ExprNode* Expr; /* Expression (0 if not def'd) */ unsigned char Type; /* Type of export */ char* Name; /* Name - dynamically allocated */ @@ -157,7 +157,7 @@ void CircularRefError (const Export* E); /* Print an error about a circular reference using to define the given export */ - + /* End of exports.h */ #endif diff --git a/src/ld65/expr.h b/src/ld65/expr.h index 6305e9ee4..938ed3448 100644 --- a/src/ld65/expr.h +++ b/src/ld65/expr.h @@ -38,8 +38,10 @@ -#include "../common/exprdefs.h" - +/* common */ +#include "exprdefs.h" + +/* ld65 */ #include "objdata.h" #include "exports.h" #include "config.h" diff --git a/src/ld65/fragment.c b/src/ld65/fragment.c new file mode 100644 index 000000000..22b45f8e4 --- /dev/null +++ b/src/ld65/fragment.c @@ -0,0 +1,79 @@ +/*****************************************************************************/ +/* */ +/* fragment.c */ +/* */ +/* Code/data fragment routines */ +/* */ +/* */ +/* */ +/* (C) 1998-2000 Ullrich von Bassewitz */ +/* Wacholderweg 14 */ +/* D-70597 Stuttgart */ +/* EMail: uz@musoftware.de */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +/* common */ +#include "xmalloc.h" + +/* ld65 */ +#include "segments.h" +#include "fragment.h" + + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +Fragment* NewFragment (unsigned char Type, unsigned long Size, Section* S) +/* Create a new fragment and insert it into the section S */ +{ + /* Allocate memory */ + Fragment* F = xmalloc (sizeof (Fragment) - 1 + Size); /* Portable? */ + + /* Initialize the data */ + F->Next = 0; + F->Obj = 0; + F->Size = Size; + F->Expr = 0; + F->Type = Type; + + /* Insert the code fragment into the segment */ + if (S->FragRoot == 0) { + /* First fragment */ + S->FragRoot = F; + } else { + S->FragLast->Next = F; + } + S->FragLast = F; + S->Size += Size; + + /* Return the new fragment */ + return F; +} + + + diff --git a/src/ld65/fragment.h b/src/ld65/fragment.h new file mode 100644 index 000000000..cae0a1513 --- /dev/null +++ b/src/ld65/fragment.h @@ -0,0 +1,83 @@ +/*****************************************************************************/ +/* */ +/* fragment.h */ +/* */ +/* Code/data fragment routines */ +/* */ +/* */ +/* */ +/* (C) 1998-2000 Ullrich von Bassewitz */ +/* Wacholderweg 14 */ +/* D-70597 Stuttgart */ +/* EMail: uz@musoftware.de */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +#ifndef FRAGMENT_H +#define FRAGMENT_H + + + +/* common */ +#include "filepos.h" + + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + +/* Fragment structure */ +typedef struct Fragment Fragment; +struct Fragment { + Fragment* Next; /* Next fragment in list */ + struct ObjData* Obj; /* Source of fragment */ + unsigned long Size; /* Size of data/expression */ + struct ExprNode* Expr; /* Expression if FRAG_EXPR */ + FilePos Pos; /* File position in source */ + unsigned char Type; /* Type of fragment */ + unsigned char LitBuf [1]; /* Dynamically alloc'ed literal buffer */ +}; + + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +Fragment* NewFragment (unsigned char Type, unsigned long Size, struct Section* S); +/* Create a new fragment and insert it into the section S */ + + + +/* End of fragment.h */ + +#endif + + + + diff --git a/src/ld65/make/gcc.mak b/src/ld65/make/gcc.mak index 30a6be1a7..8db28cb6d 100644 --- a/src/ld65/make/gcc.mak +++ b/src/ld65/make/gcc.mak @@ -26,6 +26,7 @@ OBJS = bin.o \ expr.o \ extsyms.o \ fileio.o \ + fragment.o \ global.o \ library.o \ main.o \ diff --git a/src/ld65/make/watcom.mak b/src/ld65/make/watcom.mak index cd3515ccf..583d7335e 100644 --- a/src/ld65/make/watcom.mak +++ b/src/ld65/make/watcom.mak @@ -76,6 +76,7 @@ OBJS = bin.obj \ expr.obj \ extsyms.obj \ fileio.obj \ + fragment.obj \ global.obj \ library.obj \ main.obj \ diff --git a/src/ld65/objdata.h b/src/ld65/objdata.h index 5db0848d8..4813d809d 100644 --- a/src/ld65/objdata.h +++ b/src/ld65/objdata.h @@ -56,24 +56,24 @@ /* Internal structure holding object file data */ -typedef struct ObjData_ ObjData; -struct ObjData_ { +typedef struct ObjData ObjData; +struct ObjData { ObjData* Next; /* Linked list of all objects */ char* Name; /* Module name */ char* LibName; /* Name of library */ - ObjHeader Header; /* Header of file */ + ObjHeader Header; /* Header of file */ unsigned long Start; /* Start offset of data in library */ unsigned Flags; - unsigned FileCount; /* Input file count */ - char** Files; /* List of input files */ - unsigned SectionCount; /* Count of sections in this object */ - struct Section_** Sections; /* List of all sections */ - unsigned ExportCount; /* Count of exports */ - struct Export_** Exports; /* List of all exports */ - unsigned ImportCount; /* Count of imports */ - struct Import_** Imports; /* List of all imports */ - unsigned DbgSymCount; /* Count of debug symbols */ - struct DbgSym_** DbgSyms; /* List of debug symbols */ + unsigned FileCount; /* Input file count */ + char** Files; /* List of input files */ + unsigned SectionCount; /* Count of sections in this object */ + struct Section** Sections; /* List of all sections */ + unsigned ExportCount; /* Count of exports */ + struct Export** Exports; /* List of all exports */ + unsigned ImportCount; /* Count of imports */ + struct Import** Imports; /* List of all imports */ + unsigned DbgSymCount; /* Count of debug symbols */ + struct DbgSym** DbgSyms; /* List of debug symbols */ }; @@ -105,4 +105,4 @@ void FreeObjData (ObjData* O); - + diff --git a/src/ld65/segments.c b/src/ld65/segments.c index 775835818..ea3dec3cc 100644 --- a/src/ld65/segments.c +++ b/src/ld65/segments.c @@ -48,6 +48,7 @@ #include "error.h" #include "expr.h" #include "fileio.h" +#include "fragment.h" #include "global.h" #include "segments.h" @@ -59,20 +60,6 @@ -/* Fragment structure */ -typedef struct Fragment_ Fragment; -struct Fragment_ { - Fragment* Next; /* Next fragment in list */ - ObjData* Obj; /* Source of fragment */ - unsigned long Size; /* Size of data/expression */ - ExprNode* Expr; /* Expression if FRAG_EXPR */ - FilePos Pos; /* File position in source */ - unsigned char Type; /* Type of fragment */ - unsigned char LitBuf [1]; /* Dynamically alloc'ed literal buffer */ -}; - - - /* Hash table */ #define HASHTAB_SIZE 253 static Segment* HashTab [HASHTAB_SIZE]; @@ -88,35 +75,6 @@ static Segment* SegRoot = 0; /* List of all segments */ -static Fragment* NewFragment (unsigned char Type, unsigned long Size, Section* S) -/* Create a new fragment and insert it into the segment S */ -{ - /* Allocate memory */ - Fragment* F = xmalloc (sizeof (Fragment) - 1 + Size); /* Portable? */ - - /* Initialize the data */ - F->Next = 0; - F->Obj = 0; - F->Size = Size; - F->Expr = 0; - F->Type = Type; - - /* Insert the code fragment into the segment */ - if (S->FragRoot == 0) { - /* First fragment */ - S->FragRoot = F; - } else { - S->FragLast->Next = F; - } - S->FragLast = F; - S->Size += Size; - - /* Return the new fragment */ - return F; -} - - - static Segment* NewSegment (const char* Name, unsigned char Type) /* Create a new segment and initialize it */ { @@ -413,7 +371,7 @@ void SegDump (void) while (Count--) { if (I > 75) { printf ("\n "); - I = 3; + I = 3; } printf (" %02X", *Data++); I += 3; @@ -435,7 +393,7 @@ void SegDump (void) case FRAG_FILL: printf (" Empty space (%lu bytes)\n", F->Size); - break; + break; default: Internal ("Invalid fragment type: %02X", F->Type); diff --git a/src/ld65/segments.h b/src/ld65/segments.h index f69e9c2db..b045229ea 100644 --- a/src/ld65/segments.h +++ b/src/ld65/segments.h @@ -40,9 +40,8 @@ #include -#include "../common/exprdefs.h" - -#include "objdata.h" +/* common */ +#include "exprdefs.h" @@ -52,34 +51,32 @@ -/* Forward for the section structure (a section is a part of a segment) */ -typedef struct Section_ Section; - /* Segment structure */ -typedef struct Segment_ Segment; -struct Segment_ { - Segment* Next; /* Hash list */ - Segment* List; /* List of all segments */ - Section* SecRoot; /* Section list */ - Section* SecLast; /* Pointer to last section */ - unsigned long PC; /* PC were this segment is located */ - unsigned long Size; /* Size of data so far */ - ObjData* AlignObj; /* Module that requested the alignment */ - unsigned char Align; /* Alignment needed */ - unsigned char FillVal; /* Value to use for fill bytes */ - unsigned char Type; /* Type of segment */ - char Dumped; /* Did we dump this segment? */ +typedef struct Segment Segment; +struct Segment { + Segment* Next; /* Hash list */ + Segment* List; /* List of all segments */ + struct Section* SecRoot; /* Section list */ + struct Section* SecLast; /* Pointer to last section */ + unsigned long PC; /* PC were this segment is located */ + unsigned long Size; /* Size of data so far */ + struct ObjData* AlignObj; /* Module that requested the alignment */ + unsigned char Align; /* Alignment needed */ + unsigned char FillVal; /* Value to use for fill bytes */ + unsigned char Type; /* Type of segment */ + char Dumped; /* Did we dump this segment? */ char Name [1]; /* Name, dynamically allocated */ }; /* Section structure (a section is a part of a segment) */ -struct Section_ { - Section* Next; /* List of sections in a segment */ - Segment* Seg; /* Segment that contains the section */ - struct Fragment_* FragRoot; /* Fragment list */ - struct Fragment_* FragLast; /* Pointer to last fragment */ +typedef struct Section Section; +struct Section { + Section* Next; /* List of sections in a segment */ + Segment* Seg; /* Segment that contains the section */ + struct Fragment* FragRoot; /* Fragment list */ + struct Fragment* FragLast; /* Pointer to last fragment */ unsigned long Offs; /* Offset into the segment */ unsigned long Size; /* Size of the section */ unsigned char Align; /* Alignment */ @@ -97,10 +94,10 @@ struct Section_ { #define SEG_EXPR_TOO_COMPLEX 2 /* Expression too complex */ typedef unsigned (*SegWriteFunc) (ExprNode* E, /* The expression to write */ - int Signed, /* Signed expression? */ - unsigned Size, /* Size (=range) */ - unsigned long Offs, /* File offset */ - void* Data); /* Callers data */ + int Signed, /* Signed expression? */ + unsigned Size, /* Size (=range) */ + unsigned long Offs, /* File offset */ + void* Data); /* Callers data */ @@ -110,7 +107,7 @@ typedef unsigned (*SegWriteFunc) (ExprNode* E, /* The expression to write -Section* ReadSection (FILE* F, ObjData* O); +Section* ReadSection (FILE* F, struct ObjData* O); /* Read a section from a file */ Segment* SegFind (const char* Name); @@ -150,3 +147,4 @@ void CheckSegments (void); +