Commit de14137b authored by Shenghou Ma's avatar Shenghou Ma

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
parent 3c24b60f
...@@ -16,7 +16,7 @@ enum { ...@@ -16,7 +16,7 @@ enum {
MADV_DONTNEED = 0x4, MADV_DONTNEED = 0x4,
SA_RESTART = 0x10000000, SA_RESTART = 0x10000000,
SA_ONSTACK = 0x8000000, SA_ONSTACK = 0x8000000,
SA_RESTORER = 0x4000000, SA_RESTORER = 0, // unused on ARM
SA_SIGINFO = 0x4, SA_SIGINFO = 0x4,
SIGHUP = 0x1, SIGHUP = 0x1,
SIGINT = 0x2, SIGINT = 0x2,
......
...@@ -288,7 +288,7 @@ runtime·memlimit(void) ...@@ -288,7 +288,7 @@ runtime·memlimit(void)
* and calls sighandler(). * and calls sighandler().
*/ */
extern void runtime·sigtramp(void); 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 void
runtime·setsig(int32 i, GoSighandler *fn, bool restart) runtime·setsig(int32 i, GoSighandler *fn, bool restart)
...@@ -300,9 +300,15 @@ runtime·setsig(int32 i, GoSighandler *fn, bool restart) ...@@ -300,9 +300,15 @@ runtime·setsig(int32 i, GoSighandler *fn, bool restart)
if(restart) if(restart)
sa.sa_flags |= SA_RESTART; sa.sa_flags |= SA_RESTART;
sa.sa_mask = ~0ULL; sa.sa_mask = ~0ULL;
// TODO(adonovan): Linux manpage says "sa_restorer element is // Although Linux manpage says "sa_restorer element is obsolete and
// obsolete and should not be used". Avoid it here, and test. // 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; sa.sa_restorer = (void*)runtime·sigreturn;
#endif
if(fn == runtime·sighandler) if(fn == runtime·sighandler)
fn = (void*)runtime·sigtramp; fn = (void*)runtime·sigtramp;
sa.sa_handler = fn; sa.sa_handler = fn;
......
...@@ -340,11 +340,6 @@ TEXT runtime·rt_sigaction(SB),NOSPLIT,$0 ...@@ -340,11 +340,6 @@ TEXT runtime·rt_sigaction(SB),NOSPLIT,$0
SWI $0 SWI $0
RET RET
TEXT runtime·sigreturn(SB),NOSPLIT,$0
MOVW $SYS_rt_sigreturn, R7
SWI $0
RET
TEXT runtime·usleep(SB),NOSPLIT,$12 TEXT runtime·usleep(SB),NOSPLIT,$12
MOVW usec+0(FP), R0 MOVW usec+0(FP), R0
MOVW R0, R1 MOVW R0, R1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment