Skip to content

Commit c647264

Browse files
committed
runtime: trivial replacements of g in signal_unix.go
Change-Id: I0d8d50c8b7ae6cd01594091392dc726cf149e34a Reviewed-on: https://go-review.googlesource.com/c/go/+/418590 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Austin Clements <[email protected]> Run-TryBot: Michael Pratt <[email protected]>
1 parent 399f50c commit c647264

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

src/runtime/signal_unix.go

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,9 @@ func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) {
433433
return
434434
}
435435
c := &sigctxt{info, ctx}
436-
g := sigFetchG(c)
437-
setg(g)
438-
if g == nil {
436+
gp := sigFetchG(c)
437+
setg(gp)
438+
if gp == nil {
439439
if sig == _SIGPROF {
440440
// Some platforms (Linux) have per-thread timers, which we use in
441441
// combination with the process-wide timer. Avoid double-counting.
@@ -462,22 +462,22 @@ func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) {
462462
return
463463
}
464464

465-
setg(g.m.gsignal)
465+
setg(gp.m.gsignal)
466466

467467
// If some non-Go code called sigaltstack, adjust.
468468
var gsignalStack gsignalStack
469-
setStack := adjustSignalStack(sig, g.m, &gsignalStack)
469+
setStack := adjustSignalStack(sig, gp.m, &gsignalStack)
470470
if setStack {
471-
g.m.gsignal.stktopsp = getcallersp()
471+
gp.m.gsignal.stktopsp = getcallersp()
472472
}
473473

474-
if g.stackguard0 == stackFork {
474+
if gp.stackguard0 == stackFork {
475475
signalDuringFork(sig)
476476
}
477477

478478
c.fixsigcode(sig)
479-
sighandler(sig, info, ctx, g)
480-
setg(g)
479+
sighandler(sig, info, ctx, gp)
480+
setg(gp)
481481
if setStack {
482482
restoreGsignalStack(&gsignalStack)
483483
}
@@ -816,34 +816,34 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
816816
//
817817
//go:linkname sigpanic
818818
func sigpanic() {
819-
g := getg()
819+
gp := getg()
820820
if !canpanic() {
821821
throw("unexpected signal during runtime execution")
822822
}
823823

824-
switch g.sig {
824+
switch gp.sig {
825825
case _SIGBUS:
826-
if g.sigcode0 == _BUS_ADRERR && g.sigcode1 < 0x1000 {
826+
if gp.sigcode0 == _BUS_ADRERR && gp.sigcode1 < 0x1000 {
827827
panicmem()
828828
}
829829
// Support runtime/debug.SetPanicOnFault.
830-
if g.paniconfault {
831-
panicmemAddr(g.sigcode1)
830+
if gp.paniconfault {
831+
panicmemAddr(gp.sigcode1)
832832
}
833-
print("unexpected fault address ", hex(g.sigcode1), "\n")
833+
print("unexpected fault address ", hex(gp.sigcode1), "\n")
834834
throw("fault")
835835
case _SIGSEGV:
836-
if (g.sigcode0 == 0 || g.sigcode0 == _SEGV_MAPERR || g.sigcode0 == _SEGV_ACCERR) && g.sigcode1 < 0x1000 {
836+
if (gp.sigcode0 == 0 || gp.sigcode0 == _SEGV_MAPERR || gp.sigcode0 == _SEGV_ACCERR) && gp.sigcode1 < 0x1000 {
837837
panicmem()
838838
}
839839
// Support runtime/debug.SetPanicOnFault.
840-
if g.paniconfault {
841-
panicmemAddr(g.sigcode1)
840+
if gp.paniconfault {
841+
panicmemAddr(gp.sigcode1)
842842
}
843-
print("unexpected fault address ", hex(g.sigcode1), "\n")
843+
print("unexpected fault address ", hex(gp.sigcode1), "\n")
844844
throw("fault")
845845
case _SIGFPE:
846-
switch g.sigcode0 {
846+
switch gp.sigcode0 {
847847
case _FPE_INTDIV:
848848
panicdivide()
849849
case _FPE_INTOVF:
@@ -852,11 +852,11 @@ func sigpanic() {
852852
panicfloat()
853853
}
854854

855-
if g.sig >= uint32(len(sigtable)) {
856-
// can't happen: we looked up g.sig in sigtable to decide to call sigpanic
855+
if gp.sig >= uint32(len(sigtable)) {
856+
// can't happen: we looked up gp.sig in sigtable to decide to call sigpanic
857857
throw("unexpected signal value")
858858
}
859-
panic(errorString(sigtable[g.sig].name))
859+
panic(errorString(sigtable[gp.sig].name))
860860
}
861861

862862
// dieFromSignal kills the program with a signal.
@@ -1117,8 +1117,8 @@ func sigfwdgo(sig uint32, info *siginfo, ctx unsafe.Pointer) bool {
11171117
// (1) we weren't in VDSO page,
11181118
// (2) we were in a goroutine (i.e., m.curg != nil), and
11191119
// (3) we weren't in CGO.
1120-
g := sigFetchG(c)
1121-
if g != nil && g.m != nil && g.m.curg != nil && !g.m.incgo {
1120+
gp := sigFetchG(c)
1121+
if gp != nil && gp.m != nil && gp.m.curg != nil && !gp.m.incgo {
11221122
return false
11231123
}
11241124

@@ -1299,18 +1299,18 @@ type gsignalStack struct {
12991299
//go:nosplit
13001300
//go:nowritebarrierrec
13011301
func setGsignalStack(st *stackt, old *gsignalStack) {
1302-
g := getg()
1302+
gp := getg()
13031303
if old != nil {
1304-
old.stack = g.m.gsignal.stack
1305-
old.stackguard0 = g.m.gsignal.stackguard0
1306-
old.stackguard1 = g.m.gsignal.stackguard1
1307-
old.stktopsp = g.m.gsignal.stktopsp
1304+
old.stack = gp.m.gsignal.stack
1305+
old.stackguard0 = gp.m.gsignal.stackguard0
1306+
old.stackguard1 = gp.m.gsignal.stackguard1
1307+
old.stktopsp = gp.m.gsignal.stktopsp
13081308
}
13091309
stsp := uintptr(unsafe.Pointer(st.ss_sp))
1310-
g.m.gsignal.stack.lo = stsp
1311-
g.m.gsignal.stack.hi = stsp + st.ss_size
1312-
g.m.gsignal.stackguard0 = stsp + _StackGuard
1313-
g.m.gsignal.stackguard1 = stsp + _StackGuard
1310+
gp.m.gsignal.stack.lo = stsp
1311+
gp.m.gsignal.stack.hi = stsp + st.ss_size
1312+
gp.m.gsignal.stackguard0 = stsp + _StackGuard
1313+
gp.m.gsignal.stackguard1 = stsp + _StackGuard
13141314
}
13151315

13161316
// restoreGsignalStack restores the gsignal stack to the value it had
@@ -1342,9 +1342,9 @@ func signalstack(s *stack) {
13421342
//go:nosplit
13431343
//go:linkname setsigsegv
13441344
func setsigsegv(pc uintptr) {
1345-
g := getg()
1346-
g.sig = _SIGSEGV
1347-
g.sigpc = pc
1348-
g.sigcode0 = _SEGV_MAPERR
1349-
g.sigcode1 = 0 // TODO: emulate si_addr
1345+
gp := getg()
1346+
gp.sig = _SIGSEGV
1347+
gp.sigpc = pc
1348+
gp.sigcode0 = _SEGV_MAPERR
1349+
gp.sigcode1 = 0 // TODO: emulate si_addr
13501350
}

0 commit comments

Comments
 (0)