00001 /* params.c - Run-time parameters. 00002 Copyright (C) 2001 Free Software Foundation, Inc. 00003 Written by Mark Mitchell <mark@codesourcery.com>. 00004 00005 This file is part of GCC. 00006 00007 GCC is free software; you can redistribute it and/or modify it under 00008 the terms of the GNU General Public License as published by the Free 00009 Software Foundation; either version 2, or (at your option) any later 00010 version. 00011 00012 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 00013 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with GCC; see the file COPYING. If not, write to the Free 00019 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 00020 02111-1307, USA. 00021 00022 */ 00023 00024 #include "config.h" 00025 #include "system.h" 00026 #include "params.h" 00027 #include "toplev.h" 00028 00029 /* An array containing the compiler parameters and their current 00030 values. */ 00031 00032 param_info *compiler_params; 00033 00034 /* The number of entries in the table. */ 00035 00036 static size_t num_compiler_params; 00037 00038 /* Add the N PARAMS to the current list of compiler parameters. */ 00039 00040 void 00041 add_params (params, n) 00042 const param_info params[]; 00043 size_t n; 00044 { 00045 /* Allocate enough space for the new parameters. */ 00046 compiler_params = 00047 ((param_info *) 00048 xrealloc (compiler_params, 00049 (num_compiler_params + n) * sizeof (param_info))); 00050 /* Copy them into the table. */ 00051 memcpy (compiler_params + num_compiler_params, 00052 params, 00053 n * sizeof (param_info)); 00054 /* Keep track of how many parameters we have. */ 00055 num_compiler_params += n; 00056 } 00057 00058 /* Set the VALUE associated with the parameter given by NAME. */ 00059 00060 void 00061 set_param_value (name, value) 00062 const char *name; 00063 int value; 00064 { 00065 size_t i; 00066 00067 /* Make sure nobody tries to set a parameter to an invalid value. */ 00068 if (value == INVALID_PARAM_VAL) 00069 abort (); 00070 00071 /* Scan the parameter table to find a matching entry. */ 00072 for (i = 0; i < num_compiler_params; ++i) 00073 if (strcmp (compiler_params[i].option, name) == 0) 00074 { 00075 compiler_params[i].value = value; 00076 return; 00077 } 00078 00079 /* If we didn't find this parameter, issue an error message. */ 00080 error ("invalid parameter `%s'", name); 00081 }
1.5.6