Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/tendra5/src/tools/tld/unit-entry.c – Rev 2

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/*** unit-entry.c --- Unit set table entry ADT.
32
 *
33
 ** Author: Steve Folkes <smf@hermes.mod.uk>
34
 *
35
 *** Commentary:
36
 *
37
 * This file implements the unit set table entry routines used by the TDF
38
 * linker.
39
 *
40
 *** Change Log:
41
 * $Log: unit-entry.c,v $
42
 * Revision 1.1.1.1  1998/01/17  15:57:20  release
43
 * First version to be checked into rolling release.
44
 *
45
 * Revision 1.3  1995/09/22  08:39:43  smf
46
 * Fixed problems with incomplete structures (to shut "tcc" up).
47
 * Fixed some problems in "name-key.c" (no real problems, but rewritten to
48
 * reduce the warnings that were output by "tcc" and "gcc").
49
 * Fixed bug CR95_354.tld-common-id-problem (library capsules could be loaded
50
 * more than once).
51
 *
52
 * Revision 1.2  1994/12/12  11:47:05  smf
53
 * Performing changes for 'CR94_178.sid+tld-update' - bringing in line with
54
 * OSSG C Coding Standards.
55
 *
56
 * Revision 1.1.1.1  1994/07/25  16:03:40  smf
57
 * Initial import of TDF linker 3.5 non shared files.
58
 *
59
**/
60
 
61
/****************************************************************************/
62
 
63
#include "unit-entry.h"
64
#include "debug.h"
65
#include "shape-entry.h"
66
#include "tdf.h"
67
 
68
#include "solve-cycles.h"
69
 
70
/*--------------------------------------------------------------------------*/
71
 
72
static void
73
unit_write PROTO_N ((unit, shapes, num_shapes, writer))
74
	   PROTO_T (UnitP       unit X
75
		    ShapeTableP shapes X
76
		    unsigned    num_shapes X
77
		    TDFWriterP  writer)
78
{
79
    unsigned  length = nstring_length (&(unit->contents));
80
    MapTableP table;
81
 
82
    if ((table = unit->map_table) != NIL (MapTableP)) {
83
	ShapeClosureT shape_closure;
84
 
85
	shape_closure.table  = table;
86
	shape_closure.writer = writer;
87
	debug_info_w_start_counts (num_shapes);
88
	tdf_write_int (writer, num_shapes);
89
	shape_table_iter (shapes, shape_entry_write_count,
90
			  (GenericP) &shape_closure);
91
	debug_info_w_start_maps (num_shapes);
92
	tdf_write_int (writer, num_shapes);
93
	shape_table_iter (shapes, shape_entry_write_links,
94
			  (GenericP) &shape_closure);
95
    } else {
96
	debug_info_w_start_counts ((unsigned) 0);
97
	tdf_write_int (writer, (unsigned) 0);
98
	debug_info_w_start_maps ((unsigned) 0);
99
	tdf_write_int (writer, (unsigned) 0);
100
    }
101
    debug_info_w_unit_body (length);
102
    tdf_write_int (writer, length);
103
    tdf_write_bytes (writer, &(unit->contents));
104
}
105
 
106
/*--------------------------------------------------------------------------*/
107
 
108
void
109
unit_set_contents PROTO_N ((unit, nstring))
110
		  PROTO_T (UnitP    unit X
111
			   NStringP nstring)
112
{
113
    nstring_assign (&(unit->contents), nstring);
114
}
115
 
116
MapTableP
117
unit_map_table PROTO_N ((unit))
118
	       PROTO_T (UnitP unit)
119
{
120
    return (unit->map_table);
121
}
122
 
123
UnitEntryP
124
unit_entry_create PROTO_N ((key, next, order))
125
		  PROTO_T (NStringP   key X
126
			   UnitEntryP next X
127
			   unsigned   order)
128
{
129
    UnitEntryP entry = ALLOCATE (UnitEntryT);
130
 
131
    entry->next  = next;
132
    entry->order = order;
133
    nstring_copy (&(entry->key), key);
134
    entry->head  = NIL (UnitP);
135
    entry->tail  = &(entry->head);
136
    return (entry);
137
}
138
 
139
UnitEntryP
140
unit_entry_next PROTO_N ((entry))
141
		PROTO_T (UnitEntryP entry)
142
{
143
    return (entry->next);
144
}
145
 
146
NStringP
147
unit_entry_key PROTO_N ((entry))
148
	       PROTO_T (UnitEntryP entry)
149
{
150
    return (&(entry->key));
151
}
152
 
