OSDN Git Service

PR target/42774
[pf3gnuchains/gcc-fork.git] / gcc / config / vms / vms-crt0-64.c
1 /* VMS 64bit crt0 returning VMS 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
39 extern void decc$main ();
40
41 extern int main ();
42
43 static int
44 handler (sigargs, mechargs)
45      void *sigargs;
46      void *mechargs;
47 {
48   return SS$_RESIGNAL;
49 }
50
51 int
52 __main (arg1, arg2, arg3, image_file_desc, arg5, arg6)
53      void *arg1, *arg2, *arg3;
54      void *image_file_desc;
55      void *arg5, *arg6;
56 {
57   int argc;
58   char **argv;
59   char **envp;
60
61 #pragma __pointer_size long
62
63   int i;
64   char **long_argv;
65   char **long_envp;
66
67 #pragma __pointer_size short
68
69   lib$establish (handler);
70   decc$main (arg1, arg2, arg3, image_file_desc,
71              arg5, arg6, &argc, &argv, &envp);
72
73 #pragma __pointer_size long
74
75   /* Reallocate argv with 64 bit pointers.  */
76   long_argv = (char **) _malloc32 (sizeof (char *) * (argc + 1));
77
78   for (i = 0; i < argc; i++)
79     long_argv[i] = (char *) _strdup32 (argv[i]);
80
81   long_argv[argc] = (char *) 0;
82
83   for (i = 0; envp[i]; i++);
84   long_envp = (char **) _malloc32 (sizeof (char *) * (i + 1));
85
86   for (i = 0; envp[i]; i++)
87     long_envp[i] = (char *) _strdup32 (envp[i]);
88
89   long_envp[i] = (char *) 0;
90
91 #pragma __pointer_size short
92
93   return main (argc, long_argv, long_envp);
94 }
95 #endif