aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/os_linux.c
diff options
context:
space:
mode:
authorShenghou Ma <minux@golang.org>2014-08-06 00:24:55 -0400
committerShenghou Ma <minux@golang.org>2014-08-06 00:24:55 -0400
commitde14137b4f179d97ac303d20330ba0ad622eab28 (patch)
tree414ad536d8cdbeaf9b1c5287808e1274c78443e4 /src/pkg/runtime/os_linux.c
parent3c24b60fd3e3e6c20cba64cda8ff01fd3a2c5216 (diff)
downloadgo-de14137b4f179d97ac303d20330ba0ad622eab28.tar.xz
runtime: get rid of SA_RESTORER on ARM.
The manpages says SA_RESTORER is obsolete, and indeed, not every architecture support it. However, sadly it's required on x86_64, see http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/signal.c?id=26bcd8b72563b4c54892c4c2a409f6656fb8ae8b#n430, so only use it on x86. LGTM=rsc R=rsc, iant CC=golang-codereviews https://golang.org/cl/115450043
Diffstat (limited to 'src/pkg/runtime/os_linux.c')
-rw-r--r--src/pkg/runtime/os_linux.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/pkg/runtime/os_linux.c b/src/pkg/runtime/os_linux.c
index 31cbdb0ad5..77754f481c 100644
--- a/src/pkg/runtime/os_linux.c
+++ b/src/pkg/runtime/os_linux.c
@@ -288,7 +288,7 @@ runtime·memlimit(void)
* and calls sighandler().
*/
extern void runtime·sigtramp(void);
-extern void runtime·sigreturn(void); // calls runtime·sigreturn
+extern void runtime·sigreturn(void); // calls rt_sigreturn, only used with SA_RESTORER
void
runtime·setsig(int32 i, GoSighandler *fn, bool restart)
@@ -300,9 +300,15 @@ runtime·setsig(int32 i, GoSighandler *fn, bool restart)
if(restart)
sa.sa_flags |= SA_RESTART;
sa.sa_mask = ~0ULL;
- // TODO(adonovan): Linux manpage says "sa_restorer element is
- // obsolete and should not be used". Avoid it here, and test.
+ // Although Linux manpage says "sa_restorer element is obsolete and
+ // should not be used". x86_64 kernel requires it. Only use it on
+ // x86.
+#ifdef GOARCH_386
+ sa.sa_restorer = (void*)runtime·sigreturn;
+#endif
+#ifdef GOARCH_amd64
sa.sa_restorer = (void*)runtime·sigreturn;
+#endif
if(fn == runtime·sighandler)
fn = (void*)runtime·sigtramp;
sa.sa_handler = fn;