2015-01-05 13:33:28 +01:00
|
|
|
/* Copyright (C) 2002-2015 Free Software Foundation, Inc.
|
2004-05-13 08:41:07 +02:00
|
|
|
Contributed by Andy Vaught and Paul Brook <paul@nowt.org>
|
|
|
|
|
2011-04-16 19:43:03 +02:00
|
|
|
This file is part of the GNU Fortran runtime library (libgfortran).
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-01-12 22:27:33 +01:00
|
|
|
Libgfortran is free software; you can redistribute it and/or modify
|
2004-05-13 08:41:07 +02:00
|
|
|
it under the terms of the GNU General Public License as published by
|
2009-04-09 17:00:19 +02:00
|
|
|
the Free Software Foundation; either version 3, or (at your option)
|
2004-05-13 08:41:07 +02:00
|
|
|
any later version.
|
|
|
|
|
2005-01-12 22:27:33 +01:00
|
|
|
Libgfortran is distributed in the hope that it will be useful,
|
2004-05-13 08:41:07 +02:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
permissions described in the GCC Runtime Library Exception, version
|
|
|
|
3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License and
|
|
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2007-08-31 16:01:34 +02:00
|
|
|
#include "libgfortran.h"
|
2004-05-13 08:41:07 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
#include <limits.h>
|
2014-05-22 05:51:25 +02:00
|
|
|
#include <errno.h>
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2005-11-04 09:44:29 +01:00
|
|
|
/* Stupid function to be sure the constructor is always linked in, even
|
|
|
|
in the case of static linking. See PR libfortran/22298 for details. */
|
|
|
|
void
|
|
|
|
stupid_function_name_for_static_linking (void)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-13 22:28:08 +02:00
|
|
|
/* This will be 0 for little-endian
|
|
|
|
machines and 1 for big-endian machines. */
|
|
|
|
int big_endian = 0;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Figure out endianness for this machine. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
determine_endianness (void)
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
GFC_LOGICAL_8 l8;
|
|
|
|
GFC_LOGICAL_4 l4[2];
|
|
|
|
} u;
|
|
|
|
|
|
|
|
u.l8 = 1;
|
|
|
|
if (u.l4[0])
|
2008-06-13 22:28:08 +02:00
|
|
|
big_endian = 0;
|
2004-05-13 08:41:07 +02:00
|
|
|
else if (u.l4[1])
|
2008-06-13 22:28:08 +02:00
|
|
|
big_endian = 1;
|
2004-05-13 08:41:07 +02:00
|
|
|
else
|
|
|
|
runtime_error ("Unable to determine machine endianness");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int argc_save;
|
|
|
|
static char **argv_save;
|
|
|
|
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
|
2009-05-27 17:22:34 +02:00
|
|
|
void
|
2015-08-23 23:50:30 +02:00
|
|
|
store_exe_path (const char * argv0 __attribute__ ((unused)))
|
gfortran.h (gfc_option_t): Add flag_backtrace field.
* gfortran.h (gfc_option_t): Add flag_backtrace field.
* lang.opt: Add -fbacktrace option.
* invoke.texi: Document the new option.
* trans-decl.c (gfc_build_builtin_function_decls): Add new
option to the call to set_std.
* options.c (gfc_init_options, gfc_handle_option): Handle the
new option.
* runtime/backtrace.c: New file.
* runtime/environ.c (variable_table): New GFORTRAN_ERROR_BACKTRACE
environment variable.
* runtime/compile_options.c (set_std): Add new argument.
* runtime/main.c (store_exe_path, full_exe_path): New functions.
* runtime/error.c (sys_exit): Add call to show_backtrace.
* libgfortran.h (options_t): New backtrace field.
(store_exe_path, full_exe_path, show_backtrace): New prototypes.
* configure.ac: Add checks for execinfo.h, execvp, pipe, dup2,
close, fdopen, strcasestr, getrlimit, backtrace, backtrace_symbols
and getppid.
* Makefile.am: Add runtime/backtrace.c.
* fmain.c (main): Add call to store_exe_path.
* Makefile.in: Renegerate.
* config.h.in: Renegerate.
* configure: Regenerate.
From-SVN: r122954
2007-03-15 13:39:47 +01:00
|
|
|
{
|
2015-08-23 23:50:30 +02:00
|
|
|
/* This function is now useless, but is retained due to ABI compatibility.
|
|
|
|
Remove when bumping the library ABI. */
|
|
|
|
;
|
2011-05-29 22:13:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-26 23:19:57 +02:00
|
|
|
/* Set the saved values of the command line arguments. */
|
|
|
|
|
|
|
|
void
|
|
|
|
set_args (int argc, char **argv)
|
|
|
|
{
|
|
|
|
argc_save = argc;
|
|
|
|
argv_save = argv;
|
|
|
|
}
|
2009-06-14 18:52:49 +02:00
|
|
|
iexport(set_args);
|
2009-05-26 23:19:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Retrieve the saved values of the command line arguments. */
|
|
|
|
|
|
|
|
void
|
|
|
|
get_args (int *argc, char ***argv)
|
|
|
|
{
|
|
|
|
*argc = argc_save;
|
|
|
|
*argv = argv_save;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
/* Initialize the runtime library. */
|
|
|
|
|
|
|
|
static void __attribute__((constructor))
|
|
|
|
init (void)
|
|
|
|
{
|
|
|
|
/* Figure out the machine endianness. */
|
|
|
|
determine_endianness ();
|
|
|
|
|
|
|
|
/* Must be first */
|
|
|
|
init_variables ();
|
|
|
|
|
|
|
|
init_units ();
|
2015-08-07 18:23:53 +02:00
|
|
|
|
|
|
|
/* If (and only if) the user asked for it, set up the FPU state. */
|
|
|
|
if (options.fpe != 0)
|
|
|
|
set_fpu ();
|
|
|
|
|
2005-08-11 15:50:13 +02:00
|
|
|
init_compile_options ();
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2007-08-12 22:45:29 +02:00
|
|
|
random_seed_i4 (NULL, NULL, NULL);
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Cleanup the runtime library. */
|
|
|
|
|
|
|
|
static void __attribute__((destructor))
|
normalize.c (almostone_r4, [...]): Fix parameter list.
* runtime/normalize.c (almostone_r4, almostone_r8): Fix parameter
list.
* intrinsics/random.c (KISS_DEFAULT_SEED): Remove extra semicolon.
* io/transfer.c: Do not use empty initializers for global objects.
Add missing initializers.
* io/lock.c: Do not use empty initializers for global objects.
* io/close.c: Add missing initializers.
* runtime/environ.c: Add missing initializers. Do not use empty
initializers for global object.
(init_string): Mark argument as unused.
* runtime/main.c (cleanup): Fix parameter list.
* io/io.h: Fix parameter lists.
* m4/transpose.m4, m4/matmul.m4: Fix pointer cast to avoid
warning.
* generated/transpose_c4.c, generated/transpose_c8.c,
generated/transpose_i4.c, generated/transpose_i8.c,
generated/matmul_c4.c, generated/matmul_c8.c,
generated/matmul_i4.c, generated/matmul_i8.c,
generated/matmul_r4.c, generated/matmul_r8.c: Regenerated.
* io/write.c (nml_write_obj): Fix 64-bit problem.
* io/list_read.c (nml_get_obj_data): Add missing braces around
initializer to avoid warnings.
* intrinsics/etime.c (etime_sub): Remove unused variable.
From-SVN: r99719
2005-05-15 14:44:42 +02:00
|
|
|
cleanup (void)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
|
|
|
close_units ();
|
|
|
|
}
|