1 /* Base configuration file for all NetBSD targets.
2 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* TARGET_OS_CPP_BUILTINS() common to all NetBSD targets. */
23 #define NETBSD_OS_CPP_BUILTINS_COMMON() \
26 builtin_define ("__NetBSD__"); \
27 builtin_assert ("system=unix"); \
28 builtin_assert ("system=NetBSD"); \
32 /* TARGET_OS_CPP_BUILTINS() common to all LP64 NetBSD targets. */
33 #define NETBSD_OS_CPP_BUILTINS_LP64() \
36 builtin_define ("_LP64"); \
40 /* CPP_SPEC parts common to all NetBSD targets. */
41 #define NETBSD_CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
43 /* NETBSD_NATIVE is defined when gcc is integrated into the NetBSD
44 source tree so it can be configured appropriately without using
45 the GNU configure/build mechanism. */
49 /* Look for the include files in the system-defined places. */
51 #undef GPLUSPLUS_INCLUDE_DIR
52 #define GPLUSPLUS_INCLUDE_DIR "/usr/include/g++"
54 #undef GCC_INCLUDE_DIR
55 #define GCC_INCLUDE_DIR "/usr/include"
57 #undef INCLUDE_DEFAULTS
58 #define INCLUDE_DEFAULTS \
60 { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 }, \
61 { GCC_INCLUDE_DIR, "GCC", 0, 0 }, \
65 /* Under NetBSD, the normal location of the compiler back ends is the
66 /usr/libexec directory. */
68 #undef STANDARD_EXEC_PREFIX
69 #define STANDARD_EXEC_PREFIX "/usr/libexec/"
71 /* Under NetBSD, the normal location of the various *crt*.o files is the
72 /usr/lib directory. */
74 #undef STANDARD_STARTFILE_PREFIX
75 #define STANDARD_STARTFILE_PREFIX "/usr/lib/"
77 #endif /* NETBSD_NATIVE */
80 /* Provide a LIB_SPEC appropriate for NetBSD. Here we:
82 1. Select the appropriate set of libs, depending on whether we're
85 2. Include the pthread library if -pthread is specified (only
86 if threads are enabled).
88 3. Include the posix library if -posix is specified.
90 FIXME: Could eliminate the duplication here if we were allowed to
91 use string concatenation. */
93 #ifdef NETBSD_ENABLE_PTHREADS
94 #define NETBSD_LIB_SPEC \
112 #define NETBSD_LIB_SPEC \
127 #define LIB_SPEC NETBSD_LIB_SPEC
129 /* Provide a LIBGCC_SPEC appropriate for NetBSD. We also want to exclude
130 libgcc with -symbolic. */
133 #define NETBSD_LIBGCC_SPEC \
138 %{shared: -lgcc_pic} \
142 #define NETBSD_LIBGCC_SPEC "%{!shared:%{!symbolic: -lgcc}}"
146 #define LIBGCC_SPEC NETBSD_LIBGCC_SPEC
148 /* When building shared libraries, the initialization and finalization
149 functions for the library are .init and .fini respectively. */
151 #define COLLECT_SHARED_INIT_FUNC(STREAM,FUNC) \
153 fprintf ((STREAM), "void __init() __asm__ (\".init\");"); \
154 fprintf ((STREAM), "void __init() {\n\t%s();\n}\n", (FUNC)); \
157 #define COLLECT_SHARED_FINI_FUNC(STREAM,FUNC) \
159 fprintf ((STREAM), "void __fini() __asm__ (\".fini\");"); \
160 fprintf ((STREAM), "void __fini() {\n\t%s();\n}\n", (FUNC)); \
163 #undef TARGET_HAS_F_SETLKW
164 #define TARGET_HAS_F_SETLKW
166 /* Implicit library calls should use memcpy, not bcopy, etc. */
168 #undef TARGET_MEM_FUNCTIONS
169 #define TARGET_MEM_FUNCTIONS 1
171 /* Handle #pragma weak and #pragma pack. */
173 #define HANDLE_SYSV_PRAGMA 1
176 /* Define some types that are the same on all NetBSD platforms,
177 making them agree with <machine/ansi.h>. */
180 #define WCHAR_TYPE "int"
182 #undef WCHAR_TYPE_SIZE
183 #define WCHAR_TYPE_SIZE 32
186 #define WINT_TYPE "int"
189 /* Attempt to turn on execute permission for the stack. This may be
190 used by TRANSFER_FROM_TRAMPOLINE of the target needs it (that is,
191 if the target machine can change execute permissions on a page).
193 There is no way to query the execute permission of the stack, so
194 we always issue the mprotect() call.
196 Note that we go out of our way to use namespace-non-invasive calls
197 here. Unfortunately, there is no libc-internal name for mprotect().
199 Also note that no errors should be emitted by this code; it is considered
200 dangerous for library calls to send messages to stdout/stderr. */
202 #define NETBSD_ENABLE_EXECUTE_STACK \
203 extern void __enable_execute_stack (void *); \
205 __enable_execute_stack (addr) \
208 extern int mprotect (void *, size_t, int); \
209 extern int __sysctl (int *, unsigned int, void *, size_t *, \
222 mib[0] = 6; /* CTL_HW */ \
223 mib[1] = 7; /* HW_PAGESIZE */ \
224 len = sizeof (size); \
225 (void) __sysctl (mib, 2, &size, &len, NULL, 0); \
226 mask = ~((long) size - 1); \
229 page = (char *) (((long) addr) & mask); \
230 end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
232 /* 7 == PROT_READ | PROT_WRITE | PROT_EXEC */ \
233 (void) mprotect (page, end - page, 7); \