]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgfortran/runtime/main.c
function.c (assign_parm_setup_block): Relax condition on multi-register optimization.
[thirdparty/gcc.git] / libgfortran / runtime / main.c
CommitLineData
6de9cd9a
DN
1/* Copyright (C) 2002-2003 Free Software Foundation, Inc.
2 Contributed by Andy Vaught and Paul Brook <paul@nowt.org>
3
4This file is part of the GNU Fortran 95 runtime library (libgfor).
5
6Libgfor is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11Libgfor is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with libgfor; see the file COPYING. If not, write to
18the Free Software Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
20
21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h>
24#include <math.h>
25#include <stddef.h>
26
27#include "libgfortran.h"
28
29/* This is the offset (in bytes) required to cast from logical(8)* to
30 logical(4)*. and still get the same result. Will be 0 for little-endian
31 machines and 4 for big-endian machines. */
7d7b8bfe 32int l8_to_l4_offset = 0;
6de9cd9a
DN
33
34
35/* Figure out endianness for this machine. */
36
6de9cd9a
DN
37static void
38determine_endianness (void)
39{
40 union
41 {
42 GFC_LOGICAL_8 l8;
43 GFC_LOGICAL_4 l4[2];
44 } u;
45
46 u.l8 = 1;
47 if (u.l4[0])
48 l8_to_l4_offset = 0;
49 else if (u.l4[1])
50 l8_to_l4_offset = 1;
51 else
52 runtime_error ("Unable to determine machine endianness");
53}
54
55
56static int argc_save;
57static char **argv_save;
58
59/* Set the saved values of the command line arguments. */
60
61void
62set_args (int argc, char **argv)
63{
64 argc_save = argc;
65 argv_save = argv;
66}
67
68/* Retrieve the saved values of the command line arguments. */
69
70void
71get_args (int *argc, char ***argv)
72{
6de9cd9a
DN
73 *argc = argc_save;
74 *argv = argv_save;
75}
76
77
78/* Initialize the runtime library. */
79
80static void __attribute__((constructor))
81init (void)
82{
83 /* Figure out the machine endianness. */
84 determine_endianness ();
85
86 /* Must be first */
87 init_variables ();
88
89 init_units ();
90
91#ifdef DEBUG
92 /* Check for special command lines. */
93
94 if (argc > 1 && strcmp (argv[1], "--help") == 0)
95 show_variables ();
96
7d7b8bfe 97 /* if (argc > 1 && strcmp(argv[1], "--resume") == 0) resume(); */
6de9cd9a
DN
98#endif
99
abdef811 100 random_seed(NULL,NULL,NULL);
6de9cd9a
DN
101}
102
103
104/* Cleanup the runtime library. */
105
106static void __attribute__((destructor))
107cleanup ()
108{
109 close_units ();
110}