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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgfortran/] [runtime/] [stop.c] - Blame information for rev 737

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 733 jeremybenn
/* Implementation of the STOP statement.
2
   Copyright 2002, 2005, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
3
   Contributed by Paul Brook <paul@nowt.org>
4
 
5
This file is part of the GNU Fortran runtime library (libgfortran).
6
 
7
Libgfortran is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public
9
License as published by the Free Software Foundation; either
10
version 3 of the License, or (at your option) any later version.
11
 
12
Libgfortran is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
Under Section 7 of GPL version 3, you are granted additional
18
permissions described in the GCC Runtime Library Exception, version
19
3.1, as published by the Free Software Foundation.
20
 
21
You should have received a copy of the GNU General Public License and
22
a copy of the GCC Runtime Library Exception along with this program;
23
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24
<http://www.gnu.org/licenses/>.  */
25
 
26
#include "libgfortran.h"
27
#include <stdlib.h>
28
#include <string.h>
29
#include <unistd.h>
30
 
31
/* A numeric STOP statement.  */
32
 
33
extern void stop_numeric (GFC_INTEGER_4)
34
  __attribute__ ((noreturn));
35
export_proto(stop_numeric);
36
 
37
void
38
stop_numeric (GFC_INTEGER_4 code)
39
{
40
  if (code == -1)
41
    code = 0;
42
  else
43
    st_printf ("STOP %d\n", (int)code);
44
 
45
  exit (code);
46
}
47
 
48
 
49
/* A Fortran 2008 numeric STOP statement.  */
50
 
51
extern void stop_numeric_f08 (GFC_INTEGER_4)
52
  __attribute__ ((noreturn));
53
export_proto(stop_numeric_f08);
54
 
55
void
56
stop_numeric_f08 (GFC_INTEGER_4 code)
57
{
58
  st_printf ("STOP %d\n", (int)code);
59
  exit (code);
60
}
61
 
62
 
63
/* A character string or blank STOP statement.  */
64
 
65
void
66
stop_string (const char *string, GFC_INTEGER_4 len)
67
{
68
  if (string)
69
    {
70
      estr_write ("STOP ");
71
      (void) write (STDERR_FILENO, string, len);
72
      estr_write ("\n");
73
    }
74
  exit (0);
75
}
76
 
77
 
78
/* Per Fortran 2008, section 8.4:  "Execution of a STOP statement initiates
79
   normal termination of execution. Execution of an ERROR STOP statement
80
   initiates error termination of execution."  Thus, error_stop_string returns
81
   a nonzero exit status code.  */
82
 
83
extern void error_stop_string (const char *, GFC_INTEGER_4)
84
  __attribute__ ((noreturn));
85
export_proto(error_stop_string);
86
 
87
void
88
error_stop_string (const char *string, GFC_INTEGER_4 len)
89
{
90
  estr_write ("ERROR STOP ");
91
  (void) write (STDERR_FILENO, string, len);
92
  estr_write ("\n");
93
 
94
  exit (1);
95
}
96
 
97
 
98
/* A numeric ERROR STOP statement.  */
99
 
100
extern void error_stop_numeric (GFC_INTEGER_4)
101
  __attribute__ ((noreturn));
102
export_proto(error_stop_numeric);
103
 
104
void
105
error_stop_numeric (GFC_INTEGER_4 code)
106
{
107
  st_printf ("ERROR STOP %d\n", (int) code);
108
  exit (code);
109
}

powered by: WebSVN 2.1.0

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