1 /* Handling of compile-time options that influence the library.
2 Copyright (C) 2005, 2007, 2009 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 3, or (at your option)
11 Libgfortran is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
25 #include "libgfortran.h"
32 /* Useful compile-time options will be stored in here. */
33 compile_options_t compile_options;
36 /* A signal handler to allow us to output a backtrace. */
40 const char * name = NULL, * desc = NULL;
47 desc = "Segmentation fault";
61 desc = "Illegal instruction";
68 desc = "Floating-point exception";
74 st_printf ("\nProgram received signal %d (%s): %s.\n", signum, name, desc);
76 st_printf ("\nProgram received signal %d.\n", signum);
82 /* Set the usual compile-time options. */
83 extern void set_options (int , int []);
84 export_proto(set_options);
87 set_options (int num, int options[])
90 compile_options.warn_std = options[0];
92 compile_options.allow_std = options[1];
94 compile_options.pedantic = options[2];
96 compile_options.dump_core = options[3];
98 compile_options.backtrace = options[4];
100 compile_options.sign_zero = options[5];
102 compile_options.bounds_check = options[6];
104 compile_options.range_check = options[7];
106 /* If backtrace is required, we set signal handlers on most common
108 #if defined(HAVE_SIGNAL) && (defined(SIGSEGV) || defined(SIGBUS) \
109 || defined(SIGILL) || defined(SIGFPE))
110 if (compile_options.backtrace)
113 signal (SIGSEGV, handler);
117 signal (SIGBUS, handler);
121 signal (SIGILL, handler);
125 signal (SIGFPE, handler);
133 /* Default values for the compile-time options. Keep in sync with
134 gcc/fortran/options.c (gfc_init_options). */
136 init_compile_options (void)
138 compile_options.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY;
139 compile_options.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
140 | GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77
141 | GFC_STD_GNU | GFC_STD_LEGACY;
142 compile_options.pedantic = 0;
143 compile_options.dump_core = 0;
144 compile_options.backtrace = 0;
145 compile_options.sign_zero = 1;
146 compile_options.range_check = 1;
149 /* Function called by the front-end to tell us the
150 default for unformatted data conversion. */
152 extern void set_convert (int);
153 export_proto (set_convert);
156 set_convert (int conv)
158 compile_options.convert = conv;
161 extern void set_record_marker (int);
162 export_proto (set_record_marker);
166 set_record_marker (int val)
172 compile_options.record_marker = sizeof (GFC_INTEGER_4);
176 compile_options.record_marker = sizeof (GFC_INTEGER_8);
180 runtime_error ("Invalid value for record marker");
185 extern void set_max_subrecord_length (int);
186 export_proto (set_max_subrecord_length);
188 void set_max_subrecord_length(int val)
190 if (val > GFC_MAX_SUBRECORD_LENGTH || val < 1)
192 runtime_error ("Invalid value for maximum subrecord length");
196 compile_options.max_subrecord_length = val;