X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=sim%2Fppc%2Fld-cache.c;h=f57f7db650a04d5eb7e53985cce529d97ff9b814;hb=fc3579da2ea6b2db27ac3003f818abd7786b9b30;hp=135013e5f237c5c648ca505547d185f4f1c26afe;hpb=abd8680d6efd97e7ba848a6392ee3ad72be18cd0;p=binutils-gdb.git diff --git a/sim/ppc/ld-cache.c b/sim/ppc/ld-cache.c index 135013e5f23..f57f7db650a 100644 --- a/sim/ppc/ld-cache.c +++ b/sim/ppc/ld-cache.c @@ -1,10 +1,10 @@ /* This file is part of the program psim. - Copyright (C) 1994-1997, Andrew Cagney + Copyright 1994, 1995, 1996, 1997, 2003 Andrew Cagney This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + along with this program; if not, see . */ @@ -24,10 +23,6 @@ #include "table.h" #include "ld-cache.h" -#ifndef NULL -#define NULL 0 -#endif - enum { ca_type, @@ -46,8 +41,27 @@ static const name_map cache_type_map[] = { }; +void +append_cache_rule (cache_table **table, const char *type, + const char *field_name, const char *derived_name, + const char *type_def, const char *expression, + table_entry *file_entry) +{ + while ((*table) != NULL) + table = &(*table)->next; + (*table) = ZALLOC(cache_table); + (*table)->type = name2i(type, cache_type_map); + (*table)->field_name = field_name; + (*table)->derived_name = derived_name; + (*table)->type_def = (strlen(type_def) > 0 ? type_def : NULL); + (*table)->expression = (strlen(expression) > 0 ? expression : NULL); + (*table)->file_entry = file_entry; + (*table)->next = NULL; +} + + cache_table * -load_cache_table(char *file_name, +load_cache_table(const char *file_name, int hi_bit_nr) { table *file = table_open(file_name, nr_cache_rule_fields, 0); @@ -55,19 +69,13 @@ load_cache_table(char *file_name, cache_table *table = NULL; cache_table **curr_rule = &table; while ((entry = table_entry_read(file)) != NULL) { - cache_table *new_rule = ZALLOC(cache_table); - new_rule->type = name2i(entry->fields[ca_type], cache_type_map); - new_rule->field_name = entry->fields[ca_field_name]; - new_rule->derived_name = entry->fields[ca_derived_name]; - new_rule->type_def = (strlen(entry->fields[ca_type_def]) - ? entry->fields[ca_type_def] - : NULL); - new_rule->expression = (strlen(entry->fields[ca_expression]) > 0 - ? entry->fields[ca_expression] - : NULL); - new_rule->file_entry = entry; - *curr_rule = new_rule; - curr_rule = &new_rule->next; + append_cache_rule (curr_rule, entry->fields[ca_type], + entry->fields[ca_field_name], + entry->fields[ca_derived_name], + entry->fields[ca_type_def], + entry->fields[ca_expression], + entry); + curr_rule = &(*curr_rule)->next; } return table; }