--- gcc/config/vax/vms.h 2018/04/24 18:10:25 1.1.1.1 +++ gcc/config/vax/vms.h 2018/04/24 18:30:00 1.1.1.4 @@ -1,5 +1,5 @@ /* Output variables, constants and external declarations, for GNU compiler. - Copyright (C) 1988 Free Software Foundation, Inc. + Copyright (C) 1988, 1994, 1995 Free Software Foundation, Inc. This file is part of GNU CC. @@ -15,7 +15,10 @@ GNU General Public License for more deta You should have received a copy of the GNU General Public License along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#define VMS_TARGET /* This enables certain macros in vax.h, which will make an indirect reference to an external symbol an invalid address. This needs to be @@ -37,7 +40,9 @@ the Free Software Foundation, 675 Mass A /* Predefine this in CPP because VMS limits the size of command options and GNU CPP is not used on VMS except with GNU C. */ -#define CPP_PREDEFINES "-Dvax -Dvms -DVMS -D__GNUC__=2" +#define CPP_PREDEFINES \ +"-Dvax -Dvms -DVMS -D__vax__ -D__vms__ -D__VMS__\ + -D__GNUC__=2 -D__GNUC_MINOR__=7 -Asystem(vms) -Acpu(vax) -Amachine(vax)" /* These match the definitions used in VAXCRTL, the VMS C run-time library */ @@ -86,14 +91,14 @@ the Free Software Foundation, 675 Mass A if (newsize >= 64) fprintf (FILE, "\tmovab %d(sp),sp\n", -newsize);\ else fprintf (FILE, "\tsubl2 $%d,sp\n", newsize); } -#define __MAIN_NAME " main (" +#define __MAIN_NAME " main(" /* * The MAYBE_VMS_FUNCTION_PROLOGUE macro works for both gcc and g++. It * first checks to see if the current routine is "main", which will only * happen for GCC, and add the jsb if it is. If is not the case then try and * see if __MAIN_NAME is part of current_function_name, which will only happen * if we are running g++, and add the jsb if it is. In gcc there should never - * be a space in the function name, and in g++ there is always a "(" in the + * be a paren in the function name, and in g++ there is always a "(" in the * function name, thus there should never be any confusion. * * Adjusting the stack pointer by 4 before calling C$MAIN_ARGS is required @@ -138,7 +143,7 @@ the Free Software Foundation, 675 Mass A do { fputs (".globl ", FILE); \ assemble_name (FILE, NAME); \ fputs ("\n", FILE); \ - vms_check_external (NAME); \ + vms_check_external (NULL_TREE, NAME, 0); \ } while (0) /* Under VMS we write the actual size of the storage to be allocated even @@ -163,28 +168,39 @@ the Free Software Foundation, 675 Mass A but that causes linker errors sometimes when the variable was initialized since the size of its definition was not likewise rounded up. */ +/* Note: the original ASM_OUTPUT_EXTERNAL code has been moved into + vms_check_external and vms_flush_pending_externals. */ + #define ASM_OUTPUT_EXTERNAL(FILE,DECL,NAME) \ -{ if (DECL_INITIAL (DECL) == 0 && TREE_CODE (DECL) != FUNCTION_DECL \ - && ! vms_check_external (NAME)) \ - { \ - if (TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl)) \ - const_section (); \ - else \ - data_section (); \ - fputs (".comm ", (FILE)); \ - assemble_name ((FILE), (NAME)); \ - if (DECL_SIZE (DECL) == 0) \ - fprintf ((FILE), ",0\n"); \ - else \ - { \ - tree size_tree; \ - size_tree = size_binop (CEIL_DIV_EXPR, \ - DECL_SIZE (DECL), size_int (BITS_PER_UNIT)); \ - fprintf ((FILE), ",%d\n", TREE_INT_CST_LOW (size_tree)); \ - } \ - } \ +{ if (DECL_INITIAL (DECL) == 0 && TREE_CODE (DECL) != FUNCTION_DECL) \ + vms_check_external ((DECL), (NAME), 1); \ +} + +/* ASM_OUTPUT_EXTERNAL will have wait until after an initializer is + completed in order to switch sections for an external object, so + use the DECLARE_OBJECT hooks to manage deferred declarations. */ + +/* This is the default action for ASM_DECLARE_OBJECT_NAME, but if it + is explicitly defined, then ASM_FINISH_DECLARE_OBJECT will be used. */ + +#define ASM_DECLARE_OBJECT_NAME(ASM_OUT_FILE,NAME,DECL) \ +{ if (output_bytecode) \ + BC_OUTPUT_LABEL ((ASM_OUT_FILE), (NAME)); \ + else \ + ASM_OUTPUT_LABEL ((ASM_OUT_FILE), (NAME)); \ } +/* We don't need to do anything special to finish the current object, but it + should now be safe to output any deferred external global declarations. */ + +#define ASM_FINISH_DECLARE_OBJECT(FILE,DECL,TOPLVL,ATEND) \ + vms_flush_pending_externals(FILE) + +/* Anything still pending must be flushed at the very end. */ + +#define ASM_FILE_END(STREAM) \ + vms_flush_pending_externals(STREAM) + /* Here we redefine ASM_OUTPUT_COMMON to select the data_section or the const_section before writing the ".const" assembler directive. If we were specifying a size of zero for external variables, we would @@ -253,7 +269,10 @@ const_section () \ { \ if (TREE_CODE (T) == VAR_DECL) \ { \ - if (TREE_READONLY (T) && ! TREE_THIS_VOLATILE (T)) \ + if (TREE_READONLY (T) && ! TREE_THIS_VOLATILE (T) \ + && DECL_INITIAL (T) \ + && (DECL_INITIAL (T) == error_mark_node \ + || TREE_CONSTANT (DECL_INITIAL (T)))) \ { \ if (TREE_PUBLIC (T)) \ const_section (); \ @@ -298,6 +317,9 @@ const_section () \ fputc ('\n', (FILE)); \ } +/* True for VMS V4.6 and later. */ +#define HAVE_ATEXIT + /* The following definitions are used in libgcc2.c with the __main function. The _SHR symbol is used when the sharable image library for libg++ is used - this is picked up automatically by the linker @@ -316,25 +338,22 @@ const_section () \ #define DO_GLOBAL_CTORS_BODY \ do { \ func_ptr *p; \ - extern func_ptr __CTOR_LIST__[1]; \ - extern func_ptr __CTOR_LIST_END__[1]; \ - extern func_ptr __CTOR_LIST_SHR__[1]; \ - extern func_ptr __CTOR_LIST_SHR_END__[1]; \ - if( &__CTOR_LIST_SHR__[0] != &__CTOR_LIST__[1]) \ - for (p = __CTOR_LIST_SHR__ + 1; p < __CTOR_LIST_SHR_END__ ; p++ ) \ - if (*p) (*p) (); \ + extern func_ptr __CTOR_LIST__[1], __CTOR_LIST_END__[1]; \ + extern func_ptr __CTOR_LIST_SHR__[1], __CTOR_LIST_SHR_END__[1]; \ + if (&__CTOR_LIST_SHR__[0] != &__CTOR_LIST__[1]) \ + for (p = __CTOR_LIST_SHR__ + 1; p < __CTOR_LIST_SHR_END__ ; p++ ) \ + if (*p) (*p) (); \ for (p = __CTOR_LIST__ + 1; p < __CTOR_LIST_END__ ; p++ ) \ if (*p) (*p) (); \ - atexit (__do_global_dtors); \ - { \ + do { /* arrange for `return' from main() to pass through exit() */ \ __label__ foo; \ int *callers_caller_fp = (int *) __builtin_frame_address (3); \ register int retval asm ("r0"); \ callers_caller_fp[4] = (int) && foo; \ - return; \ + break; /* out of do-while block */ \ foo: \ exit (retval); \ - } \ + } while (0); \ } while (0) #define __DTOR_LIST__ __gxx_clean_0 @@ -346,15 +365,13 @@ do { \ #define DO_GLOBAL_DTORS_BODY \ do { \ func_ptr *p; \ - extern func_ptr __DTOR_LIST__[1]; \ - extern func_ptr __DTOR_LIST_END__[1]; \ - extern func_ptr __DTOR_LIST_SHR__[1]; \ - extern func_ptr __DTOR_LIST_SHR_END__[1]; \ + extern func_ptr __DTOR_LIST__[1], __DTOR_LIST_END__[1]; \ + extern func_ptr __DTOR_LIST_SHR__[1], __DTOR_LIST_SHR_END__[1]; \ for (p = __DTOR_LIST__ + 1; p < __DTOR_LIST_END__ ; p++ ) \ if (*p) (*p) (); \ - if( &__DTOR_LIST_SHR__[0] != &__DTOR_LIST__[1]) \ - for (p = __DTOR_LIST_SHR__ + 1; p < __DTOR_LIST_SHR_END__ ; p++ ) \ - if (*p) (*p) (); \ + if (&__DTOR_LIST_SHR__[0] != &__DTOR_LIST__[1]) \ + for (p = __DTOR_LIST_SHR__ + 1; p < __DTOR_LIST_SHR_END__ ; p++ ) \ + if (*p) (*p) (); \ } while (0) #endif /* L__main */