OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libgfortran/] [runtime/] [main.c] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* Copyright (C) 2002-2003, 2005 Free Software Foundation, Inc.
2
   Contributed by Andy Vaught and Paul Brook <paul@nowt.org>
3
 
4
This file is part of the GNU Fortran 95 runtime library (libgfortran).
5
 
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)
9
any later version.
10
 
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
18
executable.)
19
 
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.
24
 
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.  */
29
 
30
#include <stdio.h>
31
#include <stdlib.h>
32
#include <string.h>
33
#include <math.h>
34
#include <stddef.h>
35
 
36
#include "libgfortran.h"
37
 
38
/* Stupid function to be sure the constructor is always linked in, even
39
   in the case of static linking.  See PR libfortran/22298 for details.  */
40
void
41
stupid_function_name_for_static_linking (void)
42
{
43
  return;
44
}
45
 
46
/* This is the offset (in bytes) required to cast from logical(8)* to
47
   logical(4)*. and still get the same result.  Will be 0 for little-endian
48
   machines and 4 for big-endian machines.  */
49
int l8_to_l4_offset = 0;
50
 
51
 
52
/* Figure out endianness for this machine.  */
53
 
54
static void
55
determine_endianness (void)
56
{
57
  union
58
  {
59
    GFC_LOGICAL_8 l8;
60
    GFC_LOGICAL_4 l4[2];
61
  } u;
62
 
63
  u.l8 = 1;
64
  if (u.l4[0])
65
    l8_to_l4_offset = 0;
66
  else if (u.l4[1])
67
    l8_to_l4_offset = 1;
68
  else
69
    runtime_error ("Unable to determine machine endianness");
70
}
71
 
72
 
73
static int argc_save;
74
static char **argv_save;
75
 
76
/* Set the saved values of the command line arguments.  */
77
 
78
void
79
set_args (int argc, char **argv)
80
{
81
  argc_save = argc;
82
  argv_save = argv;
83
}
84
 
85
/* Retrieve the saved values of the command line arguments.  */
86
 
87
void
88
get_args (int *argc, char ***argv)
89
{
90
  *argc = argc_save;
91
  *argv = argv_save;
92
}
93
 
94
 
95
/* Initialize the runtime library.  */
96
 
97
static void __attribute__((constructor))
98
init (void)
99
{
100
  /* Figure out the machine endianness.  */
101
  determine_endianness ();
102
 
103
  /* Must be first */
104
  init_variables ();
105
 
106
  init_units ();
107
  set_fpu ();
108
  init_compile_options ();
109
 
110
#ifdef DEBUG
111
  /* Check for special command lines.  */
112
 
113
  if (argc > 1 && strcmp (argv[1], "--help") == 0)
114
    show_variables ();
115
 
116
  /* if (argc > 1 && strcmp(argv[1], "--resume") == 0) resume();  */
117
#endif
118
 
119
  random_seed(NULL,NULL,NULL);
120
}
121
 
122
 
123
/* Cleanup the runtime library.  */
124
 
125
static void __attribute__((destructor))
126
cleanup (void)
127
{
128
  close_units ();
129
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.