OSDN Git Service

Correct test results for avoid-bool-define fix
[pf3gnuchains/gcc-fork.git] / gcc / params.c
1 /* params.c - Run-time parameters.
2    Copyright (C) 2001 Free Software Foundation, Inc.
3    Written by Mark Mitchell <mark@codesourcery.com>.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  
21
22 */
23
24 #include "config.h"
25 #include "system.h"
26 #include "params.h"
27 #include "toplev.h"
28
29 /* An array containing the compiler parameters and their current
30    values.  */
31
32 param_info *compiler_params;
33
34 /* The number of entries in the table.  */
35
36 static size_t num_compiler_params;
37
38 /* Add the N PARAMS to the current list of compiler parameters.  */
39
40 void 
41 add_params (params, n)
42      const param_info params[];
43      size_t n;
44 {
45   /* Allocate enough space for the new parameters.  */
46   compiler_params = 
47     ((param_info *) 
48      xrealloc (compiler_params,
49                (num_compiler_params + n) * sizeof (param_info)));
50   /* Copy them into the table.  */
51   memcpy (compiler_params + num_compiler_params,
52           params,
53           n * sizeof (param_info));
54   /* Keep track of how many parameters we have.  */
55   num_compiler_params += n;
56 }
57
58 /* Set the VALUE associated with the parameter given by NAME.  */
59
60 void
61 set_param_value (name, value)
62      const char *name;
63      int value;
64 {
65   size_t i;
66
67   /* Make sure nobody tries to set a parameter to an invalid value.  */
68   if (value == INVALID_PARAM_VAL)
69     abort ();
70
71   /* Scan the parameter table to find a matching entry.  */
72   for (i = 0; i < num_compiler_params; ++i)
73     if (strcmp (compiler_params[i].option, name) == 0)
74       {
75         compiler_params[i].value = value;
76         return;
77       }
78
79   /* If we didn't find this parameter, issue an error message.  */
80   error ("invalid parameter `%s'", name);
81 }
82
83      
84