summaryrefslogtreecommitdiff
path: root/mark_rts.c
diff options
context:
space:
mode:
authorJames Laird-Wah <james.laird-wah@saludamedical.com>2016-02-08 10:19:53 +1100
committerIvan Maidanski <ivmai@mail.ru>2016-06-02 00:33:26 +0300
commit02ec857444143a74a8624637c149634cb56bb7c6 (patch)
treeed66906b4567a47591a589dbc30752e951750f91 /mark_rts.c
parente6aa30638e7fc8d29f26d9531a9d601608c63f5b (diff)
downloadbdwgc-02ec857444143a74a8624637c149634cb56bb7c6.tar.gz
libgc: use __builtin_frame_address in GC_approx_sp
With GCC 5.x, the compiler optimises away the dummy load used to estimate the stack pointer address in GC_approx_sp; it returns zero. This leads to segfaults when embedding Mono. Instead, use __builtin_frame_address, which GCC's libgc uses for the same purpose.
Diffstat (limited to 'mark_rts.c')
-rw-r--r--mark_rts.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/mark_rts.c b/mark_rts.c
index b3e996a2..561333ab 100644
--- a/mark_rts.c
+++ b/mark_rts.c
@@ -368,6 +368,9 @@ ptr_t p;
ptr_t GC_approx_sp()
{
+#if defined(__GNUC__)
+ return __builtin_frame_address(0);
+#else
VOLATILE word dummy;
dummy = 42; /* Force stack to grow if necessary. Otherwise the */
@@ -376,17 +379,11 @@ ptr_t GC_approx_sp()
# ifdef _MSC_VER
# pragma warning(disable:4172)
# endif
-# if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 408)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wreturn-local-addr"
-# endif
return((ptr_t)(&dummy));
-# if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 408)
-# pragma GCC diagnostic pop
-# endif
# ifdef _MSC_VER
# pragma warning(default:4172)
# endif
+#endif // __GNUC__
}
/*