diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-11-05 17:41:07 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-11-05 17:41:07 +0000 |
commit | dfd1bdace6e4d4aed998fe47ae60ad9dab4b8afc (patch) | |
tree | f7b1e226211617dcc317d0413f922d7679e09a20 /libgo | |
parent | 05e0183632c44001e7ab99f3d5cb054c82eb29da (diff) | |
download | gcc-dfd1bdace6e4d4aed998fe47ae60ad9dab4b8afc.tar.gz |
runtime: provide initcontext and fixcontext for NetBSD
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193173 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/runtime/proc.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c index 8e82d128781..43071e581cc 100644 --- a/libgo/runtime/proc.c +++ b/libgo/runtime/proc.c @@ -82,7 +82,7 @@ fixcontext(ucontext_t *c __attribute__ ((unused))) { } -# else +#else # if defined(__x86_64__) && defined(__sun__) @@ -110,6 +110,28 @@ fixcontext(ucontext_t* c) c->uc_mcontext.gregs[REG_FSBASE] = fs; } +# elif defined(__NetBSD__) + +// NetBSD has a bug: setcontext clobbers tlsbase, we need to save +// and restore it ourselves. + +static __thread __greg_t tlsbase; + +static inline void +initcontext(void) +{ + ucontext_t c; + + getcontext(&c); + tlsbase = c.uc_mcontext._mc_tlsbase; +} + +static inline void +fixcontext(ucontext_t* c) +{ + c->uc_mcontext._mc_tlsbase = tlsbase; +} + # else # error unknown case for SETCONTEXT_CLOBBERS_TLS |