comparison gcc/config/alpha/vms-psxcrt0-64.c @ 0:a06113de4d67

first commit
author kent <kent@cr.ie.u-ryukyu.ac.jp>
date Fri, 17 Jul 2009 14:47:48 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:a06113de4d67
1 /* VMS 64bit 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 and the pragmas pointer_size. */
32
33 #pragma __pointer_size short
34
35 #include <stdlib.h>
36 #include <string.h>
37 #include <ssdef.h>
38 #include <stsdef.h>
39 #include <errnodef.h>
40
41 extern void decc$main ();
42 extern int main ();
43
44 static int
45 handler (sigargs, mechargs)
46 void *sigargs;
47 void *mechargs;
48 {
49 return SS$_RESIGNAL;
50 }
51
52 int
53 __main (arg1, arg2, arg3, image_file_desc, arg5, arg6)
54 void *arg1, *arg2, *arg3;
55 void *image_file_desc;
56 void *arg5, *arg6)
57 {
58 int argc;
59 char **argv;
60 char **envp;
61
62 #pragma __pointer_size long
63
64 int i;
65 char **long_argv;
66 char **long_envp;
67 int status;
68
69 #pragma __pointer_size short
70
71 lib$establish (handler);
72 decc$main (arg1, arg2, arg3, image_file_desc,
73 arg5, arg6, &argc, &argv, &envp);
74
75 #pragma __pointer_size long
76
77 /* Reallocate argv with 64-bit pointers. */
78 long_argv = (char **) malloc (sizeof (char *) * (argc + 1));
79
80 for (i = 0; i < argc; i++)
81 long_argv[i] = strdup (argv[i]);
82
83 long_argv[argc] = (char *) 0;
84
85 long_envp = (char **) malloc (sizeof (char *) * 5);
86
87 for (i = 0; envp[i]; i++)
88 long_envp[i] = strdup (envp[i]);
89
90 long_envp[i] = (char *) 0;
91
92 #pragma __pointer_size short
93
94 status = main (argc, long_argv, long_envp);
95
96 /* Map into a range of 0 - 255. */
97 status = status & 255;
98
99 if (status > 0)
100 {
101 int save_status = status;
102
103 status = C$_EXIT1 + ((status - 1) << STS$V_MSG_NO);
104
105 /* An exit failure status requires a "severe" error. All status values
106 are defined in errno with a successful (1) severity but can be
107 changed to an error (2) severity by adding 1. In addition for
108 compatibility with UNIX exit() routines we inhibit a run-time error
109 message from being generated on exit(1). */
110
111 if (save_status == 1)
112 {
113 status++;
114 status |= STS$M_INHIB_MSG;
115 }
116 }
117
118 if (status == 0)
119 status = SS$_NORMAL;
120
121 return status;
122 }
123 #endif