// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build linux && (amd64 || arm64 || ppc64le)
+//go:build linux && (amd64 || arm64 || loong64 || ppc64le)
#include <errno.h>
#include <stddef.h>
#include "libcgo.h"
// go_sigaction_t is a C version of the sigactiont struct from
-// defs_linux_amd64.go. This definition — and its conversion to and from struct
-// sigaction — are specific to linux/amd64.
+// defs_${goos}_${goarch}.go. This definition — and its conversion
+// to and from struct sigaction — are specific to ${goos}/${goarch}.
typedef struct {
uintptr_t handler;
uint64_t flags;
+#ifdef __loongarch__
+ uint64_t mask;
+ uintptr_t restorer;
+#else
uintptr_t restorer;
uint64_t mask;
+#endif
} go_sigaction_t;
// SA_RESTORER is part of the kernel interface.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build (linux && amd64) || (freebsd && amd64) || (linux && arm64) || (linux && ppc64le)
+//go:build (linux && (amd64 || arm64 || loong64 || ppc64le)) || (freebsd && amd64)
package cgo
// Support for sanitizers. See runtime/cgo/sigaction.go.
-//go:build (linux && amd64) || (freebsd && amd64) || (linux && arm64) || (linux && ppc64le)
+//go:build (linux && (amd64 || arm64 || loong64 || ppc64le)) || (freebsd && amd64)
package runtime
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build (linux && !amd64 && !arm64 && !ppc64le) || (freebsd && !amd64)
+//go:build (linux && !amd64 && !arm64 && !loong64 && !ppc64le) || (freebsd && !amd64)
package runtime
SYSCALL
RET
+// Call the function stored in _cgo_sigaction using the GCC calling convention.
+TEXT runtime·callCgoSigaction<ABIInternal>(SB),NOSPLIT,$0
+ // R4: sig, R5: new, R6: old
+ MOVV _cgo_sigaction(SB), R7
+ SUBV $16, R3 // reserve 16 bytes for sp-8 where fp may be saved.
+ JAL (R7)
+ ADDV $16, R3
+ MOVW R4, R4
+ RET
+
// func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer)
TEXT runtime·sigfwd<ABIInternal>(SB),NOSPLIT,$0
// before: