1 /*****************************************************************************/
5 /* Module constructor/destructor support */
9 /* (C) 2000 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@musoftware.de */
15 /* This software is provided 'as-is', without any expressed or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
32 /*****************************************************************************/
48 /*****************************************************************************/
50 /*****************************************************************************/
54 /* Struct describing one condes type */
55 typedef struct ConDesDesc ConDesDesc;
57 Collection ExpList; /* List of exported symbols */
58 char* Label; /* Name of table label */
59 char* SegName; /* Name of segment the table is in */
60 unsigned char Enable; /* Table enabled */
63 /* Array for all types */
64 static ConDesDesc ConDes[CD_TYPE_COUNT] = {
65 { STATIC_COLLECTION_INITIALIZER, 0, 0, 0 },
66 { STATIC_COLLECTION_INITIALIZER, 0, 0, 0 },
67 { STATIC_COLLECTION_INITIALIZER, 0, 0, 0 },
68 { STATIC_COLLECTION_INITIALIZER, 0, 0, 0 },
69 { STATIC_COLLECTION_INITIALIZER, 0, 0, 0 },
70 { STATIC_COLLECTION_INITIALIZER, 0, 0, 0 },
71 { STATIC_COLLECTION_INITIALIZER, 0, 0, 0 },
76 /*****************************************************************************/
78 /*****************************************************************************/
82 void ConDesAddExport (struct Export* E)
83 /* Add the given export to the list of constructors/destructor */
87 /* Insert the export into all tables for which declarations exist */
88 for (Type = 0; Type < CD_TYPE_COUNT; ++Type) {
89 unsigned Prio = E->ConDes[Type];
90 if (Prio != CD_PRIO_NONE) {
91 CollAppend (&ConDes[Type].ExpList, E);
98 void ConDesSetSegName (unsigned Type, const char* SegName)
99 /* Set the segment name where the table should go */
101 /* Check the parameters */
102 PRECONDITION (Type >= CD_TYPE_MIN && Type <= CD_TYPE_MAX && SegName != 0);
104 /* Setting the segment name twice is bad */
105 CHECK (ConDes[Type].SegName == 0);
108 ConDes[Type].SegName = xstrdup (SegName);
113 void ConDesSetLabel (unsigned Type, const char* Name)
114 /* Set the label for the given ConDes type */
116 /* Check the parameters */
117 PRECONDITION (Type >= CD_TYPE_MIN && Type <= CD_TYPE_MAX && Name != 0);
119 /* Setting the label twice is bad */
120 CHECK (ConDes[Type].Label == 0);
123 ConDes[Type].Label = xstrdup (Name);
128 const char* ConDesGetSegName (unsigned Type)
129 /* Return the segment name for the given ConDes type */
131 /* Check the parameters */
132 PRECONDITION (Type >= CD_TYPE_MIN && Type <= CD_TYPE_MAX);
134 /* Return the name */
135 return ConDes[Type].SegName;
140 const char* ConDesGetLabel (unsigned Type)
141 /* Return the label for the given ConDes type */
143 /* Check the parameters */
144 PRECONDITION (Type >= CD_TYPE_MIN && Type <= CD_TYPE_MAX);
146 /* Return the name */
147 return ConDes[Type].Label;
152 int ConDesHasSegName (unsigned Type)
153 /* Return true if a segment name is already defined for this ConDes type */
155 return (ConDesGetSegName(Type) != 0);
160 int ConDesHasLabel (unsigned Type)
161 /* Return true if a label is already defined for this ConDes type */
163 return (ConDesGetLabel(Type) != 0);
168 void ConDesCreate (void)
169 /* Create the condes tables if requested */
175 void ConDesDump (void)
176 /* Dump ConDes data to stdout for debugging */
179 for (Type = 0; Type < CD_TYPE_COUNT; ++Type) {
180 Collection* ExpList = &ConDes[Type].ExpList;
181 printf ("CONDES(%u): %u symbols\n", Type, CollCount (ExpList));