]> git.sur5r.net Git - cc65/blobdiff - src/cc65/segments.c
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / src / cc65 / segments.c
index 57f1a80479f7f39243f1a43c8821d461a2515381..cdbd05e39b7a804290ba7b4a66a3108766c47f30 100644 (file)
@@ -1,15 +1,15 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                               segments.c                                 */
+/*                                segments.c                                 */
 /*                                                                           */
-/*                  Lightweight segment management stuff                    */
+/*                   Lightweight segment management stuff                    */
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2001      Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2001-2009, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -56,7 +56,7 @@
 
 
 /*****************************************************************************/
-/*                                  Data                                    */
+/*                                   Data                                    */
 /*****************************************************************************/
 
 
@@ -80,7 +80,7 @@ static Collection SegmentStack = STATIC_COLLECTION_INITIALIZER;
 
 
 /*****************************************************************************/
-/*                                  Code                                    */
+/*                                   Code                                    */
 /*****************************************************************************/
 
 
@@ -143,12 +143,12 @@ static Segments* NewSegments (SymEntry* Func)
     Segments* S = xmalloc (sizeof (Segments));
 
     /* Initialize the fields */
-    S->Text    = NewTextSeg (Func);
-    S->Code            = NewCodeSeg (GetSegName (SEG_CODE), Func);
-    S->Data            = NewDataSeg (GetSegName (SEG_DATA), Func);
-    S->ROData          = NewDataSeg (GetSegName (SEG_RODATA), Func);
-    S->BSS             = NewDataSeg (GetSegName (SEG_BSS), Func);
-    S->CurDSeg         = SEG_DATA;
+    S->Text     = NewTextSeg (Func);
+    S->Code     = NewCodeSeg (GetSegName (SEG_CODE), Func);
+    S->Data     = NewDataSeg (GetSegName (SEG_DATA), Func);
+    S->ROData   = NewDataSeg (GetSegName (SEG_RODATA), Func);
+    S->BSS      = NewDataSeg (GetSegName (SEG_BSS), Func);
+    S->CurDSeg  = SEG_DATA;
 
     /* Return the new struct */
     return S;
@@ -183,6 +183,14 @@ void PopSegments (void)
 
 
 
+void CreateGlobalSegments (void)
+/* Create the global segments and remember them in GS */
+{
+    GS = PushSegments (0);
+}
+
+
+
 void UseDataSeg (segment_t DSeg)
 /* For the current segment list, use the data segment DSeg */
 {
@@ -200,12 +208,12 @@ struct DataSeg* GetDataSeg (void)
 {
     PRECONDITION (CS != 0);
     switch (CS->CurDSeg) {
-       case SEG_BSS:     return CS->BSS;
-       case SEG_DATA:    return CS->Data;
-       case SEG_RODATA:  return CS->ROData;
-       default:
-           FAIL ("Invalid data segment");
-           return 0;
+        case SEG_BSS:     return CS->BSS;
+        case SEG_DATA:    return CS->Data;
+        case SEG_RODATA:  return CS->ROData;
+        default:
+            FAIL ("Invalid data segment");
+            return 0;
     }
 }
 
@@ -272,25 +280,25 @@ void RemoveGlobalCode (void)
 
 
 
-void OutputSegments (const Segments* S, FILE* F)
-/* Output the given segments to the file */
+void OutputSegments (const Segments* S)
+/* Output the given segments to the output file */
 {
     /* Output the function prologue if the segments came from a function */
-    CS_OutputPrologue (S->Code, F);
+    CS_OutputPrologue (S->Code);
 
     /* Output the text segment */
-    TS_Output (S->Text, F);
+    TS_Output (S->Text);
 
     /* Output the three data segments */
-    DS_Output (S->Data, F);
-    DS_Output (S->ROData, F);
-    DS_Output (S->BSS, F);
+    DS_Output (S->Data);
+    DS_Output (S->ROData);
+    DS_Output (S->BSS);
 
     /* Output the code segment */
-    CS_Output (S->Code, F);
+    CS_Output (S->Code);
 
     /* Output the code segment epiloque */
-    CS_OutputEpilogue (S->Code, F);
+    CS_OutputEpilogue (S->Code);
 }