1 /* Copyright (C) 2002-2015 Free Software Foundation, Inc.
2 Contributed by Andy Vaught and Paul Brook <paul@nowt.org>
4 This file is part of the GNU Fortran 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"
36 /* Stupid function to be sure the constructor is always linked in, even
37 in the case of static linking. See PR libfortran/22298 for details. */
39 stupid_function_name_for_static_linking (void)
46 /* This will be 0 for little-endian
47 machines and 1 for big-endian machines.
49 Currently minimal libgfortran only runs on little-endian devices
50 which don't support constructors so this is just a constant. */
54 static char **argv_save
;
56 static const char *exe_path
;
58 /* recursion_check()-- It's possible for additional errors to occur
59 * during fatal error processing. We detect this condition here and
60 * exit with code 4 immediately. */
62 #define MAGIC 0x20DE8101
65 recursion_check (void)
69 /* Don't even try to print something at this point */
76 #define STRERR_MAXSZ 256
79 os_error (const char *message
)
82 printf ("Operating system error: ");
83 printf ("%s\n", message
);
89 runtime_error (const char *message
, ...)
94 printf ("Fortran runtime error: ");
95 va_start (ap
, message
);
96 vprintf (message
, ap
);
101 iexport(runtime_error
);
103 /* void runtime_error_at()-- These are errors associated with a
104 * run time error generated by the front end compiler. */
107 runtime_error_at (const char *where
, const char *message
, ...)
112 printf ("Fortran runtime error: ");
113 va_start (ap
, message
);
114 vprintf (message
, ap
);
119 iexport(runtime_error_at
);
121 /* Return the full path of the executable. */
125 return (char *) exe_path
;
129 /* Set the saved values of the command line arguments. */
132 set_args (int argc
, char **argv
)
141 /* Retrieve the saved values of the command line arguments. */
144 get_args (int *argc
, char ***argv
)
150 /* sys_abort()-- Terminate the program showing backtrace and dumping
156 printf ("Abort called.\n");