aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1995-02-21 19:07:50 -0500
committerRichard Kenner <kenner@gcc.gnu.org>1995-02-21 19:07:50 -0500
commit30c7130834ddc00fbaa59c3b6a06e84fb907efd2 (patch)
tree9c844b43014c6cde98228c3327f004c82995196b /gcc
parent8c4caa3de9cf6f313b5736eb83ac70f34c58016b (diff)
downloadgcc-30c7130834ddc00fbaa59c3b6a06e84fb907efd2.zip
gcc-30c7130834ddc00fbaa59c3b6a06e84fb907efd2.tar.gz
gcc-30c7130834ddc00fbaa59c3b6a06e84fb907efd2.tar.bz2
Initial revision
From-SVN: r9024
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/i386/winnt.c119
-rw-r--r--gcc/fixinc.winnt224
2 files changed, 343 insertions, 0 deletions
diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c
new file mode 100644
index 0000000..fa2cd30
--- /dev/null
+++ b/gcc/config/i386/winnt.c
@@ -0,0 +1,119 @@
+/* Subroutines for insn-output.c for Windows NT.
+ Contributed by Douglas Rupp (drupp@cs.washington.edu)
+ Copyright (C) 1995 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC 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 2, or (at your option)
+any later version.
+
+GNU CC 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 GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <stdio.h>
+#include "config.h"
+#include "rtl.h"
+#include "regs.h"
+#include "hard-reg-set.h"
+#include "output.h"
+#include "tree.h"
+#include "flags.h"
+/* Return DECL with the assembler name modified with a suffix consisting
+ of an atsign (@) followed by the number of bytes of arguments */
+
+tree
+gen_stdcall_suffix (decl)
+ tree decl;
+{
+ int total = 0;
+ char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+ char *newsym;
+
+ if (TYPE_ARG_TYPES (TREE_TYPE (decl)))
+ if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (decl))))
+ == void_type_node)
+ {
+ tree formal_type = TYPE_ARG_TYPES (TREE_TYPE (decl));
+
+ while (TREE_VALUE (formal_type) != void_type_node)
+ {
+ total += TREE_INT_CST_LOW (TYPE_SIZE (TREE_VALUE (formal_type)));
+ formal_type = TREE_CHAIN (formal_type);
+ }
+ }
+
+ newsym = xmalloc (strlen (asmname) + 10);
+ sprintf (newsym, "%s@%d", asmname, total/BITS_PER_UNIT);
+ return get_identifier (newsym);
+}
+
+/* This function generates the assembly code for function entry.
+ FILE is an stdio stream to output the code to.
+ SIZE is an int: how many units of temporary storage to allocate. */
+
+void
+winnt_function_prologue (file, size)
+ FILE *file;
+ int size;
+{
+ register int regno;
+ int limit;
+ rtx xops[4];
+ int pic_reg_used = flag_pic && (current_function_uses_pic_offset_table
+ || current_function_uses_const_pool);
+
+ xops[0] = stack_pointer_rtx;
+ xops[1] = frame_pointer_rtx;
+ xops[2] = GEN_INT (size);
+ xops[3] = gen_rtx (REG, Pmode, 0); /* eax */
+ if (frame_pointer_needed)
+ {
+ output_asm_insn ("push%L1 %1", xops);
+ output_asm_insn (AS2 (mov%L0,%0,%1), xops);
+ }
+
+ if (size > 4095)
+ {
+ output_asm_insn (AS2 (mov%L0, %2, %3), xops);
+ output_asm_insn ("call __chkstk", xops);
+ }
+ else if (size)
+ output_asm_insn (AS2 (sub%L0,%2,%0), xops);
+
+ /* Note If use enter it is NOT reversed args.
+ This one is not reversed from intel!!
+ I think enter is slower. Also sdb doesn't like it.
+ But if you want it the code is:
+ {
+ xops[3] = const0_rtx;
+ output_asm_insn ("enter %2,%3", xops);
+ }
+ */
+ limit = (frame_pointer_needed ? FRAME_POINTER_REGNUM : STACK_POINTER_REGNUM);
+ for (regno = limit - 1; regno >= 0; regno--)
+ if ((regs_ever_live[regno] && ! call_used_regs[regno])
+ || (regno == PIC_OFFSET_TABLE_REGNUM && pic_reg_used))
+ {
+ xops[0] = gen_rtx (REG, SImode, regno);
+ output_asm_insn ("push%L0 %0", xops);
+ }
+
+ if (pic_reg_used)
+ {
+ xops[0] = pic_offset_table_rtx;
+ xops[1] = (rtx) gen_label_rtx ();
+
+ output_asm_insn (AS1 (call,%P1), xops);
+ ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (xops[1]));
+ output_asm_insn (AS1 (pop%L0,%0), xops);
+ output_asm_insn ("addl $_GLOBAL_OFFSET_TABLE_+[.-%P1],%0", xops);
+ }
+}
diff --git a/gcc/fixinc.winnt b/gcc/fixinc.winnt
new file mode 100644
index 0000000..c928675
--- /dev/null
+++ b/gcc/fixinc.winnt
@@ -0,0 +1,224 @@
+#! sh
+#
+# fixinc.winnt -- Install modified versions of Windows NT system include
+# files.
+#
+# Based on fixinc.sco script by Ian Lance Taylor (ian@airs.com)).
+# Modifications by Douglas Rupp (drupp@cs.washington.edu)
+#
+# This file is part of GNU CC.
+#
+# GNU CC 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 2, or (at your option)
+# any later version.
+#
+# GNU CC 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 GNU CC; see the file COPYING. If not, write to
+# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+# This script munges the native include files provided with Windows NT
+# 3.5 SDK systems so as to provide a reasonable namespace when
+# compiling with gcc. The header files by default do not
+# provide many essential definitions and declarations if
+# __STDC__ is 1. This script modifies the header files to check
+# for __STRICT_ANSI__ being defined instead. However the most
+# important modification is to change all occurences of __stdcall
+# and __cdecl to __attribute__((stdcall)) and __attribute__((cdecl)),
+# respectively. Once munged, the
+# resulting new system include files are placed in a directory
+# that GNU C will search *before* searching the /mstools/h
+# directory. This script should work properly for an /mstools/h
+# directory dated 9/4/94 on the installation CDROM.
+#
+# See README-fixinc for more information.
+
+# Directory containing the original header files.
+INPUT=${2-${INPUT-/mstools/h}}
+
+# Fail if no arg to specify a directory for the output.
+if [ x$1 = x ]
+then echo fixincludes: no output directory specified
+exit 1
+fi
+
+# Directory in which to store the results.
+LIB=${1?"fixincludes: output directory not specified"}
+
+# Make sure it exists.
+if [ ! -d $LIB ]; then
+ mkdir $LIB || exit 1
+fi
+
+ORIG_DIR=`pwd`
+
+# Make LIB absolute if it is relative.
+# Don't do this if not necessary, since may screw up automounters.
+case $LIB in
+/*)
+ ;;
+*)
+ cd $LIB; LIB=`${PWDCMD-pwd}`
+ ;;
+esac
+
+echo 'Building fixincludes in ' ${LIB}
+
+# Determine whether this filesystem has symbolic links.
+if ln -s X $LIB/ShouldNotExist 2>NUL; then
+ rm -f $LIB/ShouldNotExist
+ LINKS=true
+else
+ LINKS=false
+fi
+
+echo 'Making directories:'
+cd ${INPUT}
+if $LINKS; then
+ files=`ls -LR | sed -n s/:$//p`
+else
+ files=`find . -type d -print | sed '/^.$/d'`
+fi
+for file in $files; do
+ rm -rf $LIB/$file
+ if [ ! -d $LIB/$file ]
+ then mkdir $LIB/$file
+ fi
+done
+
+# treetops gets an alternating list
+# of old directories to copy
+# and the new directories to copy to.
+treetops="${INPUT} ${LIB}"
+
+set - $treetops
+while [ $# != 0 ]; do
+ # $1 is an old directory to copy, and $2 is the new directory to copy to.
+ echo "Finding header files in $1:"
+ cd ${INPUT}
+ cd $1
+ files=`find . -name '*.[hH]' -type f -print`
+ echo 'Checking header files:'
+ for file in $files; do
+ echo $file
+ if egrep "!__STDC__|__stdcall|__cdecl" $file >NUL; then
+ if [ -r $file ]; then
+ cp $file $2/$file >NUL 2>&1 || echo "Can't copy $file"
+ chmod +w,a+r $2/$file
+
+# The following have been removed from the sed command below
+# because it is more useful to leave these things in.
+# The only reason to remove them was for -pedantic,
+# which isn't much of a reason. -- rms.
+# /^[ ]*#[ ]*ident/d
+
+ sed -e '
+ s/!__STDC__/!defined (__STRICT_ANSI__)/g
+ s/__stdcall/__attribute__((stdcall))/g
+ s/__cdecl/__attribute__((cdecl))/g
+ ' $2/$file > $2/$file.sed
+ mv $2/$file.sed $2/$file
+ if cmp $file $2/$file >NUL 2>&1; then
+ rm $2/$file
+ else
+ echo Fixed $file
+ fi
+ fi
+ fi
+ done
+ shift; shift
+done
+
+# Fix first broken decl of getcwd present on some svr4 systems.
+
+file=direct.h
+base=`basename $file`
+if [ -r ${LIB}/$file ]; then
+ file_to_fix=${LIB}/$file
+else
+ if [ -r ${INPUT}/$file ]; then
+ file_to_fix=${INPUT}/$file
+ else
+ file_to_fix=""
+ fi
+fi
+if [ \! -z "$file_to_fix" ]; then
+ echo Checking $file_to_fix
+ sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
+ if cmp $file_to_fix /tmp/$base >NUL 2>&1; then \
+ true
+ else
+ echo Fixed $file_to_fix
+ rm -f ${LIB}/$file
+ cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
+ fi
+ rm -f /tmp/$base
+fi
+
+file=rpcndr.h
+base=`basename $file`
+if [ -r ${LIB}/$file ]; then
+ file_to_fix=${LIB}/$file
+else
+ if [ -r ${INPUT}/$file ]; then
+ file_to_fix=${INPUT}/$file
+ else
+ file_to_fix=""
+ fi
+fi
+if [ \! -z "$file_to_fix" ]; then
+ echo Checking $file_to_fix
+ sed -e 's/Format\[\]/Format\[1\]/' $file_to_fix > /tmp/$base
+ if cmp $file_to_fix /tmp/$base >NUL 2>&1; then \
+ true
+ else
+ echo Fixed $file_to_fix
+ rm -f ${LIB}/$file
+ cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
+ fi
+ rm -f /tmp/$base
+fi
+
+file=winnt.h
+base=`basename $file`
+if [ -r ${LIB}/$file ]; then
+ file_to_fix=${LIB}/$file
+else
+ if [ -r ${INPUT}/$file ]; then
+ file_to_fix=${INPUT}/$file
+ else
+ file_to_fix=""
+ fi
+fi
+if [ \! -z "$file_to_fix" ]; then
+ echo Checking $file_to_fix
+ sed -e '
+ s/^#if !defined (__cplusplus)/#if 0/
+ s/^#define DECLSPEC_IMPORT __declspec(dllimport)/#define DECLSPEC_IMPORT/
+ ' $file_to_fix > /tmp/$base
+ if cmp $file_to_fix /tmp/$base >NUL 2>&1; then \
+ true
+ else
+ echo Fixed $file_to_fix
+ rm -f ${LIB}/$file
+ cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
+ fi
+ rm -f /tmp/$base
+fi
+
+echo 'Removing unneeded directories:'
+cd $LIB
+files=`find . -type d -print | sort -r`
+for file in $files; do
+ rmdir $LIB/$file > NUL 2>&1
+done
+
+exit 0