OSDN Git Service

PR target/42774
[pf3gnuchains/gcc-fork.git] / gcc / config / vms / vms-psxcrt0.c
1 /* VMS crt0 returning Unix style condition codes .
2    Copyright (C) 2001, 2009 Free Software Foundation, Inc.
3    Contributed by Douglas B. Rupp (rupp@gnat.com).
4
5    This file is part of GCC.
6
7    GCC is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3, or (at your option)
10    any later version.
11
12    GCC 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 #if !defined(__DECC)
27 You Lose! This file can only be compiled with DEC C.
28 #else
29
30 /* This file can only be compiled with DEC C, due to the call to
31    lib$establish.  */
32
33 #include <stdlib.h>
34 #include <string.h>
35 #include <ssdef.h>
36 #include <stsdef.h>
37 #include <errnodef.h>
38
39 extern void decc$main ();
40 extern int main ();
41
42 static int
43 handler (sigargs, mechargs)
44      void *sigargs;
45      void *mechargs;
46 {
47   return SS$_RESIGNAL;
48 }
49
50 int
51 __main (arg1, arg2, arg3, image_file_desc, arg5, arg6)
52      void *arg1, *arg2, *arg3;
53      void *image_file_desc;
54      void *arg5, *arg6;
55 {
56   int argc;
57   char **argv;
58   char **envp;
59   int status;
60
61   lib$establish (handler);
62   decc$main (arg1, arg2, arg3, image_file_desc, arg5, arg6,
63              &argc, &argv, &envp);
64
65   status = main (argc, argv, envp);
66
67   /* Map into a range of 0 - 255.  */
68   status = status & 255;
69
70   if (status > 0)
71     {
72       int save_status = status;
73
74       status = C$_EXIT1 + ((status - 1) << STS$V_MSG_NO);
75
76       /* An exit failure status requires a "severe" error
77          All status values are defined in errno with a successful
78          (1) severity but can be changed to an error (2) severity by adding 1.
79          In addition for compatibility with UNIX exit() routines we inhibit
80          a run-time error message from being generated on exit(1).  */
81
82       if (save_status == 1)
83         {
84           status++;
85           status |= STS$M_INHIB_MSG;
86         }
87     }
88
89   if (status == 0)
90     status = SS$_NORMAL;
91
92   return status;
93 }
94 #endif