1 /* Base configuration file for all NetBSD targets.
2 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC 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 GCC 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 GCC; see the file COPYING. If not, write to
19 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
22 /* TARGET_OS_CPP_BUILTINS() common to all NetBSD targets. */
23 #define NETBSD_OS_CPP_BUILTINS_COMMON() \
26 builtin_define ("__NetBSD__"); \
27 builtin_define ("__unix__"); \
28 builtin_assert ("system=bsd"); \
29 builtin_assert ("system=unix"); \
30 builtin_assert ("system=NetBSD"); \
33 builtin_define ("__PIC__"); \
34 builtin_define ("__pic__"); \
39 /* CPP_SPEC parts common to all NetBSD targets. */
40 #define NETBSD_CPP_SPEC \
41 "%{posix:-D_POSIX_SOURCE} \
42 %{pthread:-D_REENTRANT -D_PTHREADS}"
44 /* NETBSD_NATIVE is defined when gcc is integrated into the NetBSD
45 source tree so it can be configured appropriately without using
46 the GNU configure/build mechanism. */
50 /* Look for the include files in the system-defined places. */
52 #undef GPLUSPLUS_INCLUDE_DIR
53 #define GPLUSPLUS_INCLUDE_DIR "/usr/include/g++"
55 #undef GPLUSPLUS_BACKWARD_INCLUDE_DIR
56 #define GPLUSPLUS_BACKWARD_INCLUDE_DIR "/usr/include/g++/backward"
58 #undef GCC_INCLUDE_DIR
59 #define GCC_INCLUDE_DIR "/usr/include"
61 #undef INCLUDE_DEFAULTS
62 #define INCLUDE_DEFAULTS \
64 { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 }, \
65 { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1 }, \
66 { GCC_INCLUDE_DIR, "GCC", 0, 0 }, \
70 /* Under NetBSD, the normal location of the compiler back ends is the
71 /usr/libexec directory. */
73 #undef STANDARD_EXEC_PREFIX
74 #define STANDARD_EXEC_PREFIX "/usr/libexec/"
76 /* Under NetBSD, the normal location of the various *crt*.o files is the
77 /usr/lib directory. */
79 #undef STANDARD_STARTFILE_PREFIX
80 #define STANDARD_STARTFILE_PREFIX "/usr/lib/"
82 #undef TOOLDIR_BASE_PREFIX
83 #define TOOLDIR_BASE_PREFIX "/usr/"
85 #undef STANDARD_BINDIR_PREFIX
86 #define STANDARD_BINDIR_PREFIX "/usr/bin"
88 #undef STANDARD_LIBEXEC_PREFIX
89 #define STANDARD_LIBEXEC_PREFIX STANDARD_EXEC_PREFIX
91 #endif /* NETBSD_NATIVE */
94 /* Provide a LIB_SPEC appropriate for NetBSD. Here we:
96 1. Select the appropriate set of libs, depending on whether we're
99 2. Include the pthread library if -pthread is specified (only
100 if threads are enabled).
102 3. Include the posix library if -posix is specified.
104 FIXME: Could eliminate the duplication here if we were allowed to
105 use string concatenation. */
107 #ifdef NETBSD_ENABLE_PTHREADS
108 #define NETBSD_LIB_SPEC \
127 #define NETBSD_LIB_SPEC \
143 #define LIB_SPEC NETBSD_LIB_SPEC
145 /* Don't provide a LIBGCC_SPEC for NetBSD as the default
146 is correct. In the --disabled-shared case -lgcc is perfect. */
148 #if defined(NETBSD_TOOLS) || defined(NETBSD_NATIVE)
149 #define LIBGCC_PICSUFFIX "_pic"
152 /* Pass -cxx-isystem to cc1/cc1plus. */
153 #define NETBSD_CC1_AND_CC1PLUS_SPEC \
157 #define CC1_SPEC NETBSD_CC1_AND_CC1PLUS_SPEC
160 #define CC1PLUS_SPEC NETBSD_CC1_AND_CC1PLUS_SPEC
162 /* When building shared libraries, the initialization and finalization
163 functions for the library are .init and .fini respectively. */
165 #define COLLECT_SHARED_INIT_FUNC(STREAM,FUNC) \
167 fprintf ((STREAM), "void __init() __asm__ (\".init\");"); \
168 fprintf ((STREAM), "void __init() {\n\t%s();\n}\n", (FUNC)); \
171 #define COLLECT_SHARED_FINI_FUNC(STREAM,FUNC) \
173 fprintf ((STREAM), "void __fini() __asm__ (\".fini\");"); \
174 fprintf ((STREAM), "void __fini() {\n\t%s();\n}\n", (FUNC)); \
177 #undef TARGET_POSIX_IO
178 #define TARGET_POSIX_IO
180 /* Handle #pragma weak and #pragma pack. */
182 #define HANDLE_SYSV_PRAGMA 1
184 /* Don't assume anything about the header files. */
185 #undef NO_IMPLICIT_EXTERN_C
186 #define NO_IMPLICIT_EXTERN_C 1
188 /* Define some types that are the same on all NetBSD platforms,
189 making them agree with <machine/ansi.h>. */
192 #define WCHAR_TYPE "int"
194 #undef WCHAR_TYPE_SIZE
195 #define WCHAR_TYPE_SIZE 32
198 #define WINT_TYPE "int"
201 /* Attempt to turn on execute permission for the stack. This may be
202 used by INITIALIZE_TRAMPOLINE of the target needs it (that is,
203 if the target machine can change execute permissions on a page).
205 There is no way to query the execute permission of the stack, so
206 we always issue the mprotect() call.
208 Note that we go out of our way to use namespace-non-invasive calls
209 here. Unfortunately, there is no libc-internal name for mprotect().
211 Also note that no errors should be emitted by this code; it is considered
212 dangerous for library calls to send messages to stdout/stderr. */
214 #define NETBSD_ENABLE_EXECUTE_STACK \
215 extern void __enable_execute_stack (void *); \
217 __enable_execute_stack (void *addr) \
219 extern int mprotect (void *, size_t, int); \
220 extern int __sysctl (int *, unsigned int, void *, size_t *, \
233 mib[0] = 6; /* CTL_HW */ \
234 mib[1] = 7; /* HW_PAGESIZE */ \
235 len = sizeof (size); \
236 (void) __sysctl (mib, 2, &size, &len, NULL, 0); \
237 mask = ~((long) size - 1); \
240 page = (char *) (((long) addr) & mask); \
241 end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
243 /* 7 == PROT_READ | PROT_WRITE | PROT_EXEC */ \
244 (void) mprotect (page, end - page, 7); \