1 /* Copyright (C) 2002-2003, 2005 Free Software Foundation, Inc.
2 Contributed by Andy Vaught and Paul Brook <paul@nowt.org>
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. */
36 #include "libgfortran.h"
42 /* Stupid function to be sure the constructor is always linked in, even
43 in the case of static linking. See PR libfortran/22298 for details. */
45 stupid_function_name_for_static_linking (void)
50 /* This is the offset (in bytes) required to cast from logical(8)* to
51 logical(4)*. and still get the same result. Will be 0 for little-endian
52 machines and 4 for big-endian machines. */
53 int l8_to_l4_offset = 0;
56 /* Figure out endianness for this machine. */
59 determine_endianness (void)
73 runtime_error ("Unable to determine machine endianness");
78 static char **argv_save;
80 /* Set the saved values of the command line arguments. */
83 set_args (int argc, char **argv)
89 /* Retrieve the saved values of the command line arguments. */
92 get_args (int *argc, char ***argv)
99 static const char *exe_path;
101 /* Save the path under which the program was called, for use in the
102 backtrace routines. */
104 store_exe_path (const char * argv0)
107 #define PATH_MAX 1024
110 #ifndef DIR_SEPARATOR
111 #define DIR_SEPARATOR '/'
114 char buf[PATH_MAX], *cwd, *path;
122 cwd = getcwd (buf, sizeof (buf));
124 /* exe_path will be cwd + "/" + argv[0] + "\0" */
125 path = malloc (strlen (cwd) + 1 + strlen (argv0) + 1);
126 st_sprintf (path, "%s%c%s", cwd, DIR_SEPARATOR, argv0);
130 /* Return the full path of the executable. */
134 return (char *) exe_path;
137 /* Initialize the runtime library. */
139 static void __attribute__((constructor))
142 /* Figure out the machine endianness. */
143 determine_endianness ();
150 init_compile_options ();
153 /* Check for special command lines. */
155 if (argc > 1 && strcmp (argv[1], "--help") == 0)
158 /* if (argc > 1 && strcmp(argv[1], "--resume") == 0) resume(); */
161 random_seed(NULL,NULL,NULL);
165 /* Cleanup the runtime library. */
167 static void __attribute__((destructor))