Deleted Added
full compact
host-darwin.c (132718) host-darwin.c (161651)
1/* Darwin/powerpc host-specific hook definitions.
1/* Darwin/powerpc host-specific hook definitions.
2 Copyright (C) 2003 Free Software Foundation, Inc.
2 Copyright (C) 2003, 2004 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 2, or (at your
9 option) any later version.
10

--- 121 unchanged lines hidden (view full) ---

132
133 sigemptyset(&sact.sa_mask);
134 sact.sa_flags = SA_ONSTACK | SA_SIGINFO;
135 sact.sa_sigaction = segv_handler;
136 if (sigaction (SIGSEGV, &sact, 0) < 0)
137 fatal_error ("While setting up signal handler: %m");
138}
139
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 2, or (at your
9 option) any later version.
10

--- 121 unchanged lines hidden (view full) ---

132
133 sigemptyset(&sact.sa_mask);
134 sact.sa_flags = SA_ONSTACK | SA_SIGINFO;
135 sact.sa_sigaction = segv_handler;
136 if (sigaction (SIGSEGV, &sact, 0) < 0)
137 fatal_error ("While setting up signal handler: %m");
138}
139
140static void * darwin_rs6000_gt_pch_get_address (size_t);
141static bool darwin_rs6000_gt_pch_use_address (void *, size_t);
142
143#undef HOST_HOOKS_GT_PCH_GET_ADDRESS
144#define HOST_HOOKS_GT_PCH_GET_ADDRESS darwin_rs6000_gt_pch_get_address
145#undef HOST_HOOKS_GT_PCH_USE_ADDRESS
146#define HOST_HOOKS_GT_PCH_USE_ADDRESS darwin_rs6000_gt_pch_use_address
147
140#undef HOST_HOOKS_GT_PCH_GET_ADDRESS
141#define HOST_HOOKS_GT_PCH_GET_ADDRESS darwin_rs6000_gt_pch_get_address
142#undef HOST_HOOKS_GT_PCH_USE_ADDRESS
143#define HOST_HOOKS_GT_PCH_USE_ADDRESS darwin_rs6000_gt_pch_use_address
144
148
149/* Yes, this is really supposed to work. */
150static char pch_address_space[1024*1024*1024] __attribute__((aligned (4096)));
151
152/* Return the address of the PCH address space, if the PCH will fit in it. */
153
154static void *
145/* Yes, this is really supposed to work. */
146static char pch_address_space[1024*1024*1024] __attribute__((aligned (4096)));
147
148/* Return the address of the PCH address space, if the PCH will fit in it. */
149
150static void *
155darwin_rs6000_gt_pch_get_address (size_t sz)
151darwin_rs6000_gt_pch_get_address (size_t sz, int fd ATTRIBUTE_UNUSED)
156{
157 if (sz <= sizeof (pch_address_space))
158 return pch_address_space;
159 else
160 return NULL;
161}
162
163/* Check ADDR and SZ for validity, and deallocate (using munmap) that part of
164 pch_address_space beyond SZ. */
165
152{
153 if (sz <= sizeof (pch_address_space))
154 return pch_address_space;
155 else
156 return NULL;
157}
158
159/* Check ADDR and SZ for validity, and deallocate (using munmap) that part of
160 pch_address_space beyond SZ. */
161
166static bool
167darwin_rs6000_gt_pch_use_address (void *addr, size_t sz)
162static int
163darwin_rs6000_gt_pch_use_address (void *addr, size_t sz, int fd, size_t off)
168{
169 const size_t pagesize = getpagesize();
164{
165 const size_t pagesize = getpagesize();
170 bool result;
166 void *mmap_result;
167 int ret;
171
172 if ((size_t)pch_address_space % pagesize != 0
173 || sizeof (pch_address_space) % pagesize != 0)
174 abort ();
175
168
169 if ((size_t)pch_address_space % pagesize != 0
170 || sizeof (pch_address_space) % pagesize != 0)
171 abort ();
172
176 result = (addr == pch_address_space && sz <= sizeof (pch_address_space));
177 if (! result)
173 ret = (addr == pch_address_space && sz <= sizeof (pch_address_space));
174 if (! ret)
178 sz = 0;
179
180 /* Round the size to a whole page size. Normally this is a no-op. */
181 sz = (sz + pagesize - 1) / pagesize * pagesize;
182
183 if (munmap (pch_address_space + sz, sizeof (pch_address_space) - sz) != 0)
184 fatal_error ("couldn't unmap pch_address_space: %m\n");
185
175 sz = 0;
176
177 /* Round the size to a whole page size. Normally this is a no-op. */
178 sz = (sz + pagesize - 1) / pagesize * pagesize;
179
180 if (munmap (pch_address_space + sz, sizeof (pch_address_space) - sz) != 0)
181 fatal_error ("couldn't unmap pch_address_space: %m\n");
182
186 return result;
183 if (ret)
184 {
185 mmap_result = mmap (addr, sz,
186 PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED,
187 fd, off);
188
189 /* The file might not be mmap-able. */
190 ret = mmap_result != (void *) MAP_FAILED;
191
192 /* Sanity check for broken MAP_FIXED. */
193 if (ret && mmap_result != addr)
194 abort ();
195 }
196
197 return ret;
187}
198}
199
188
189const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;
200
201const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;