1 /* Definitions of target machine GNU compiler. 32bit VMS version.
2 Copyright (C) 2009, 2010 Free Software Foundation, Inc.
3 Contributed by Douglas B Rupp (rupp@gnat.com).
5 This file is part of GCC.
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)
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.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
25 #include "vms-protos.h"
29 /* Correlation of standard CRTL names with DECCRTL function names. */
31 /* Name is for a function that allocate memory. Use the 64bit version
33 #define VMS_CRTL_MALLOC (1 << 0)
35 /* If long pointer are enabled, use _NAME64 instead. */
36 #define VMS_CRTL_64 (1 << 1)
38 /* Use tNAME instead. To be applied after the previous rule. */
39 #define VMS_CRTL_FLOAT (1 << 2)
41 /* Prepend __bsd44__ before the name. To be applied after the P64
43 #define VMS_CRTL_BSD44 (1 << 3)
45 /* Prepend x before the name for printf like functions. */
46 #define VMS_CRTL_PRNTF (1 << 4)
50 /* The standard C name. */
51 const char *const name
;
53 /* Flags to drive the translation. */
57 /* Map for the translation. */
59 static const struct vms_crtl_name vms_crtl_names
[] =
61 #include "vms-crtlmap.h"
64 /* Number of entires in the above array. */
66 #define NBR_CRTL_NAMES (sizeof (vms_crtl_names) / sizeof (*vms_crtl_names))
68 /* List of aliased identifiers. They must be persistant accross gc. */
70 static GTY(()) VEC(tree
,gc
) *aliases_id
;
72 /* Add a CRTL translation. This simply use the transparent alias
73 mechanism, which is platform independant and works with the
74 #pragma extern_prefix (which set the assembler name). */
77 vms_add_crtl_xlat (const char *name
, size_t nlen
,
78 const char *id_str
, size_t id_len
)
82 targ
= get_identifier_with_length (name
, nlen
);
83 gcc_assert (!IDENTIFIER_TRANSPARENT_ALIAS (targ
));
84 IDENTIFIER_TRANSPARENT_ALIAS (targ
) = 1;
85 TREE_CHAIN (targ
) = get_identifier_with_length (id_str
, id_len
);
87 VEC_safe_push (tree
, gc
, aliases_id
, targ
);
89 /* printf ("vms: %s (%p) -> %.*s\n", name, targ, id_len, id_str); */
92 /* Do VMS specific stuff on builtins: disable the ones that are not
93 standard, mangle names. */
96 vms_patch_builtins (void)
98 /* enum built_in_function bi; */
101 /* Fwrite on VMS is non-standard. */
102 if (builtin_decl_implicit_p (BUILT_IN_WRITE
))
103 set_builtin_decl_implicit_p (BUILT_IN_WRITE
, false);
105 if (builtin_decl_implicit_p (BUILT_IN_WRITE_UNLOCKED
))
106 set_builtin_decl_implicit_p (BUILT_IN_WRITE_UNLOCKED
, false);
108 /* Define aliases for names. */
109 for (i
= 0; i
< NBR_CRTL_NAMES
; i
++)
111 const struct vms_crtl_name
*n
= &vms_crtl_names
[i
];
112 char res
[VMS_CRTL_MAXLEN
+ 3 + 9 + 1 + 1];
116 /* Add the dec-c prefix. */
117 memcpy (res
, "decc$", 5);
120 if (n
->flags
& VMS_CRTL_BSD44
)
122 memcpy (res
+ rlen
, "__bsd44__", 9);
126 if (n
->flags
& VMS_CRTL_FLOAT
)
129 if (n
->flags
& VMS_CRTL_PRNTF
)
132 nlen
= strlen (n
->name
);
133 memcpy (res
+ rlen
, n
->name
, nlen
);
135 if ((n
->flags
& VMS_CRTL_64
) == 0)
136 vms_add_crtl_xlat (n
->name
, nlen
, res
, rlen
+ nlen
);
139 char alt
[VMS_CRTL_MAXLEN
+ 3];
142 /* Add three translations:
145 X -> X if short, _X64 if long. */
147 memcpy (alt
+ 1, n
->name
, nlen
);
148 alt
[1 + nlen
+ 0] = '3';
149 alt
[1 + nlen
+ 1] = '2';
150 alt
[1 + nlen
+ 2] = 0;
151 vms_add_crtl_xlat (alt
, nlen
+ 3, res
, rlen
+ nlen
);
153 use_64
= (((n
->flags
& VMS_CRTL_64
) && POINTER_SIZE
== 64)
154 || ((n
->flags
& VMS_CRTL_MALLOC
)
155 && TARGET_MALLOC64
));
157 vms_add_crtl_xlat (n
->name
, nlen
, res
, rlen
+ nlen
);
160 memcpy (res
+ rlen
, n
->name
, nlen
);
161 res
[rlen
+ nlen
+ 0] = '6';
162 res
[rlen
+ nlen
+ 1] = '4';
165 vms_add_crtl_xlat (n
->name
, nlen
, res
, rlen
+ nlen
+ 2);
167 alt
[1 + nlen
+ 0] = '6';
168 alt
[1 + nlen
+ 1] = '4';
169 vms_add_crtl_xlat (alt
, nlen
+ 3, res
, rlen
+ nlen
+ 2);