153
unsigned
154
unit_entry_order PROTO_N ((entry))
155
		 PROTO_T (UnitEntryP entry)
156
{
157
    return (entry->order);
158
}
159
 
160
UnitP
161
unit_entry_add_unit PROTO_N ((entry, num_counts))
162
		    PROTO_T (UnitEntryP entry X
163
			     unsigned   num_counts)
164
{
165
    UnitP unit = ALLOCATE (UnitT);
166
 
167
    unit->next      = NIL (UnitP);
168
    unit->map_table = ((num_counts != 0) ?
169
		       map_table_create () : NIL (MapTableP));
170
    *(entry->tail)  = unit;
171
    entry->tail     = &(unit->next);
172
    return (unit);
173
}
174
 
175
/*--------------------------------------------------------------------------*/
176
 
177
void
178
unit_entry_do_count PROTO_N ((entry, gclosure))
179
		    PROTO_T (UnitEntryP entry X
180
			     GenericP   gclosure)
181
{
182
    UnitSetClosureP closure = (UnitSetClosureP) gclosure;
183
    UnitP           unit;
184
 
185
    if ((unit = entry->head) != NIL (UnitP)) {
186
	while (unit) {
187
	    MapTableP table;
188
 
189
	    if ((table = unit->map_table) != NIL (MapTableP)) {
190
		map_table_iter (table, map_entry_check_non_empty,
191
				(GenericP) closure->shapes);
192
	    }
193
	    unit = unit->next;
194
	}
195
	closure->num_unit_sets ++;
196
    }
197
}
198
 
199
void
200
unit_entry_write_unit_set PROTO_N ((entry, tld_entry, writer))
201
			  PROTO_T (UnitEntryP entry X
202
				   UnitEntryP tld_entry X
203
				   TDFWriterP writer)
204
{
205
    if ((entry->head) || (entry == tld_entry)) {
206
	NStringP key = unit_entry_key (entry);
207
 
208
	debug_info_w_unit_dec (key);
209
	tdf_write_string (writer, key);
210
    }
211
}
212
 
213
void
214
unit_entry_write_tld_unit PROTO_N ((entry, shapes, writer))
215
			  PROTO_T (UnitEntryP  entry X
216
				   ShapeTableP shapes X
217
				   TDFWriterP  writer)
218
{
219
    unsigned size = (tdf_int_size ((unsigned) 1) + 1);
220
    NStringP key  = unit_entry_key (entry);
221
 
222
    debug_info_w_start_units (key, (unsigned) 1);
223
    tdf_write_int (writer, (unsigned) 1);
224
    debug_info_w_start_unit (key, (unsigned) 1, (unsigned) 1);
225
    debug_info_w_start_counts ((unsigned) 0);
226
    tdf_write_int (writer, (unsigned) 0);
227
    debug_info_w_start_maps ((unsigned) 0);
228
    tdf_write_int (writer, (unsigned) 0);
229
    shape_table_iter (shapes, shape_entry_compute_tld_size, (GenericP) &size);
230
    size /= 2;
231
    debug_info_w_unit_body (size);
232
    tdf_write_int (writer, size);
233
    tdf_write_align (writer);
234
    debug_info_w_tld_version ((unsigned) 1);
235
    tdf_write_int (writer, (unsigned) 1);
236
    shape_table_iter (shapes, shape_entry_write_tld, (GenericP) writer);
237
    tdf_write_align (writer);
238
}
239
 
240
void
241
unit_entry_write_units PROTO_N ((entry, shapes, num_shapes, writer))
242
		       PROTO_T (UnitEntryP  entry X
243
				ShapeTableP shapes X
244
				unsigned    num_shapes X
245
				TDFWriterP  writer)
246
{
247
    unsigned num_units = 0;
248
    NStringP key       = unit_entry_key (entry);
249
    UnitP    unit;
250
 
251
    for (unit = entry->head; unit; unit = unit->next) {
252
	num_units ++;
253
    }
254
    if (num_units > 0) {
255
	unsigned i;
256
 
257
	debug_info_w_start_units (key, num_units);
258
	tdf_write_int (writer, num_units);
259
	for (unit = entry->head, i = 1; unit; unit = unit->next, i ++) {
260
	    debug_info_w_start_unit (key, i, num_units);
261
	    unit_write (unit, shapes, num_shapes, writer);
262
	}
263
    }
264
}
265
 
266
/*
267
 * Local variables(smf):
268
 * eval: (include::add-path-entry "../os-interface" "../library")
269
 * eval: (include::add-path-entry "../generated")
270
 * end:
271
**/