1*4c3eb207Smrg /* Copyright (C) 2002-2020 Free Software Foundation, Inc.
2627f7eb2Smrg Contributed by Andy Vaught and Paul Brook <paul@nowt.org>
3627f7eb2Smrg
4627f7eb2Smrg This file is part of the GNU Fortran runtime library (libgfortran).
5627f7eb2Smrg
6627f7eb2Smrg Libgfortran is free software; you can redistribute it and/or modify
7627f7eb2Smrg it under the terms of the GNU General Public License as published by
8627f7eb2Smrg the Free Software Foundation; either version 3, or (at your option)
9627f7eb2Smrg any later version.
10627f7eb2Smrg
11627f7eb2Smrg Libgfortran is distributed in the hope that it will be useful,
12627f7eb2Smrg but WITHOUT ANY WARRANTY; without even the implied warranty of
13627f7eb2Smrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14627f7eb2Smrg GNU General Public License for more details.
15627f7eb2Smrg
16627f7eb2Smrg Under Section 7 of GPL version 3, you are granted additional
17627f7eb2Smrg permissions described in the GCC Runtime Library Exception, version
18627f7eb2Smrg 3.1, as published by the Free Software Foundation.
19627f7eb2Smrg
20627f7eb2Smrg You should have received a copy of the GNU General Public License and
21627f7eb2Smrg a copy of the GCC Runtime Library Exception along with this program;
22627f7eb2Smrg see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23627f7eb2Smrg <http://www.gnu.org/licenses/>. */
24627f7eb2Smrg
25627f7eb2Smrg #include "libgfortran.h"
26627f7eb2Smrg
27627f7eb2Smrg
28627f7eb2Smrg /* Stupid function to be sure the constructor is always linked in, even
29627f7eb2Smrg in the case of static linking. See PR libfortran/22298 for details. */
30627f7eb2Smrg void
stupid_function_name_for_static_linking(void)31627f7eb2Smrg stupid_function_name_for_static_linking (void)
32627f7eb2Smrg {
33627f7eb2Smrg return;
34627f7eb2Smrg }
35627f7eb2Smrg
36627f7eb2Smrg
37627f7eb2Smrg static int argc_save;
38627f7eb2Smrg static char **argv_save;
39627f7eb2Smrg
40627f7eb2Smrg
41627f7eb2Smrg /* Set the saved values of the command line arguments. */
42627f7eb2Smrg
43627f7eb2Smrg void
set_args(int argc,char ** argv)44627f7eb2Smrg set_args (int argc, char **argv)
45627f7eb2Smrg {
46627f7eb2Smrg argc_save = argc;
47627f7eb2Smrg argv_save = argv;
48627f7eb2Smrg }
49627f7eb2Smrg iexport(set_args);
50627f7eb2Smrg
51627f7eb2Smrg
52627f7eb2Smrg /* Retrieve the saved values of the command line arguments. */
53627f7eb2Smrg
54627f7eb2Smrg void
get_args(int * argc,char *** argv)55627f7eb2Smrg get_args (int *argc, char ***argv)
56627f7eb2Smrg {
57627f7eb2Smrg *argc = argc_save;
58627f7eb2Smrg *argv = argv_save;
59627f7eb2Smrg }
60627f7eb2Smrg
61627f7eb2Smrg
62627f7eb2Smrg /* Initialize the runtime library. */
63627f7eb2Smrg
64627f7eb2Smrg static void __attribute__((constructor))
init(void)65627f7eb2Smrg init (void)
66627f7eb2Smrg {
67627f7eb2Smrg /* Must be first */
68627f7eb2Smrg init_variables ();
69627f7eb2Smrg
70627f7eb2Smrg init_units ();
71627f7eb2Smrg
72627f7eb2Smrg /* If (and only if) the user asked for it, set up the FPU state. */
73627f7eb2Smrg if (options.fpe != 0)
74627f7eb2Smrg set_fpu ();
75627f7eb2Smrg
76627f7eb2Smrg init_compile_options ();
77627f7eb2Smrg }
78627f7eb2Smrg
79627f7eb2Smrg
80627f7eb2Smrg /* Cleanup the runtime library. */
81627f7eb2Smrg
82627f7eb2Smrg static void __attribute__((destructor))
cleanup(void)83627f7eb2Smrg cleanup (void)
84627f7eb2Smrg {
85627f7eb2Smrg close_units ();
86627f7eb2Smrg }
87