]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/netbsd.h
GNU CC -> GCC
[thirdparty/gcc.git] / gcc / config / netbsd.h
CommitLineData
52f4fff6 1/* Base configuration file for all NetBSD targets.
35501efe 2 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
52f4fff6
JT
3 Free Software Foundation, Inc.
4
7ec022b2 5This file is part of GCC.
52f4fff6 6
7ec022b2 7GCC is free software; you can redistribute it and/or modify
52f4fff6
JT
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
7ec022b2 12GCC is distributed in the hope that it will be useful,
52f4fff6
JT
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
7ec022b2 18along with GCC; see the file COPYING. If not, write to
52f4fff6
JT
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */
21
22/* TARGET_OS_CPP_BUILTINS() common to all NetBSD targets. */
23#define NETBSD_OS_CPP_BUILTINS_COMMON() \
24 do \
25 { \
26 builtin_define ("__NetBSD__"); \
27 builtin_assert ("system=unix"); \
28 builtin_assert ("system=NetBSD"); \
29 } \
30 while (0)
31
52f4fff6 32/* CPP_SPEC parts common to all NetBSD targets. */
35501efe
JT
33#define NETBSD_CPP_SPEC \
34 "%{posix:-D_POSIX_SOURCE} \
35 %{pthread:-D_REENTRANT -D_PTHREADS}"
52f4fff6 36
b69efa5b
MM
37/* NETBSD_NATIVE is defined when gcc is integrated into the NetBSD
38 source tree so it can be configured appropriately without using
991b6592 39 the GNU configure/build mechanism. */
b69efa5b
MM
40
41#ifdef NETBSD_NATIVE
42
0e3ce1df
RK
43/* Look for the include files in the system-defined places. */
44
45#undef GPLUSPLUS_INCLUDE_DIR
46#define GPLUSPLUS_INCLUDE_DIR "/usr/include/g++"
47
48#undef GCC_INCLUDE_DIR
49#define GCC_INCLUDE_DIR "/usr/include"
50
51#undef INCLUDE_DEFAULTS
58600d24
TV
52#define INCLUDE_DEFAULTS \
53 { \
54 { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 }, \
55 { GCC_INCLUDE_DIR, "GCC", 0, 0 }, \
56 { 0, 0, 0, 0 } \
0e3ce1df
RK
57 }
58
b69efa5b
MM
59/* Under NetBSD, the normal location of the compiler back ends is the
60 /usr/libexec directory. */
0e3ce1df 61
b69efa5b
MM
62#undef STANDARD_EXEC_PREFIX
63#define STANDARD_EXEC_PREFIX "/usr/libexec/"
0e3ce1df
RK
64
65/* Under NetBSD, the normal location of the various *crt*.o files is the
66 /usr/lib directory. */
67
b69efa5b
MM
68#undef STANDARD_STARTFILE_PREFIX
69#define STANDARD_STARTFILE_PREFIX "/usr/lib/"
70
f982f805 71#endif /* NETBSD_NATIVE */
0e3ce1df
RK
72
73
b0c2b2f9
JT
74/* Provide a LIB_SPEC appropriate for NetBSD. Here we:
75
76 1. Select the appropriate set of libs, depending on whether we're
77 profiling.
78
ee3c755a
JT
79 2. Include the pthread library if -pthread is specified (only
80 if threads are enabled).
b0c2b2f9 81
ee3c755a
JT
82 3. Include the posix library if -posix is specified.
83
84 FIXME: Could eliminate the duplication here if we were allowed to
85 use string concatenation. */
0e3ce1df 86
ee3c755a 87#ifdef NETBSD_ENABLE_PTHREADS
1ebe8c03 88#define NETBSD_LIB_SPEC \
b0c2b2f9
JT
89 "%{pthread: \
90 %{!p: \
91 %{!pg:-lpthread}} \
92 %{p:-lpthread_p} \
93 %{pg:-lpthread_p}} \
94 %{posix: \
f982f805
JT
95 %{!p: \
96 %{!pg:-lposix}} \
97 %{p:-lposix_p} \
98 %{pg:-lposix_p}} \
99 %{!shared: \
100 %{!symbolic: \
101 %{!p: \
102 %{!pg:-lc}} \
103 %{p:-lc_p} \
104 %{pg:-lc_p}}}"
ee3c755a 105#else
1ebe8c03 106#define NETBSD_LIB_SPEC \
ee3c755a
JT
107 "%{posix: \
108 %{!p: \
109 %{!pg:-lposix}} \
110 %{p:-lposix_p} \
111 %{pg:-lposix_p}} \
112 %{!shared: \
113 %{!symbolic: \
114 %{!p: \
115 %{!pg:-lc}} \
116 %{p:-lc_p} \
117 %{pg:-lc_p}}}"
118#endif
f982f805 119
1ebe8c03
JT
120#undef LIB_SPEC
121#define LIB_SPEC NETBSD_LIB_SPEC
122
f982f805
JT
123/* Provide a LIBGCC_SPEC appropriate for NetBSD. We also want to exclude
124 libgcc with -symbolic. */
125
f982f805 126#ifdef NETBSD_NATIVE
1ebe8c03 127#define NETBSD_LIBGCC_SPEC \
f982f805
JT
128 "%{!symbolic: \
129 %{!shared: \
130 %{!p: \
1ebe8c03 131 %{!pg: -lgcc}}} \
5a721dab
RE
132 %{shared: -lgcc_pic} \
133 %{p: -lgcc_p} \
134 %{pg: -lgcc_p}}"
f982f805 135#else
1ebe8c03 136#define NETBSD_LIBGCC_SPEC "%{!shared:%{!symbolic: -lgcc}}"
f982f805 137#endif
414e05cf 138
1ebe8c03
JT
139#undef LIBGCC_SPEC
140#define LIBGCC_SPEC NETBSD_LIBGCC_SPEC
141
414e05cf
RE
142/* When building shared libraries, the initialization and finalization
143 functions for the library are .init and .fini respectively. */
144
145#define COLLECT_SHARED_INIT_FUNC(STREAM,FUNC) \
146 do { \
147 fprintf ((STREAM), "void __init() __asm__ (\".init\");"); \
148 fprintf ((STREAM), "void __init() {\n\t%s();\n}\n", (FUNC)); \
172270b3 149 } while (0)
414e05cf
RE
150
151#define COLLECT_SHARED_FINI_FUNC(STREAM,FUNC) \
152 do { \
153 fprintf ((STREAM), "void __fini() __asm__ (\".fini\");"); \
154 fprintf ((STREAM), "void __fini() {\n\t%s();\n}\n", (FUNC)); \
172270b3 155 } while (0)
0e3ce1df 156
f982f805
JT
157#undef TARGET_HAS_F_SETLKW
158#define TARGET_HAS_F_SETLKW
0e3ce1df 159
0e3ce1df
RK
160/* Implicit library calls should use memcpy, not bcopy, etc. */
161
0f7a7be7
DB
162#undef TARGET_MEM_FUNCTIONS
163#define TARGET_MEM_FUNCTIONS 1
f31a472f
RK
164
165/* Handle #pragma weak and #pragma pack. */
166
32f0ffb3 167#define HANDLE_SYSV_PRAGMA 1
ad08e60e
JT
168
169
170/* Define some types that are the same on all NetBSD platforms,
171 making them agree with <machine/ansi.h>. */
172
173#undef WCHAR_TYPE
174#define WCHAR_TYPE "int"
175
176#undef WCHAR_TYPE_SIZE
177#define WCHAR_TYPE_SIZE 32
178
179#undef WINT_TYPE
180#define WINT_TYPE "int"
90e021a0
JT
181\f
182
183/* Attempt to turn on execute permission for the stack. This may be
184 used by TRANSFER_FROM_TRAMPOLINE of the target needs it (that is,
185 if the target machine can change execute permissions on a page).
186
187 There is no way to query the execute permission of the stack, so
188 we always issue the mprotect() call.
189
190 Note that we go out of our way to use namespace-non-invasive calls
191 here. Unfortunately, there is no libc-internal name for mprotect().
192
193 Also note that no errors should be emitted by this code; it is considered
194 dangerous for library calls to send messages to stdout/stderr. */
195
196#define NETBSD_ENABLE_EXECUTE_STACK \
197extern void __enable_execute_stack (void *); \
198void \
199__enable_execute_stack (addr) \
200 void *addr; \
201{ \
202 extern int mprotect (void *, size_t, int); \
203 extern int __sysctl (int *, unsigned int, void *, size_t *, \
204 void *, size_t); \
205 \
206 static int size; \
207 static long mask; \
208 \
209 char *page, *end; \
210 \
211 if (size == 0) \
212 { \
213 int mib[2]; \
214 size_t len; \
215 \
216 mib[0] = 6; /* CTL_HW */ \
217 mib[1] = 7; /* HW_PAGESIZE */ \
218 len = sizeof (size); \
219 (void) __sysctl (mib, 2, &size, &len, NULL, 0); \
220 mask = ~((long) size - 1); \
221 } \
222 \
223 page = (char *) (((long) addr) & mask); \
224 end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
225 \
226 /* 7 == PROT_READ | PROT_WRITE | PROT_EXEC */ \
227 (void) mprotect (page, end - page, 7); \
228}