]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/alpha/vms-psxcrt0-64.c
Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.
[thirdparty/gcc.git] / gcc / config / alpha / vms-psxcrt0-64.c
CommitLineData
b6bfa876 1/* VMS 64bit crt0 returning Unix style condition codes .
748086b7 2 Copyright (C) 2001, 2009 Free Software Foundation, Inc.
b6bfa876
DR
3 Contributed by Douglas B. Rupp (rupp@gnat.com).
4
7ec022b2 5This file is part of GCC.
b6bfa876 6
7ec022b2 7GCC is free software; you can redistribute it and/or modify
b6bfa876 8it under the terms of the GNU General Public License as published by
748086b7 9the Free Software Foundation; either version 3, or (at your option)
b6bfa876
DR
10any later version.
11
7ec022b2 12GCC is distributed in the hope that it will be useful,
b6bfa876
DR
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
748086b7
JJ
17Under Section 7 of GPL version 3, you are granted additional
18permissions described in the GCC Runtime Library Exception, version
193.1, as published by the Free Software Foundation.
20
21You should have received a copy of the GNU General Public License and
22a copy of the GCC Runtime Library Exception along with this program;
23see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24<http://www.gnu.org/licenses/>. */
b6bfa876
DR
25
26#if !defined(__DECC)
27You Lose! This file can only be compiled with DEC C.
28#else
29
27d30956 30/* This file can only be compiled with DEC C, due to the call to
b6bfa876
DR
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
41extern void decc$main ();
42extern int main ();
43
44static int
45handler (sigargs, mechargs)
46 void *sigargs;
47 void *mechargs;
48{
49 return SS$_RESIGNAL;
50}
51
52int
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
a50aa827 77 /* Reallocate argv with 64-bit pointers. */
b6bfa876
DR
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