* config/i386/netbsd-elf.h (TARGET_OS_CPP_BUILTINS): Define.
[official-gcc.git] / gcc / config / i386 / interix.c
blob58a19ab5de6c53c8f0a45a9522d2202ca976b52d
1 /* Subroutines for insn-output.c for Windows NT.
2 Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 #include "config.h"
22 #include "system.h"
23 #include "rtl.h"
24 #include "regs.h"
25 #include "hard-reg-set.h"
26 #include "output.h"
27 #include "tree.h"
28 #include "flags.h"
30 /* Return string which is the former assembler name modified with a
31 suffix consisting of an atsign (@) followed by the number of bytes of
32 arguments */
34 const char *
35 gen_stdcall_suffix (decl)
36 tree decl;
38 int total = 0;
39 /* ??? This probably should use XSTR (XEXP (DECL_RTL (decl), 0), 0) instead
40 of DECL_ASSEMBLER_NAME. */
41 const char *const asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
42 char *newsym;
44 if (TYPE_ARG_TYPES (TREE_TYPE (decl)))
45 if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (decl))))
46 == void_type_node)
48 tree formal_type = TYPE_ARG_TYPES (TREE_TYPE (decl));
50 while (TREE_VALUE (formal_type) != void_type_node)
52 int parm_size
53 = TREE_INT_CST_LOW (TYPE_SIZE (TREE_VALUE (formal_type)));
54 /* Must round up to include padding. This is done the same
55 way as in store_one_arg. */
56 parm_size = ((parm_size + PARM_BOUNDARY - 1)
57 / PARM_BOUNDARY * PARM_BOUNDARY);
58 total += parm_size;
59 formal_type = TREE_CHAIN (formal_type);
63 newsym = xmalloc (strlen (asmname) + 10);
64 sprintf (newsym, "%s@%d", asmname, total/BITS_PER_UNIT);
65 return IDENTIFIER_POINTER (get_identifier (newsym));
68 void
69 i386_interix_encode_section_info (decl, first)
70 tree decl;
71 int first;
73 if (flag_pic)
75 rtx rtl = (TREE_CODE_CLASS (TREE_CODE (decl)) != 'd'
76 ? TREE_CST_RTL (decl) : DECL_RTL (decl));
77 SYMBOL_REF_FLAG (XEXP (rtl, 0))
78 = (TREE_CODE_CLASS (TREE_CODE (decl)) != 'd'
79 || ! TREE_PUBLIC (decl));
81 if (first && TREE_CODE (decl) == FUNCTION_DECL)
82 if (lookup_attribute ("stdcall",
83 TYPE_ATTRIBUTES (TREE_TYPE (decl))))
84 XEXP (DECL_RTL (decl), 0) =
85 gen_rtx (SYMBOL_REF, Pmode, gen_stdcall_suffix (decl));
88 #if 0
89 /* Turn this back on when the linker is updated to handle grouped
90 .data$ sections correctly. See corresponding note in i386/interix.h.
91 MK. */
93 /* Cover function for UNIQUE_SECTION. */
95 void
96 i386_pe_unique_section (decl, reloc)
97 tree decl;
98 int reloc;
100 int len;
101 const char *name;
102 char *string,*prefix;
104 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
105 name = (* targetm.strip_name_encoding) (name);
107 /* The object is put in, for example, section .text$foo.
108 The linker will then ultimately place them in .text
109 (everything from the $ on is stripped). Don't put
110 read-only data in .rdata section to avoid a PE linker
111 bug when .rdata$* grouped sections are used in code
112 without a .rdata section. */
113 if (TREE_CODE (decl) == FUNCTION_DECL)
114 prefix = ".text$";
115 else if (DECL_READONLY_SECTION (decl, reloc))
116 prefix = ".rdata$";
117 else
118 prefix = ".data$";
119 len = strlen (name) + strlen (prefix);
120 string = alloca (len + 1);
121 sprintf (string, "%s%s", prefix, name);
123 DECL_SECTION_NAME (decl) = build_string (len, string);
126 #endif /* 0 */