config.gcc (vax-*-bsd*): Add vax/bsd.h to ${tm_file}.
[official-gcc.git] / gcc / config / vax / vms.h
blob943882975d5f0b7b1317f8a6ddee08ba5b635afc
1 /* Output variables, constants and external declarations, for GNU compiler.
2 Copyright (C) 1988, 1994, 1995, 1996, 1997, 1999, 2001, 2002
3 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC 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 2, or (at your option)
10 any later version.
12 GNU CC 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 GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 #define TARGET_EXECUTABLE_SUFFIX ".exe"
23 #define TARGET_OBJECT_SUFFIX ".obj"
25 /* This enables certain macros in vax.h, which will make an indirect
26 reference to an external symbol an invalid address. This needs to be
27 defined before we include vax.h, since it determines which macros
28 are used for GO_IF_*. */
30 #define NO_EXTERNAL_INDIRECT_ADDRESS
32 #include "vax/vax.h"
34 #undef VMS_TARGET
35 #define VMS_TARGET 1
37 #undef LIB_SPEC
38 #undef TARGET_NAME
39 #undef TARGET_DEFAULT
40 #undef CALL_USED_REGISTERS
41 #undef STARTING_FRAME_OFFSET
43 #define TARGET_OS_CPP_BUILTINS() \
44 do \
45 { \
46 builtin_define_std ("vms"); \
47 builtin_define_std ("VMS"); \
48 builtin_assert ("system=vms"); \
50 builtin_define_std ("vax"); \
51 if (TARGET_G_FLOAT) \
52 builtin_define_std ("GFLOAT"); \
53 } \
54 while (0)
56 /* These match the definitions used in VAXCRTL, the VMS C run-time library */
58 #define SIZE_TYPE "unsigned int"
59 #define PTRDIFF_TYPE "int"
60 #define WCHAR_TYPE "unsigned int"
61 #define WCHAR_TYPE_SIZE 32 /* in bits */
63 /* Use memcpy for structure copying, and so forth. */
64 #define TARGET_MEM_FUNCTIONS
66 /* Strictly speaking, VMS does not use DBX at all, but the interpreter built
67 into gas only speaks straight DBX. */
69 #define DEFAULT_GDB_EXTENSIONS 0
71 #define TARGET_DEFAULT 1
72 #define TARGET_NAME "vax/vms"
74 /* The structure return address arrives as an "argument" on VMS. */
75 #undef STRUCT_VALUE_REGNUM
76 #define STRUCT_VALUE 0
77 #undef PCC_STATIC_STRUCT_RETURN
79 #define CALL_USED_REGISTERS {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1}
81 /* The run-time library routine VAXC$ESTABLISH (necessary when mixing
82 VMS exception handling and setjmp/longjmp in the same program) requires
83 that a hidden automatic variable at the top of the stack be reserved
84 for its use. We accomplish this by simply adding 4 bytes to the local
85 stack for all functions, and making sure that normal local variables
86 are 4 bytes lower on the stack then they would otherwise have been. */
88 #define STARTING_FRAME_OFFSET -4
90 /* This macro definition sets up a default value for `main' to return. */
91 #define DEFAULT_MAIN_RETURN c_expand_return (integer_one_node)
93 /* This is how to output a command to make the user-level label named NAME
94 defined for reference from other files. */
96 #undef ASM_GLOBALIZE_LABEL
97 #define ASM_GLOBALIZE_LABEL(FILE,NAME) \
98 do { fputs (".globl ", FILE); \
99 assemble_name (FILE, NAME); \
100 fputs ("\n", FILE); \
101 vms_check_external (NULL_TREE, NAME, 0); \
102 } while (0)
104 /* Under VMS we write the actual size of the storage to be allocated even
105 though the symbol is external. Although it is possible to give external
106 symbols a size of 0 (as unix does), the VMS linker does not make the
107 distinction between a variable definition and an external reference of a
108 variable, and thus the linker will not complain about a missing definition.
109 If we followed the unix example of giving external symbols a size of
110 zero, you tried to link a program where a given variable was externally
111 defined but none of the object modules contained a non-extern definition,
112 the linker would allocate 0 bytes for the variable, and any attempt to
113 use that variable would use the storage allocated to some other variable.
115 We must also select either const_section or data_section: this will indicate
116 whether or not the variable will get the readonly bit set. Since the
117 VMS linker does not distinguish between a variable's definition and an
118 external reference, all usages of a given variable must have the readonly
119 bit set the same way, or the linker will get confused and give warning
120 messages. */
122 /* We used to round the size up to a multiple of 4,
123 but that causes linker errors sometimes when the variable was initialized
124 since the size of its definition was not likewise rounded up. */
126 /* Note: the original ASM_OUTPUT_EXTERNAL code has been moved into
127 vms_check_external and vms_flush_pending_externals. */
129 #define ASM_OUTPUT_EXTERNAL(FILE,DECL,NAME) \
130 { if (DECL_INITIAL (DECL) == 0 && TREE_CODE (DECL) != FUNCTION_DECL) \
131 vms_check_external ((DECL), (NAME), 1); \
134 /* ASM_OUTPUT_EXTERNAL will have wait until after an initializer is
135 completed in order to switch sections for an external object, so
136 use the DECLARE_OBJECT hooks to manage deferred declarations. */
138 /* This is the default action for ASM_DECLARE_OBJECT_NAME, but if it
139 is explicitly defined, then ASM_FINISH_DECLARE_OBJECT will be used. */
141 #define ASM_DECLARE_OBJECT_NAME(ASM_OUT_FILE,NAME,DECL) \
142 ASM_OUTPUT_LABEL ((ASM_OUT_FILE), (NAME))
144 /* We don't need to do anything special to finish the current object, but it
145 should now be safe to output any deferred external global declarations. */
147 #define ASM_FINISH_DECLARE_OBJECT(FILE,DECL,TOPLVL,ATEND) \
148 vms_flush_pending_externals(FILE)
150 /* Anything still pending must be flushed at the very end. */
152 #define ASM_FILE_END(STREAM) \
153 vms_flush_pending_externals(STREAM)
155 /* Here we redefine ASM_OUTPUT_COMMON to select the data_section or the
156 const_section before writing the ".const" assembler directive.
157 If we were specifying a size of zero for external variables, we would
158 not have to select a section, since the assembler can assume that
159 when the size > 0, the storage is for a non-external, uninitialized
160 variable (for which a "const" declaration would be senseless),
161 and the assembler can make the storage read/write.
163 Since the ".const" directive specifies the actual size of the storage used
164 for both external and non-external variables, the assembler cannot
165 make this assumption, and thus it has no way of deciding if storage should
166 be read/write or read-only. To resolve this, we give the assembler some
167 assistance, in the form of a ".const" or a ".data" directive.
169 Under GCC 1.40, external variables were declared with a size of zero.
170 The GNU assembler, GAS, will recognize the "-2" switch when built for VMS;
171 when compiling programs with GCC 2.n this switch should be used or the
172 assembler will not give the read-only attribute to external constants.
173 Failure to use this switch will result in linker warning messages about
174 mismatched psect attributes. */
176 #undef ASM_OUTPUT_COMMON
178 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
179 ( ((TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl)) \
180 ? (const_section (), 0) : (data_section (), 0)), \
181 fputs (".comm ", (FILE)), \
182 assemble_name ((FILE), (NAME)), \
183 fprintf ((FILE), ",%u\n", (SIZE)))
185 /* We define this to prevent the name mangler from putting dollar signs into
186 function names. This isn't really needed, but it has been here for
187 some time and removing it would cause the object files generated by the
188 compiler to be incompatible with the object files from a compiler that
189 had this defined. Since it does no harm, we leave it in. */
191 #define NO_DOLLAR_IN_LABEL
193 /* Add a "const" section. This is viewed by the assembler as being nearly
194 the same as the "data" section, with the only difference being that a
195 flag is set for variables declared while in the const section. This
196 flag is used to determine whether or not the read/write bit should be
197 set in the Psect definition. */
199 #define EXTRA_SECTIONS in_const
201 #define EXTRA_SECTION_FUNCTIONS \
202 void \
203 const_section () \
205 if (in_section != in_const) { \
206 fprintf(asm_out_file,".const\n"); \
207 in_section = in_const; \
211 /* This is used by a hook in varasm.c to write the assembler directives
212 that are needed to tell the startup code which constructors need to
213 be run. */
215 #define TARGET_ASM_CONSTRUCTOR vms_asm_out_constructor
216 #define TARGET_ASM_DESTRUCTOR vms_asm_out_destructor
218 /* The following definitions are used in libgcc2.c with the __main
219 function. The _SHR symbol is used when the sharable image library
220 for the C++ library is used - this is picked up automatically by the linker
221 and this symbol points to the start of __CTOR_LIST__ from the C++ library.
222 If the C++ library is not used, then __CTOR_LIST_SHR__ occurs just after
223 __CTOR_LIST__, and essentially points to the same list as __CTOR_LIST. */
225 #ifdef L__main
227 #define __CTOR_LIST__ __gxx_init_0
228 #define __CTOR_LIST_END__ __gxx_init_2
230 #define __CTOR_LIST_SHR__ $$PsectAttributes_NOSHR$$__gxx_init_0_shr
231 #define __CTOR_LIST_SHR_END__ $$PsectAttributes_NOSHR$$__gxx_init_2_shr
233 #define DO_GLOBAL_CTORS_BODY \
234 do { \
235 func_ptr *p; \
236 extern func_ptr __CTOR_LIST__[1], __CTOR_LIST_END__[1]; \
237 extern func_ptr __CTOR_LIST_SHR__[1], __CTOR_LIST_SHR_END__[1]; \
238 if (&__CTOR_LIST_SHR__[0] != &__CTOR_LIST__[1]) \
239 for (p = __CTOR_LIST_SHR__ + 1; p < __CTOR_LIST_SHR_END__ ; p++ ) \
240 if (*p) (*p) (); \
241 for (p = __CTOR_LIST__ + 1; p < __CTOR_LIST_END__ ; p++ ) \
242 if (*p) (*p) (); \
243 do { /* arrange for `return' from main() to pass through exit() */ \
244 __label__ foo; \
245 int *callers_caller_fp = (int *) __builtin_frame_address (3); \
246 register int retval asm ("r0"); \
247 callers_caller_fp[4] = (int) && foo; \
248 break; /* out of do-while block */ \
249 foo: \
250 exit (retval); \
251 } while (0); \
252 } while (0)
254 #define __DTOR_LIST__ __gxx_clean_0
255 #define __DTOR_LIST_END__ __gxx_clean_2
257 #define __DTOR_LIST_SHR__ $$PsectAttributes_NOSHR$$__gxx_clean_0_shr
258 #define __DTOR_LIST_SHR_END__ $$PsectAttributes_NOSHR$$__gxx_clean_2_shr
260 #define DO_GLOBAL_DTORS_BODY \
261 do { \
262 func_ptr *p; \
263 extern func_ptr __DTOR_LIST__[1], __DTOR_LIST_END__[1]; \
264 extern func_ptr __DTOR_LIST_SHR__[1], __DTOR_LIST_SHR_END__[1]; \
265 for (p = __DTOR_LIST__ + 1; p < __DTOR_LIST_END__ ; p++ ) \
266 if (*p) (*p) (); \
267 if (&__DTOR_LIST_SHR__[0] != &__DTOR_LIST__[1]) \
268 for (p = __DTOR_LIST_SHR__ + 1; p < __DTOR_LIST_SHR_END__ ; p++ ) \
269 if (*p) (*p) (); \
270 } while (0)
272 #endif /* L__main */
274 /* Specify the list of include file directories. */
275 #define INCLUDE_DEFAULTS \
277 { "GNU_GXX_INCLUDE:", "G++", 1, 1 }, \
278 { "GNU_CC_INCLUDE:", "GCC", 0, 0 }, /* GNU includes */ \
279 { "SYS$SYSROOT:[SYSLIB.]", 0, 0, 0 }, /* VAX-11 "C" includes */ \
280 { ".", 0, 0, 1 }, /* Make normal VMS filespecs work. */ \
281 { 0, 0, 0, 0 } \