1 /* Handling of compile-time options that influence the library.
2 Copyright (C) 2005, 2007 Free Software Foundation, Inc.
4 This file is part of the GNU Fortran 95 runtime library (libgfortran).
6 Libgfortran is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 In addition to the permissions in the GNU General Public License, the
12 Free Software Foundation gives you unlimited permission to link the
13 compiled version of this file into combinations with other programs,
14 and to distribute those combinations without any restriction coming
15 from the use of this file. (The General Public License restrictions
16 do apply in other respects; for example, they cover modification of
17 the file, and distribution when not linked into a combine
20 Libgfortran is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with libgfortran; see the file COPYING. If not, write to
27 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
28 Boston, MA 02110-1301, USA. */
30 #include "libgfortran.h"
37 /* Useful compile-time options will be stored in here. */
38 compile_options_t compile_options;
41 /* A signal handler to allow us to output a backtrace. */
45 const char * name = NULL, * desc = NULL;
52 desc = "Segmentation fault";
66 desc = "Illegal instruction";
73 desc = "Floating-point exception";
79 st_printf ("\nProgram received signal %d (%s): %s.\n", signum, name, desc);
81 st_printf ("\nProgram received signal %d.\n", signum);
87 /* Set the usual compile-time options. */
88 extern void set_options (int , int []);
89 export_proto(set_options);
92 set_options (int num, int options[])
95 compile_options.warn_std = options[0];
97 compile_options.allow_std = options[1];
99 compile_options.pedantic = options[2];
101 compile_options.dump_core = options[3];
103 compile_options.backtrace = options[4];
105 compile_options.sign_zero = options[5];
107 compile_options.bounds_check = options[6];
109 compile_options.range_check = options[7];
111 /* If backtrace is required, we set signal handlers on most common
113 #if defined(HAVE_SIGNAL) && (defined(SIGSEGV) || defined(SIGBUS) \
114 || defined(SIGILL) || defined(SIGFPE))
115 if (compile_options.backtrace)
118 signal (SIGSEGV, handler);
122 signal (SIGBUS, handler);
126 signal (SIGILL, handler);
130 signal (SIGFPE, handler);
138 /* Default values for the compile-time options. Keep in sync with
139 gcc/fortran/options.c (gfc_init_options). */
141 init_compile_options (void)
143 compile_options.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY;
144 compile_options.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
145 | GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77
146 | GFC_STD_GNU | GFC_STD_LEGACY;
147 compile_options.pedantic = 0;
148 compile_options.dump_core = 0;
149 compile_options.backtrace = 0;
150 compile_options.sign_zero = 1;
151 compile_options.range_check = 1;
154 /* Function called by the front-end to tell us the
155 default for unformatted data conversion. */
157 extern void set_convert (int);
158 export_proto (set_convert);
161 set_convert (int conv)
163 compile_options.convert = conv;
166 extern void set_record_marker (int);
167 export_proto (set_record_marker);
171 set_record_marker (int val)
177 compile_options.record_marker = sizeof (GFC_INTEGER_4);
181 compile_options.record_marker = sizeof (GFC_INTEGER_8);
185 runtime_error ("Invalid value for record marker");
190 extern void set_max_subrecord_length (int);
191 export_proto (set_max_subrecord_length);
193 void set_max_subrecord_length(int val)
195 if (val > GFC_MAX_SUBRECORD_LENGTH || val < 1)
197 runtime_error ("Invalid value for maximum subrecord length");
201 compile_options.max_subrecord_length = val;