1 /* This file is part of the program psim.
3 Copyright (C) 1994-1995,1997, Andrew Cagney <cagney@highland.com.au>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 typedef struct _cap_mapping cap_mapping
;
29 unsigned_cell external
;
36 cap_mapping
*mappings
;
41 cap_create(const char *key
)
50 cap_mapping
*current_map
= db
->mappings
;
51 if (current_map
!= NULL
) {
52 db
->nr_mappings
= db
->mappings
->external
;
53 /* verify that the mappings that were not removed are in sequence
55 while (current_map
->next
!= NULL
) {
56 if (current_map
->external
!= current_map
->next
->external
+ 1)
57 error("cap: cap database possibly corrupt");
58 current_map
= current_map
->next
;
60 ASSERT(current_map
->next
== NULL
);
61 if (current_map
->external
!= 1)
62 error("cap: cap database possibly currupt");
74 cap_mapping
*current_map
= db
->mappings
;
75 while (current_map
!= NULL
) {
76 if (current_map
->external
== external
)
77 return current_map
->internal
;
78 current_map
= current_map
->next
;
88 cap_mapping
*current_map
= db
->mappings
;
89 while (current_map
!= NULL
) {
90 if (current_map
->internal
== internal
)
91 return current_map
->external
;
92 current_map
= current_map
->next
;
102 if (cap_external(db
, internal
) != 0) {
103 error("cap: attempting to add an object already in the data base");
106 /* insert at the front making things in decending order */
107 cap_mapping
*new_map
= ZALLOC(cap_mapping
);
108 new_map
->next
= db
->mappings
;
109 new_map
->internal
= internal
;
110 db
->nr_mappings
+= 1;
111 new_map
->external
= db
->nr_mappings
;
112 db
->mappings
= new_map
;
121 cap_mapping
**current_map
= &db
->mappings
;
122 while (*current_map
!= NULL
) {
123 if ((*current_map
)->internal
== internal
) {
124 cap_mapping
*delete = *current_map
;
125 *current_map
= delete->next
;
129 current_map
= &(*current_map
)->next
;
131 error("cap: attempt to remove nonexistant internal object");