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 /* If backtrace is required, we set signal handlers on most common
111 #if defined(HAVE_SIGNAL) && (defined(SIGSEGV) || defined(SIGBUS) \
112 || defined(SIGILL) || defined(SIGFPE))
113 if (compile_options
.backtrace
)
116 signal (SIGSEGV
, handler
);
120 signal (SIGBUS
, handler
);
124 signal (SIGILL
, handler
);
128 signal (SIGFPE
, handler
);
136 /* Default values for the compile-time options. Keep in sync with
137 gcc/fortran/options.c (gfc_init_options). */
139 init_compile_options (void)
141 compile_options
.warn_std
= GFC_STD_F95_OBS
| GFC_STD_F95_DEL
142 | GFC_STD_F2003
| GFC_STD_LEGACY
;
143 compile_options
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F95_DEL
144 | GFC_STD_F2003
| GFC_STD_F95
| GFC_STD_F77
| GFC_STD_GNU
| GFC_STD_LEGACY
;
145 compile_options
.pedantic
= 0;
146 compile_options
.dump_core
= 0;
147 compile_options
.backtrace
= 0;
148 compile_options
.sign_zero
= 1;
151 /* Function called by the front-end to tell us the
152 default for unformatted data conversion. */
154 extern void set_convert (int);
155 export_proto (set_convert
);
158 set_convert (int conv
)
160 compile_options
.convert
= conv
;
163 extern void set_record_marker (int);
164 export_proto (set_record_marker
);
168 set_record_marker (int val
)
174 compile_options
.record_marker
= sizeof (GFC_INTEGER_4
);
178 compile_options
.record_marker
= sizeof (GFC_INTEGER_8
);
182 runtime_error ("Invalid value for record marker");
187 extern void set_max_subrecord_length (int);
188 export_proto (set_max_subrecord_length
);
190 void set_max_subrecord_length(int val
)
192 if (val
> GFC_MAX_SUBRECORD_LENGTH
|| val
< 1)
194 runtime_error ("Invalid value for maximum subrecord length");
198 compile_options
.max_subrecord_length
= val
;