From: Tristan Gingold Date: Mon, 27 Jun 2011 12:51:09 +0000 (+0000) Subject: re PR target/44241 (vms-crtl.h, vms-crtl-64.h need many more symbols) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=db8b22ef4925f80ce5cabb585852896548f78c7e;p=gcc.git re PR target/44241 (vms-crtl.h, vms-crtl-64.h need many more symbols) 2011-06-27 Tristan Gingold PR target/44241 * config/vms/vms-protos.h: New file. * config/vms/vms-crtlmap.map: New file. * config/vms/vms.c: New file. * config/vms/make-crtlmap.awk: New file. * config/vms/vms-crtl.h: File removed. * config/vms/vms-crtl-64.h: File removed. * config/vms/t-vms (vms-crtlmap.h, vms.o): New targets. * config/alpha/vms64.h: Do not include vms-crtl-64.h * config/alpha/alpha.c (alpha_init_builtins): Remove code to clear some builtins on VMS. Calls vms_patch_builtins. (avms_asm_output_external): Remove. * config/alpha/vms.h (ASM_OUTPUT_EXTERNAL): Remove. (struct crtl_name_spec): Remove (DO_CTRL_NAMES): Remove. * config/ia64/vms.h (struct crtl_name_spec): Remove (DO_CTRL_NAMES): Remove. * config/ia64/ia64.c (alpha_init_builtins): Remove code to clear some builtins on VMS. Calls vms_patch_builtins. (ia64_asm_output_external): Remove DO_CRTL_NAME. * config/ia64/vms64.h: Do not include vms-crtl-64.h * config.gcc (*-*-*vms*): Define extra_objs, target_gtfiles, tm_p_file. From-SVN: r175523 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c687dbc5a3e..2e1bc76b093 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,29 @@ +2011-06-27 Tristan Gingold + + PR target/44241 + * config/vms/vms-protos.h: New file. + * config/vms/vms-crtlmap.map: New file. + * config/vms/vms.c: New file. + * config/vms/make-crtlmap.awk: New file. + * config/vms/vms-crtl.h: File removed. + * config/vms/vms-crtl-64.h: File removed. + * config/vms/t-vms (vms-crtlmap.h, vms.o): New targets. + * config/alpha/vms64.h: Do not include vms-crtl-64.h + * config/alpha/alpha.c (alpha_init_builtins): Remove code to + clear some builtins on VMS. Calls vms_patch_builtins. + (avms_asm_output_external): Remove. + * config/alpha/vms.h (ASM_OUTPUT_EXTERNAL): Remove. + (struct crtl_name_spec): Remove + (DO_CTRL_NAMES): Remove. + * config/ia64/vms.h (struct crtl_name_spec): Remove + (DO_CTRL_NAMES): Remove. + * config/ia64/ia64.c (alpha_init_builtins): Remove code to + clear some builtins on VMS. Calls vms_patch_builtins. + (ia64_asm_output_external): Remove DO_CRTL_NAME. + * config/ia64/vms64.h: Do not include vms-crtl-64.h + * config.gcc (*-*-*vms*): Define extra_objs, target_gtfiles, + tm_p_file. + 2011-06-27 Tristan Gingold * config/alpha/alpha.c (alpha_end_function): Always generate .end diff --git a/gcc/config.gcc b/gcc/config.gcc index a1dbd1a8139..14c7a81f45b 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -721,6 +721,9 @@ case ${target} in extra_options="${extra_options} vms/vms.opt" xmake_file=vms/x-vms tmake_file="vms/t-vms" + extra_objs="vms.o" + target_gtfiles="$target_gtfiles \$(srcdir)/config/vms/vms.c" + tm_p_file="${tm_p_file} vms/vms-protos.h" if test x$gnu_ld != xyes; then # Build wrappers for native case. extra_programs="ld\$(exeext) ar\$(exeext)" diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 510c1a81568..5d656f12963 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -6367,12 +6367,6 @@ alpha_init_builtins (void) dimode_integer_type_node = lang_hooks.types.type_for_mode (DImode, 0); - /* Fwrite on VMS is non-standard. */ -#if TARGET_ABI_OPEN_VMS - implicit_built_in_decls[(int) BUILT_IN_FWRITE] = NULL_TREE; - implicit_built_in_decls[(int) BUILT_IN_FWRITE_UNLOCKED] = NULL_TREE; -#endif - ftype = build_function_type_list (dimode_integer_type_node, NULL_TREE); alpha_add_builtins (zero_arg_builtins, ARRAY_SIZE (zero_arg_builtins), ftype); @@ -6409,6 +6403,8 @@ alpha_init_builtins (void) NULL_TREE); alpha_builtin_function ("__builtin_revert_vms_condition_handler", ftype, ALPHA_BUILTIN_REVERT_VMS_CONDITION_HANDLER, 0); + + vms_patch_builtins (); } alpha_v8qi_u = build_vector_type (unsigned_intQI_type_node, 8); @@ -8169,15 +8165,6 @@ alpha_end_function (FILE *file, const char *fnname, tree decl ATTRIBUTE_UNUSED) inside_function = FALSE; } -#if TARGET_ABI_OPEN_VMS -void avms_asm_output_external (FILE *file, tree decl ATTRIBUTE_UNUSED, const char *name) -{ -#ifdef DO_CRTL_NAMES - DO_CRTL_NAMES; -#endif -} -#endif - #if TARGET_ABI_OSF /* Emit a tail call to FUNCTION after adjusting THIS by DELTA. diff --git a/gcc/config/alpha/vms.h b/gcc/config/alpha/vms.h index f730ea1b5dd..fc74c236a37 100644 --- a/gcc/config/alpha/vms.h +++ b/gcc/config/alpha/vms.h @@ -225,55 +225,6 @@ typedef struct {int num_args; enum avms_arg_type atypes[6];} avms_arg_info; #define LINK_EH_SPEC "vms-dwarf2eh.o%s " #define LINK_GCC_C_SEQUENCE_SPEC "%G" -#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \ - avms_asm_output_external (FILE, DECL, NAME) - -typedef struct crtl_name_spec -{ - const char *const name; - const char *deccname; - int referenced; -} crtl_name_spec; - -#include "config/vms/vms-crtl.h" - -/* Alias CRTL names to 32/64bit DECCRTL functions. - Fixme: This should do a binary search. */ -#define DO_CRTL_NAMES \ - do \ - { \ - int i; \ - static crtl_name_spec vms_crtl_names[] = CRTL_NAMES; \ - static int malloc64_init = 0; \ - \ - if ((malloc64_init == 0) && TARGET_MALLOC64) \ - { \ - for (i=0; vms_crtl_names [i].name; i++) \ - { \ - if (strcmp ("calloc", vms_crtl_names [i].name) == 0) \ - vms_crtl_names [i].deccname = "decc$_calloc64"; \ - else \ - if (strcmp ("malloc", vms_crtl_names [i].name) == 0) \ - vms_crtl_names [i].deccname = "decc$_malloc64"; \ - else \ - if (strcmp ("realloc", vms_crtl_names [i].name) == 0) \ - vms_crtl_names [i].deccname = "decc$_realloc64"; \ - else \ - if (strcmp ("strdup", vms_crtl_names [i].name) == 0) \ - vms_crtl_names [i].deccname = "decc$_strdup64"; \ - } \ - malloc64_init = 1; \ - } \ - for (i=0; vms_crtl_names [i].name; i++) \ - if (!vms_crtl_names [i].referenced && \ - (strcmp (name, vms_crtl_names [i].name) == 0)) \ - { \ - fprintf (file, "\t%s=%s\n", \ - name, vms_crtl_names [i].deccname); \ - vms_crtl_names [i].referenced = 1; \ - } \ - } while (0) - /* This is how to output an assembler line that says to advance the location counter to a multiple of 2**LOG bytes. */ diff --git a/gcc/config/alpha/vms64.h b/gcc/config/alpha/vms64.h index 07424d0f292..495d3c6167d 100644 --- a/gcc/config/alpha/vms64.h +++ b/gcc/config/alpha/vms64.h @@ -49,5 +49,3 @@ along with GCC; see the file COPYING3. If not see /* Defaults to "long int" */ #undef SIZE_TYPE #undef PTRDIFF_TYPE - -# include "config/vms/vms-crtl-64.h" diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index 901481358b3..b0d9dc8a746 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -10133,8 +10133,7 @@ ia64_init_builtins (void) /* Fwrite on VMS is non-standard. */ if (TARGET_ABI_OPEN_VMS) { - implicit_built_in_decls[(int) BUILT_IN_FWRITE] = NULL_TREE; - implicit_built_in_decls[(int) BUILT_IN_FWRITE_UNLOCKED] = NULL_TREE; + vms_patch_builtins (); } #define def_builtin(name, type, code) \ @@ -10263,10 +10262,6 @@ ia64_asm_output_external (FILE *file, tree decl, const char *name) int need_visibility = ((*targetm.binds_local_p) (decl) && maybe_assemble_visibility (decl)); -#ifdef DO_CRTL_NAMES - DO_CRTL_NAMES; -#endif - /* GNU as does not need anything here, but the HP linker does need something for external functions. */ if ((TARGET_HPUX_LD || !TARGET_GNU_AS) diff --git a/gcc/config/ia64/vms.h b/gcc/config/ia64/vms.h index 5d87e711856..847d79afa1d 100644 --- a/gcc/config/ia64/vms.h +++ b/gcc/config/ia64/vms.h @@ -132,52 +132,6 @@ STATIC func_ptr __CTOR_LIST__[1] \ /* Maybe same as HPUX? Needs to be checked. */ #define JMP_BUF_SIZE (8 * 76) -typedef struct crtl_name_spec -{ - const char *const name; - const char *deccname; - int referenced; -} crtl_name_spec; - -#include "config/vms/vms-crtl.h" - -/* Alias CRTL names to 32/64bit DECCRTL functions. - Fixme: This should do a binary search. */ -#define DO_CRTL_NAMES \ - do \ - { \ - int i; \ - static crtl_name_spec vms_crtl_names[] = CRTL_NAMES; \ - static int malloc64_init = 0; \ - \ - if ((malloc64_init == 0) && TARGET_MALLOC64) \ - { \ - for (i=0; vms_crtl_names [i].name; i++) \ - { \ - if (strcmp ("calloc", vms_crtl_names [i].name) == 0) \ - vms_crtl_names [i].deccname = "decc$_calloc64"; \ - else \ - if (strcmp ("malloc", vms_crtl_names [i].name) == 0) \ - vms_crtl_names [i].deccname = "decc$_malloc64"; \ - else \ - if (strcmp ("realloc", vms_crtl_names [i].name) == 0) \ - vms_crtl_names [i].deccname = "decc$_realloc64"; \ - else \ - if (strcmp ("strdup", vms_crtl_names [i].name) == 0) \ - vms_crtl_names [i].deccname = "decc$_strdup64"; \ - } \ - malloc64_init = 1; \ - } \ - for (i=0; vms_crtl_names [i].name; i++) \ - if (!vms_crtl_names [i].referenced && \ - (strcmp (name, vms_crtl_names [i].name) == 0)) \ - { \ - fprintf (file, "\t.alias %s, \"%s\"\n", \ - name, vms_crtl_names [i].deccname); \ - vms_crtl_names [i].referenced = 1; \ - } \ - } while (0) - #undef SUBTARGET_OPTIMIZATION_OPTIONS #define SUBTARGET_OPTIMIZATION_OPTIONS \ { OPT_LEVELS_ALL, OPT_fmerge_constants, NULL, 0 } diff --git a/gcc/config/ia64/vms64.h b/gcc/config/ia64/vms64.h index ac1d7a50799..a92014337c5 100644 --- a/gcc/config/ia64/vms64.h +++ b/gcc/config/ia64/vms64.h @@ -37,5 +37,3 @@ along with GCC; see the file COPYING3. If not see #undef TARGET_DEFAULT #define TARGET_DEFAULT (MASK_DWARF2_ASM | MASK_GNU_AS | MASK_MALLOC64) - -#include "config/vms/vms-crtl-64.h" diff --git a/gcc/config/vms/make-crtlmap.awk b/gcc/config/vms/make-crtlmap.awk new file mode 100644 index 00000000000..6f82dee7aa8 --- /dev/null +++ b/gcc/config/vms/make-crtlmap.awk @@ -0,0 +1,55 @@ +# Generate the VMS crtl map +# Copyright (C) 2011 Free Software Foundation, Inc. + +BEGIN { + is_first = 1; + maxlen=1; + maxlen_name="??" + prev="" + ORS="" +} + +# Remove comment and blank lines. +/^ *#/ || /^ *$/ { + next; +} + +{ + # Handle comma + if (!is_first) + print ",\n" + else + is_first = 0; + + # Check the map is sorted + if ($0 <= prev) + { + print "Map not sorted!! (with name " $0 ")\n" + exit 1 + } + prev = $0 + + # Compute the max of the identifier len. + l=length($1) + if (l > maxlen) + { + maxlen = l + maxlen_name = $1 + } + + print "{ \"" $1 "\", " + if (NF == 1) + print "0 }" + else if (NF == 2) + printf "VMS_CRTL_" $2 " }" + else if (NF == 3) + printf "VMS_CRTL_" $2 " | VMS_CRTL_" $3 " }" + else + # To be fixed. + exit 1 +} + +END { + print "\n\n" + print "#define VMS_CRTL_MAXLEN " maxlen " /*" maxlen_name " */\n" +} diff --git a/gcc/config/vms/t-vms b/gcc/config/vms/t-vms index d02b66614de..516435df1f9 100644 --- a/gcc/config/vms/t-vms +++ b/gcc/config/vms/t-vms @@ -35,3 +35,11 @@ $(T)pcrt0.o: $(srcdir)/config/vms/vms-ucrt0.c $(GCC_PASSES) $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \ -c -o $(T)pcrt0.o -DCRT0_POSIX_EXIT $(srcdir)/config/vms/vms-ucrt0.c +vms-crtlmap.h: $(srcdir)/config/vms/vms-crtlmap.map \ + $(srcdir)/config/vms/make-crtlmap.awk + $(AWK) -f $(srcdir)/config/vms/make-crtlmap.awk \ + $(srcdir)/config/vms/vms-crtlmap.map > $@ + +vms.o: $(srcdir)/config/vms/vms.c $(TREE_H) $(CONFIG_H) $(SYSTEM_H) \ + coretypes.h $(TM_P_H) vms-crtlmap.h + $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< diff --git a/gcc/config/vms/vms-crtl-64.h b/gcc/config/vms/vms-crtl-64.h deleted file mode 100644 index 84b653d79e2..00000000000 --- a/gcc/config/vms/vms-crtl-64.h +++ /dev/null @@ -1,195 +0,0 @@ -/* Definitions of target machine GNU compiler. 64bit VMS version. - Copyright (C) 2009, 2010 Free Software Foundation, Inc. - Contributed by Douglas B Rupp (rupp@gnat.com). - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3, or (at your option) -any later version. - -GCC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GCC; see the file COPYING3. If not see -. */ - -/* - Correlation array of 64bit standard CRTL names with DECCRTL - function names. Currently contains only a partial list, - e.g. those functions use in GNAT and GCC. Memory allocation - routines are 32bit but this can be overridden by -mmalloc - subtarget switch. - - Note: Please keep in alphabetical order. -*/ - -#undef CRTL_NAMES -#define CRTL_NAMES \ -{ \ -{"_calloc32", "decc$calloc", 0}, \ -{"_malloc32", "decc$malloc", 0}, \ -{"_realloc32", "decc$realloc", 0}, \ -{"_strdup32", "decc$strdup", 0}, \ -{"abs", "decc$abs", 0}, \ -{"abort", "decc$abort", 0}, \ -{"access", "decc$access", 0}, \ -{"accept", "decc$accept", 0}, \ -{"acos", "decc$tacos", 0}, \ -{"alarm", "decc$alarm", 0}, \ -{"asin", "decc$tasin", 0}, \ -{"atan", "decc$tatan", 0}, \ -{"atan2", "decc$tatan2", 0}, \ -{"atexit", "decc$atexit", 0}, \ -{"atoi", "decc$atoi", 0}, \ -{"atoll", "decc$atoll", 0}, \ -{"atoq", "decc$atoq", 0}, \ -{"basename", "decc$_basename64", 0}, \ -{"bcmp", "decc$bcmp", 0}, \ -{"bcopy", "decc$bcopy", 0}, \ -{"bsearch", "decc$_bsearch64", 0}, \ -{"bzero", "decc$bzero", 0}, \ -{"calloc", "decc$calloc", 0}, \ -{"ceil", "decc$tceil", 0}, \ -{"chdir", "decc$chdir", 0}, \ -{"chown", "decc$chown", 0}, \ -{"clearerr", "decc$clearerr", 0}, \ -{"clock", "decc$clock", 0}, \ -{"close", "decc$close", 0}, \ -{"cos", "decc$tcos", 0}, \ -{"connect", "decc$connect", 0}, \ -{"ctime", "decc$ctime", 0}, \ -{"dup", "decc$dup", 0}, \ -{"dup2", "decc$dup2", 0}, \ -{"exit", "decc$exit", 0}, \ -{"exp", "decc$texp", 0}, \ -{"fabs", "decc$tfabs", 0}, \ -{"fclose", "decc$fclose", 0}, \ -{"fdopen", "decc$fdopen", 0}, \ -{"fgetc", "decc$fgetc", 0}, \ -{"fgets", "decc$_fgets64", 0}, \ -{"fflush", "decc$fflush", 0}, \ -{"ffs", "decc$ffs", 0}, \ -{"floor", "decc$tfloor", 0}, \ -{"fopen", "decc$fopen", 0}, \ -{"fputc", "decc$fputc", 0}, \ -{"fputs", "decc$fputs", 0}, \ -{"free", "decc$free", 0}, \ -{"fread", "decc$fread", 0}, \ -{"freopen", "decc$freopen", 0}, \ -{"fseek", "decc$fseek", 0}, \ -{"ftell", "decc$ftell", 0}, \ -{"fwrite", "decc$fwrite", 0}, \ -{"getcwd", "decc$_getcwd64", 0}, \ -{"getegid", "decc$getegid", 0}, \ -{"getenv", "decc$getenv", 0}, \ -{"geteuid", "decc$geteuid", 0}, \ -{"getgid", "decc$getgid", 0}, \ -{"gethostbyaddr","decc$gethostbyaddr",0}, \ -{"gethostbyname","decc$gethostbyname",0}, \ -{"getpagesize", "decc$getpagesize", 0}, \ -{"getpid", "decc$getpid", 0}, \ -{"getservbyname","decc$getservbyname",0}, \ -{"getservbyport","decc$getservbyport",0}, \ -{"gettimeofday", "decc$gettimeofday", 0}, \ -{"getuid", "decc$getuid", 0}, \ -{"htons", "decc$htons", 0}, \ -{"iconv", "decc$iconv", 0}, \ -{"index", "decc$_index64", 0}, \ -{"isatty", "decc$isatty", 0}, \ -{"isdigit", "decc$isdigit", 0}, \ -{"kill", "decc$kill", 0}, \ -{"log", "decc$tlog", 0}, \ -{"log10", "decc$tlog10", 0}, \ -{"lseek", "decc$lseek", 0}, \ -{"ioctl", "decc$ioctl", 0}, \ -{"malloc", "decc$malloc", 0}, \ -{"mbstowcs", "decc$_mbstowcs64", 0}, \ -{"memchr", "decc$_memchr64", 0}, \ -{"memcmp", "decc$memcmp", 0}, \ -{"memcpy", "decc$_memcpy64", 0}, \ -{"memmove", "decc$_memmove64", 0}, \ -{"memset", "decc$_memset64", 0}, \ -{"mkstemp", "decc$mkstemp", 0}, \ -{"mktemp", "decc$_mktemp64", 0}, \ -{"mmap", "decc$_mmap64", 0}, \ -{"munmap", "decc$munmap", 0}, \ -{"nl_langinfo", "decc$nl_langinfo", 0}, \ -{"open", "decc$open", 0}, \ -{"pclose", "decc$pclose", 0}, \ -{"popen", "decc$popen", 0}, \ -{"pow", "decc$tpow", 0}, \ -{"printf", "decc$txprintf", 0}, \ -{"putenv", "decc$putenv", 0}, \ -{"puts", "decc$puts", 0}, \ -{"random", "decc$random", 0}, \ -{"read", "decc$read", 0}, \ -{"realloc", "decc$realloc", 0}, \ -{"recv", "decc$recv", 0}, \ -{"recvfrom", "decc$recvfrom", 0}, \ -{"recvmsg", "decc$__bsd44___recvmsg64", 0}, \ -{"rename", "decc$rename", 0}, \ -{"rewind", "decc$rewind", 0}, \ -{"rindex", "decc$_rindex64", 0}, \ -{"rmdir", "decc$rmdir", 0}, \ -{"send", "decc$send", 0}, \ -{"sendmsg", "decc$__bsd44___sendmsg64", 0}, \ -{"sendto", "decc$sendto", 0}, \ -{"setenv", "decc$setenv", 0}, \ -{"setlocale", "decc$setlocale", 0}, \ -{"setvbuf", "decc$setvbuf", 0}, \ -{"signal", "decc$signal", 0}, \ -{"sigsetmask", "decc$sigsetmask", 0}, \ -{"sin", "decc$tsin", 0}, \ -{"snprintf", "decc$txsnprintf", 0}, \ -{"socket", "decc$socket", 0}, \ -{"sqrt", "decc$tsqrt", 0}, \ -{"strcasecmp", "decc$strcasecmp", 0}, \ -{"strchr", "decc$_strchr64", 0}, \ -{"strcpy", "decc$_strcpy64", 0}, \ -{"strdup", "decc$strdup", 0}, \ -{"strerror", "decc$strerror", 0}, \ -{"strlen", "decc$strlen", 0}, \ -{"strncasecmp", "decc$strncasecmp", 0}, \ -{"strncmp", "decc$strncmp", 0}, \ -{"strncpy", "decc$_strncpy64", 0}, \ -{"strrchr", "decc$_strrchr64", 0}, \ -{"strstr", "decc$_strstr64", 0}, \ -{"strtod", "decc$t_strtod64", 0}, \ -{"strtol", "decc$_strtoll64", 0}, \ -{"strtoul", "decc$_strtoull64", 0}, \ -{"sysconf", "decc$sysconf", 0}, \ -{"system", "decc$system", 0}, \ -{"tan", "decc$ttan", 0}, \ -{"time", "decc$time", 0}, \ -{"times", "decc$times", 0}, \ -{"tmpfile", "decc$tmpfile", 0}, \ -{"tmpnam", "decc$_tmpnam64", 0}, \ -{"ungetc", "decc$ungetc", 0}, \ -{"unlink", "decc$unlink", 0}, \ -{"umask", "decc$umask", 0}, \ -{"utime", "decc$utime", 0}, \ -{"wait", "decc$wait", 0}, \ -{"waitpid", "decc$waitpid", 0}, \ -{"wcswidth", "decc$wcswidth", 0}, \ -{"write", "decc$write", 0}, \ -{"vfprintf", "decc$txvfprintf", 0}, \ -{"vprintf", "decc$txvprintf", 0}, \ -{"vsprintf", "decc$txvsprintf", 0}, \ -{"vsnprintf", "decc$txvsnprintf", 0}, \ -{NULL, NULL, 0} \ -} - -/* Initialize of libfuncs that are 32/64 bit memory specific. */ - -#undef MEM_LIBFUNCS_INIT -#define MEM_LIBFUNCS_INIT \ -do { \ - memcpy_libfunc = init_one_libfunc ("decc$_memcpy64"); \ - memmove_libfunc = init_one_libfunc ("decc$_memmove64"); \ - memset_libfunc = init_one_libfunc ("decc$_memset64"); \ -} while (0) diff --git a/gcc/config/vms/vms-crtl.h b/gcc/config/vms/vms-crtl.h deleted file mode 100644 index 8f09176dcc5..00000000000 --- a/gcc/config/vms/vms-crtl.h +++ /dev/null @@ -1,191 +0,0 @@ -/* Definitions of target machine GNU compiler. 32bit VMS version. - Copyright (C) 2009, 2010 Free Software Foundation, Inc. - Contributed by Douglas B Rupp (rupp@gnat.com). - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3, or (at your option) -any later version. - -GCC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GCC; see the file COPYING3. If not see -. */ - -/* - Correlation array of standard CRTL names with DECCRTL - function names. Currently contains only a partial list, - e.g. those functions use in GNAT and GCC - - Note: Please keep in alphabetical order. -*/ - -#define CRTL_NAMES \ -{ \ -{"_calloc32", "decc$calloc", 0}, \ -{"_malloc32", "decc$malloc", 0}, \ -{"_realloc32", "decc$realloc", 0}, \ -{"_strdup32", "decc$strdup", 0}, \ -{"abs", "decc$abs", 0}, \ -{"abort", "decc$abort", 0}, \ -{"access", "decc$access", 0}, \ -{"accept", "decc$accept", 0}, \ -{"acos", "decc$tacos", 0}, \ -{"alarm", "decc$alarm", 0}, \ -{"asin", "decc$tasin", 0}, \ -{"atan", "decc$tatan", 0}, \ -{"atan2", "decc$tatan2", 0}, \ -{"atexit", "decc$atexit", 0}, \ -{"atoi", "decc$atoi", 0}, \ -{"atoll", "decc$atoll", 0}, \ -{"atoq", "decc$atoq", 0}, \ -{"basename", "decc$basename", 0}, \ -{"bcmp", "decc$bcmp", 0}, \ -{"bcopy", "decc$bcopy", 0}, \ -{"bsearch", "decc$bsearch", 0}, \ -{"bzero", "decc$bzero", 0}, \ -{"calloc", "decc$calloc", 0}, \ -{"ceil", "decc$tceil", 0}, \ -{"chdir", "decc$chdir", 0}, \ -{"chown", "decc$chown", 0}, \ -{"clearerr", "decc$clearerr", 0}, \ -{"clock", "decc$clock", 0}, \ -{"close", "decc$close", 0}, \ -{"cos", "decc$tcos", 0}, \ -{"connect", "decc$connect", 0}, \ -{"ctime", "decc$ctime", 0}, \ -{"dup", "decc$dup", 0}, \ -{"dup2", "decc$dup2", 0}, \ -{"exit", "decc$exit", 0}, \ -{"exp", "decc$texp", 0}, \ -{"fabs", "decc$tfabs", 0}, \ -{"fclose", "decc$fclose", 0}, \ -{"fdopen", "decc$fdopen", 0}, \ -{"fgetc", "decc$fgetc", 0}, \ -{"fgets", "decc$fgets", 0}, \ -{"fflush", "decc$fflush", 0}, \ -{"ffs", "decc$ffs", 0}, \ -{"floor", "decc$tfloor", 0}, \ -{"fopen", "decc$fopen", 0}, \ -{"fputc", "decc$fputc", 0}, \ -{"fputs", "decc$fputs", 0}, \ -{"free", "decc$free", 0}, \ -{"fread", "decc$fread", 0}, \ -{"freopen", "decc$freopen", 0}, \ -{"fseek", "decc$fseek", 0}, \ -{"ftell", "decc$ftell", 0}, \ -{"fwrite", "decc$fwrite", 0}, \ -{"getcwd", "decc$getcwd", 0}, \ -{"getegid", "decc$getegid", 0}, \ -{"getenv", "decc$getenv", 0}, \ -{"geteuid", "decc$geteuid", 0}, \ -{"getgid", "decc$getgid", 0}, \ -{"gethostbyaddr","decc$gethostbyaddr",0}, \ -{"gethostbyname","decc$gethostbyname",0}, \ -{"getpagesize", "decc$getpagesize", 0}, \ -{"getpid", "decc$getpid", 0}, \ -{"getservbyname","decc$getservbyname",0}, \ -{"getservbyport","decc$getservbyport",0}, \ -{"gettimeofday", "decc$gettimeofday", 0}, \ -{"getuid", "decc$getuid", 0}, \ -{"htons", "decc$htons", 0}, \ -{"iconv", "decc$iconv", 0}, \ -{"index", "decc$index", 0}, \ -{"isatty", "decc$isatty", 0}, \ -{"isdigit", "decc$isdigit", 0}, \ -{"kill", "decc$kill", 0}, \ -{"log", "decc$tlog", 0}, \ -{"log10", "decc$tlog10", 0}, \ -{"lseek", "decc$lseek", 0}, \ -{"ioctl", "decc$ioctl", 0}, \ -{"malloc", "decc$malloc", 0}, \ -{"mbstowcs", "decc$mbstowcs", 0}, \ -{"memchr", "decc$memchr", 0}, \ -{"memcmp", "decc$memcmp", 0}, \ -{"memcpy", "decc$memcpy", 0}, \ -{"memmove", "decc$memmove", 0}, \ -{"memset", "decc$memset", 0}, \ -{"mkstemp", "decc$mkstemp", 0}, \ -{"mktemp", "decc$mktemp", 0}, \ -{"mmap", "decc$mmap", 0}, \ -{"munmap", "decc$munmap", 0}, \ -{"nl_langinfo", "decc$nl_langinfo", 0}, \ -{"open", "decc$open", 0}, \ -{"pclose", "decc$pclose", 0}, \ -{"popen", "decc$popen", 0}, \ -{"pow", "decc$tpow", 0}, \ -{"printf", "decc$txprintf", 0}, \ -{"putenv", "decc$putenv", 0}, \ -{"puts", "decc$puts", 0}, \ -{"random", "decc$random", 0}, \ -{"read", "decc$read", 0}, \ -{"realloc", "decc$realloc", 0}, \ -{"recv", "decc$recv", 0}, \ -{"recvfrom", "decc$recvfrom", 0}, \ -{"recvmsg", "decc$__bsd44___recvmsg32", 0}, \ -{"rename", "decc$rename", 0}, \ -{"rewind", "decc$rewind", 0}, \ -{"rindex", "decc$rindex", 0}, \ -{"rmdir", "decc$rmdir", 0}, \ -{"send", "decc$send", 0}, \ -{"sendmsg", "decc$__bsd44___sendmsg32", 0}, \ -{"sendto", "decc$sendto", 0}, \ -{"setenv", "decc$setenv", 0}, \ -{"setlocale", "decc$setlocale", 0}, \ -{"setvbuf", "decc$setvbuf", 0}, \ -{"signal", "decc$signal", 0}, \ -{"sigsetmask", "decc$sigsetmask", 0}, \ -{"sin", "decc$tsin", 0}, \ -{"snprintf", "decc$txsnprintf", 0}, \ -{"socket", "decc$socket", 0}, \ -{"sqrt", "decc$tsqrt", 0}, \ -{"strcasecmp", "decc$strcasecmp", 0}, \ -{"strchr", "decc$strchr", 0}, \ -{"strcpy", "decc$strcpy", 0}, \ -{"strdup", "decc$strdup", 0}, \ -{"strerror", "decc$strerror", 0}, \ -{"strlen", "decc$strlen", 0}, \ -{"strncasecmp", "decc$strncasecmp", 0}, \ -{"strncmp", "decc$strncmp", 0}, \ -{"strncpy", "decc$strncpy", 0}, \ -{"strrchr", "decc$strrchr", 0}, \ -{"strstr", "decc$strstr", 0}, \ -{"strtod", "decc$tstrtod", 0}, \ -{"strtol", "decc$strtoll", 0}, \ -{"strtoul", "decc$strtoull", 0}, \ -{"sysconf", "decc$sysconf", 0}, \ -{"system", "decc$system", 0}, \ -{"tan", "decc$ttan", 0}, \ -{"time", "decc$time", 0}, \ -{"times", "decc$times", 0}, \ -{"tmpfile", "decc$tmpfile", 0}, \ -{"tmpnam", "decc$tmpnam", 0}, \ -{"ungetc", "decc$ungetc", 0}, \ -{"unlink", "decc$unlink", 0}, \ -{"umask", "decc$umask", 0}, \ -{"utime", "decc$utime", 0}, \ -{"wait", "decc$wait", 0}, \ -{"waitpid", "decc$waitpid", 0}, \ -{"wcswidth", "decc$wcswidth", 0}, \ -{"write", "decc$write", 0}, \ -{"vfprintf", "decc$txvfprintf", 0}, \ -{"vprintf", "decc$txvprintf", 0}, \ -{"vsprintf", "decc$txvsprintf", 0}, \ -{"vsnprintf", "decc$txvsnprintf", 0}, \ -{NULL, NULL, 0} \ -} - -/* Initialize of libfuncs that are 32/64 bit memory specific. */ - -#define MEM_LIBFUNCS_INIT \ -do { \ - memcpy_libfunc = init_one_libfunc ("decc$memcpy"); \ - memmove_libfunc = init_one_libfunc ("decc$memmove"); \ - memset_libfunc = init_one_libfunc ("decc$memset"); \ -} while (0) diff --git a/gcc/config/vms/vms-crtlmap.map b/gcc/config/vms/vms-crtlmap.map new file mode 100644 index 00000000000..4f2755e2c82 --- /dev/null +++ b/gcc/config/vms/vms-crtlmap.map @@ -0,0 +1,200 @@ +# Standard C names to DEC-C names map table. +# All names in the DEC-C shared image (shared library) are prefixed +# with decc$ (this is the standard vms convention for names in public +# shared libraries). This conversion is done by the compiler for all +# languages. +# +# Currently contains only a partial list, e.g. those functions use +# in GNAT and GCC. +# +# File format: +# - Empty lines are ignored. +# - Comment lines start with '#' in the first column. +# - map lines consist in an identifier optionnaly followed by at most 2 +# space-separated flags. +# Flags are: +# FLOAT: will be prefixed by 'x' +# 64: There is a 64-bit variant +# BSD44: name will be prefixed by __bsd44__ +# PRNTF: a 't' prefix will be added. +# MALLOC: malloc related function. +# +# Keep entries alpha-sorted - this is enforced by the awk script. +# +__32_signal +__32_ssignal +__64_signal +__64_ssignal +__utc_localtime +__utc_localtime_t +__utc_stat +__utc_time +__utctz_gmtime +__utctz_localtime +__utctz_localtime_t +abort +abs +accept +access +acos FLOAT +alarm +asin FLOAT +atan FLOAT +atan2 FLOAT +atexit +atoi +atoll +atoq +basename 64 +bcmp +bcopy +bsearch 64 +bzero +calloc 64 MALLOC +ceil FLOAT +chdir +chown +clearerr +clock +close +connect +cos FLOAT +ctermid 64 +ctime +dup +dup2 +exit +exp FLOAT +fabs FLOAT +fclose +fdopen +fflush +ffs +fgetc +fgets 64 +floor FLOAT +fopen +fprintf FLOAT PRNTF +fputc +fputs +fread +free +freopen +fseek +ftell +fwrite +getc +getcwd 64 +getegid +getenv +geteuid +getgid +gethostbyaddr +gethostbyname +getpagesize +getpid +getservbyname +getservbyport +gettimeofday +getuid +gmtime +htons +iconv +index 64 +ioctl +isatty +isdigit +islower +isprint +isspace +isupper +kill +localtime +log FLOAT +log1 FLOAT +lseek +malloc 64 MALLOC +mbstowcs 64 +memchr 64 +memcmp +memcpy 64 +memmove 64 +memset 64 +mkdir +mkstemp +mktemp 64 +mmap 64 +munmap +nl_langinfo +open +pclose +perror +popen +pow FLOAT +printf FLOAT PRNTF +putc +putchar +putenv +puts +qsort 64 +random +read +realloc 64 MALLOC +recv +recvfrom +recvmsg BSD44 64 +rename +rewind +rindex 64 +rmdir +send +sendmsg BSD44 64 +sendto +setenv +setlocale +setvbuf +signal +sigsetmask +sin FLOAT +snprintf FLOAT PRNTF +socket +sprintf FLOAT PRNTF +sqrt FLOAT +stat +strcasecmp +strcat 64 +strchr 64 +strcmp +strcpy 64 +strdup 64 MALLOC +strerror +strlen +strncasecmp +strncmp +strncpy 64 +strrchr 64 +strstr 64 +strtod 64 FLOAT +strtol 64 +strtoul 64 +sysconf +system +tan FLOAT +time +times +tmpfile +tmpnam 64 +tolower +toupper +umask +ungetc +unlink +utime +vfprintf FLOAT PRNTF +vprintf FLOAT PRNTF +vsnprintf FLOAT PRNTF +vsprintf FLOAT PRNTF +wait +waitpid +wcswidth +write diff --git a/gcc/config/vms/vms-protos.h b/gcc/config/vms/vms-protos.h new file mode 100644 index 00000000000..04dcd606999 --- /dev/null +++ b/gcc/config/vms/vms-protos.h @@ -0,0 +1,21 @@ +/* Definitions of target machine for GCC for VMS. + Copyright (C) 2011 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +/* vms.c */ +void vms_patch_builtins (void); diff --git a/gcc/config/vms/vms.c b/gcc/config/vms/vms.c new file mode 100644 index 00000000000..62a16619856 --- /dev/null +++ b/gcc/config/vms/vms.c @@ -0,0 +1,171 @@ +/* Definitions of target machine GNU compiler. 32bit VMS version. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + Contributed by Douglas B Rupp (rupp@gnat.com). + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "vms-protos.h" +#include "tm.h" +#include "ggc.h" + +/* Correlation of standard CRTL names with DECCRTL function names. */ + +/* Name is for a function that allocate memory. Use the 64bit version + if -mmalloc64. */ +#define VMS_CRTL_MALLOC (1 << 0) + +/* If long pointer are enabled, use _NAME64 instead. */ +#define VMS_CRTL_64 (1 << 1) + +/* Use tNAME instead. To be applied after the previous rule. */ +#define VMS_CRTL_FLOAT (1 << 2) + +/* Prepend __bsd44__ before the name. To be applied after the P64 + rule. */ +#define VMS_CRTL_BSD44 (1 << 3) + +/* Prepend x before the name for printf like functions. */ +#define VMS_CRTL_PRNTF (1 << 4) + +struct vms_crtl_name +{ + /* The standard C name. */ + const char *const name; + + /* Flags to drive the translation. */ + unsigned int flags; +}; + +/* Map for the translation. */ + +static const struct vms_crtl_name vms_crtl_names[] = + { +#include "vms-crtlmap.h" + }; + +/* Number of entires in the above array. */ + +#define NBR_CRTL_NAMES (sizeof (vms_crtl_names) / sizeof (*vms_crtl_names)) + +/* List of aliased identifiers. They must be persistant accross gc. */ + +static GTY(()) VEC(tree,gc) *aliases_id; + +/* Add a CRTL translation. This simply use the transparent alias + mechanism, which is platform independant and works with the + #pragma extern_prefix (which set the assembler name). */ + +static void +vms_add_crtl_xlat (const char *name, size_t nlen, + const char *id_str, size_t id_len) +{ + tree targ; + + targ = get_identifier_with_length (name, nlen); + gcc_assert (!IDENTIFIER_TRANSPARENT_ALIAS (targ)); + IDENTIFIER_TRANSPARENT_ALIAS (targ) = 1; + TREE_CHAIN (targ) = get_identifier_with_length (id_str, id_len); + + VEC_safe_push (tree, gc, aliases_id, targ); + + /* printf ("vms: %s (%p) -> %.*s\n", name, targ, id_len, id_str); */ +} + +/* Do VMS specific stuff on builtins: disable the ones that are not + standard, mangle names. */ + +void +vms_patch_builtins (void) +{ + /* enum built_in_function bi; */ + unsigned int i; + + /* Fwrite on VMS is non-standard. */ + implicit_built_in_decls[(int) BUILT_IN_FWRITE] = NULL_TREE; + implicit_built_in_decls[(int) BUILT_IN_FWRITE_UNLOCKED] = NULL_TREE; + + /* Define aliases for names. */ + for (i = 0; i < NBR_CRTL_NAMES; i++) + { + const struct vms_crtl_name *n = &vms_crtl_names[i]; + char res[VMS_CRTL_MAXLEN + 3 + 9 + 1 + 1]; + int rlen; + int nlen; + + /* Add the dec-c prefix. */ + memcpy (res, "decc$", 5); + rlen = 5; + + if (n->flags & VMS_CRTL_BSD44) + { + memcpy (res + rlen, "__bsd44__", 9); + rlen += 9; + } + + if (n->flags & VMS_CRTL_FLOAT) + res[rlen++] = 't'; + + if (n->flags & VMS_CRTL_PRNTF) + res[rlen++] = 'x'; + + nlen = strlen (n->name); + memcpy (res + rlen, n->name, nlen); + + if ((n->flags & VMS_CRTL_64) == 0) + vms_add_crtl_xlat (n->name, nlen, res, rlen + nlen); + else + { + char alt[VMS_CRTL_MAXLEN + 3]; + bool use_64; + + /* Add three translations: + _X32 -> X + _X64 -> _X64 + X -> X if short, _X64 if long. */ + alt[0] = '_'; + memcpy (alt + 1, n->name, nlen); + alt[1 + nlen + 0] = '3'; + alt[1 + nlen + 1] = '2'; + alt[1 + nlen + 2] = 0; + vms_add_crtl_xlat (alt, nlen + 3, res, rlen + nlen); + + use_64 = (((n->flags & VMS_CRTL_64) && POINTER_SIZE == 64) + || ((n->flags & VMS_CRTL_MALLOC) + && TARGET_MALLOC64)); + if (!use_64) + vms_add_crtl_xlat (n->name, nlen, res, rlen + nlen); + + res[rlen++] = '_'; + memcpy (res + rlen, n->name, nlen); + res[rlen + nlen + 0] = '6'; + res[rlen + nlen + 1] = '4'; + + if (use_64) + vms_add_crtl_xlat (n->name, nlen, res, rlen + nlen + 2); + + alt[1 + nlen + 0] = '6'; + alt[1 + nlen + 1] = '4'; + vms_add_crtl_xlat (alt, nlen + 3, res, rlen + nlen + 2); + } + } +} + +#include "gt-vms.h"