1*b1e83836Smrg /* Copyright (C) 2002-2022 Free Software Foundation, Inc.
2181254a7Smrg Contributed by Andy Vaught and Paul Brook <paul@nowt.org>
3181254a7Smrg
4181254a7Smrg This file is part of the GNU Fortran runtime library (libgfortran).
5181254a7Smrg
6181254a7Smrg Libgfortran is free software; you can redistribute it and/or modify
7181254a7Smrg it under the terms of the GNU General Public License as published by
8181254a7Smrg the Free Software Foundation; either version 3, or (at your option)
9181254a7Smrg any later version.
10181254a7Smrg
11181254a7Smrg Libgfortran is distributed in the hope that it will be useful,
12181254a7Smrg but WITHOUT ANY WARRANTY; without even the implied warranty of
13181254a7Smrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14181254a7Smrg GNU General Public License for more details.
15181254a7Smrg
16181254a7Smrg Under Section 7 of GPL version 3, you are granted additional
17181254a7Smrg permissions described in the GCC Runtime Library Exception, version
18181254a7Smrg 3.1, as published by the Free Software Foundation.
19181254a7Smrg
20181254a7Smrg You should have received a copy of the GNU General Public License and
21181254a7Smrg a copy of the GCC Runtime Library Exception along with this program;
22181254a7Smrg see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23181254a7Smrg <http://www.gnu.org/licenses/>. */
24181254a7Smrg
25181254a7Smrg #include "libgfortran.h"
26181254a7Smrg
27181254a7Smrg
28181254a7Smrg /* Stupid function to be sure the constructor is always linked in, even
29181254a7Smrg in the case of static linking. See PR libfortran/22298 for details. */
30181254a7Smrg void
stupid_function_name_for_static_linking(void)31181254a7Smrg stupid_function_name_for_static_linking (void)
32181254a7Smrg {
33181254a7Smrg return;
34181254a7Smrg }
35181254a7Smrg
36181254a7Smrg
37181254a7Smrg static int argc_save;
38181254a7Smrg static char **argv_save;
39181254a7Smrg
40181254a7Smrg
41181254a7Smrg /* Set the saved values of the command line arguments. */
42181254a7Smrg
43181254a7Smrg void
set_args(int argc,char ** argv)44181254a7Smrg set_args (int argc, char **argv)
45181254a7Smrg {
46181254a7Smrg argc_save = argc;
47181254a7Smrg argv_save = argv;
48181254a7Smrg }
49181254a7Smrg iexport(set_args);
50181254a7Smrg
51181254a7Smrg
52181254a7Smrg /* Retrieve the saved values of the command line arguments. */
53181254a7Smrg
54181254a7Smrg void
get_args(int * argc,char *** argv)55181254a7Smrg get_args (int *argc, char ***argv)
56181254a7Smrg {
57181254a7Smrg *argc = argc_save;
58181254a7Smrg *argv = argv_save;
59181254a7Smrg }
60181254a7Smrg
61181254a7Smrg
62181254a7Smrg /* Initialize the runtime library. */
63181254a7Smrg
64181254a7Smrg static void __attribute__((constructor))
init(void)65181254a7Smrg init (void)
66181254a7Smrg {
67181254a7Smrg /* Must be first */
68181254a7Smrg init_variables ();
69181254a7Smrg
70181254a7Smrg init_units ();
71181254a7Smrg
72181254a7Smrg /* If (and only if) the user asked for it, set up the FPU state. */
73181254a7Smrg if (options.fpe != 0)
74181254a7Smrg set_fpu ();
75181254a7Smrg
76181254a7Smrg init_compile_options ();
77181254a7Smrg }
78181254a7Smrg
79181254a7Smrg
80181254a7Smrg /* Cleanup the runtime library. */
81181254a7Smrg
82181254a7Smrg static void __attribute__((destructor))
cleanup(void)83181254a7Smrg cleanup (void)
84181254a7Smrg {
85181254a7Smrg close_units ();
86181254a7Smrg }
87