Mercurial > hg > CbC > CbC_gcc
comparison gcc/config/vms/vms-psxcrt0-64.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
52:c156f1bd5cd9 | 55:77e2b8dfacca |
---|---|
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 **) _malloc32 (sizeof (char *) * (argc + 1)); | |
79 | |
80 for (i = 0; i < argc; i++) | |
81 long_argv[i] = (char *) _strdup32 (argv[i]); | |
82 | |
83 long_argv[argc] = (char *) 0; | |
84 | |
85 for (i = 0; envp[i]; i++); | |
86 long_envp = (char **) _malloc32 (sizeof (char *) * (i + 1)); | |
87 | |
88 for (i = 0; envp[i]; i++) | |
89 long_envp[i] = (char *) _strdup32 (envp[i]); | |
90 | |
91 long_envp[i] = (char *) 0; | |
92 | |
93 #pragma __pointer_size short | |
94 | |
95 status = main (argc, long_argv, long_envp); | |
96 | |
97 /* Map into a range of 0 - 255. */ | |
98 status = status & 255; | |
99 | |
100 if (status > 0) | |
101 { | |
102 int save_status = status; | |
103 | |
104 status = C$_EXIT1 + ((status - 1) << STS$V_MSG_NO); | |
105 | |
106 /* An exit failure status requires a "severe" error. All status values | |
107 are defined in errno with a successful (1) severity but can be | |
108 changed to an error (2) severity by adding 1. In addition for | |
109 compatibility with UNIX exit() routines we inhibit a run-time error | |
110 message from being generated on exit(1). */ | |
111 | |
112 if (save_status == 1) | |
113 { | |
114 status++; | |
115 status |= STS$M_INHIB_MSG; | |
116 } | |
117 } | |
118 | |
119 if (status == 0) | |
120 status = SS$_NORMAL; | |
121 | |
122 return status; | |
123 } | |
124 #endif |