Subversion Repositories tendra.SVN

Rev

Rev 2 | Go to most recent revision | Details | Compare with Previous | 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-table.c --- Unit set table ADT.
32
 *
33
 ** Author: Steve Folkes <smf@hermes.mod.uk>
34
 *
35
 *** Commentary:
36
 *
37
 * This file implements the unit set table routines used by the TDF linker.
38
 *
39
 *** Change Log:
40
 * $Log: unit-table.c,v $
41
 * Revision 1.1.1.1  1998/01/17  15:57:20  release
42
 * First version to be checked into rolling release.
43
 *
44
 * Revision 1.3  1995/09/22  08:39:45  smf
45
 * Fixed problems with incomplete structures (to shut "tcc" up).
46
 * Fixed some problems in "name-key.c" (no real problems, but rewritten to
47
 * reduce the warnings that were output by "tcc" and "gcc").
48
 * Fixed bug CR95_354.tld-common-id-problem (library capsules could be loaded
49
 * more than once).
50
 *
51
 * Revision 1.2  1994/12/12  11:47:09  smf
52
 * Performing changes for 'CR94_178.sid+tld-update' - bringing in line with
53
 * OSSG C Coding Standards.
54
 *
55
 * Revision 1.1.1.1  1994/07/25  16:03:40  smf
56
 * Initial import of TDF linker 3.5 non shared files.
57
 *
58
**/
59
 
60
/****************************************************************************/
61
 
62
#include "unit-table.h"
63
 
64
#include "solve-cycles.h"
65
 
66
/*--------------------------------------------------------------------------*/
67
 
68
UnitTableP
69
unit_table_create PROTO_Z ()
70
{
71
    UnitTableP table = ALLOCATE (UnitTableT);
72
    unsigned   i;
73
 
74
    for (i = 0; i < UNIT_TABLE_SIZE; i ++) {
75
	table->contents [i] = NIL (UnitEntryP);
76
    }
77
    return (table);
78
}
79
 
80
UnitEntryP
81
unit_table_add PROTO_N ((table, key, order))
82
	       PROTO_T (UnitTableP table X
83
			NStringP   key X
84
			unsigned   order)
85
{
86
    unsigned   hash_value = (nstring_hash_value (key) % UNIT_TABLE_SIZE);
87
    UnitEntryP next       = (table->contents [hash_value]);
88
    UnitEntryP entry      = unit_entry_create (key, next, order);
89
 
90
    table->contents [hash_value] = entry;
91
    return (entry);
92
}
93
 
94
UnitEntryP
95
unit_table_get PROTO_N ((table, key))
96
	       PROTO_T (UnitTableP table X
97
			NStringP   key)
98
{
99
    unsigned   hash_value = (nstring_hash_value (key) % UNIT_TABLE_SIZE);
100
    UnitEntryP entry      = (table->contents [hash_value]);
101
 
102
    while (entry && (!nstring_equal (key, unit_entry_key (entry)))) {
103
	entry = unit_entry_next (entry);
104
    }
105
    return (entry);
106
}
107
 
108
void
109
unit_table_iter PROTO_N ((table, proc, closure))
110
		PROTO_T (UnitTableP table X
111
			 void     (*proc) PROTO_S ((UnitEntryP, GenericP)) X
112
			 GenericP   closure)
113
{
114
    unsigned i;
115
 
116
    for (i = 0; i < UNIT_TABLE_SIZE; i ++) {
117
	UnitEntryP entry = (table->contents [i]);
118
 
119
	while (entry) {
120
	    (*proc) (entry, closure);
121
	    entry = unit_entry_next (entry);
122
	}
123
    }
124
}
125
 
126
/*
127
 * Local variables(smf):
128
 * eval: (include::add-path-entry "../os-interface" "../library")
129
 * eval: (include::add-path-entry "../generated")
130
 * end:
131
**/