summaryrefslogtreecommitdiff
path: root/gcc/ggc-page.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>1999-10-18 16:38:40 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>1999-10-18 16:38:40 +0000
commit42f8e268c22bc66bdf9b98f2e319245025d342f5 (patch)
tree6596f54ce7edff04d59fdda5983ef7953fa1f015 /gcc/ggc-page.c
parent33b090ebcd903ef520475bb301daec2d708a216e (diff)
downloadgcc-42f8e268c22bc66bdf9b98f2e319245025d342f5.tar.gz
* ggc-page.c (init_ggc): Work around SunOS unaligned mmap bug.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@30070 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ggc-page.c')
-rw-r--r--gcc/ggc-page.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
index ecd116db5e6..24a8e2de2ad 100644
--- a/gcc/ggc-page.c
+++ b/gcc/ggc-page.c
@@ -797,6 +797,26 @@ init_ggc ()
G.allocated_last_gc = GGC_MIN_LAST_ALLOCATED;
+#ifdef HAVE_MMAP
+ /* StunOS has an amazing off-by-one error for the first mmap allocation
+ after fiddling with RLIMIT_STACK. The result, as hard as it is to
+ believe, is an unaligned page allocation, which would cause us to
+ hork badly if we tried to use it. */
+ {
+ char *p = alloc_anon (NULL, G.pagesize);
+ if ((size_t)p & (G.pagesize - 1))
+ {
+ /* How losing. Discard this one and try another. If we still
+ can't get something useful, give up. */
+
+ p = alloc_anon (NULL, G.pagesize);
+ if ((size_t)p & (G.pagesize - 1))
+ abort ();
+ }
+ munmap (p, G.pagesize);
+ }
+#endif
+
empty_string = ggc_alloc_string ("", 0);
ggc_add_string_root (&empty_string, 1);
}