diff --git a/src/runtime/cgo/gcc_mmap.c b/src/runtime/cgo/gcc_mmap.c index eb710a039d4e05..47f326140509c7 100644 --- a/src/runtime/cgo/gcc_mmap.c +++ b/src/runtime/cgo/gcc_mmap.c @@ -2,7 +2,7 @@ // 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 || loong64 || ppc64le)) || (freebsd && amd64) +//go:build (linux && (amd64 || arm64 || loong64 || ppc64le || riscv64)) || (freebsd && amd64) #include #include diff --git a/src/runtime/cgo/gcc_sigaction.c b/src/runtime/cgo/gcc_sigaction.c index f7a10df0f72449..300fdffd6a7cc0 100644 --- a/src/runtime/cgo/gcc_sigaction.c +++ b/src/runtime/cgo/gcc_sigaction.c @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build linux && (386 || amd64 || arm64 || loong64 || ppc64 || ppc64le) +//go:build linux && (386 || amd64 || arm64 || loong64 || ppc64 || ppc64le || riscv64) #include #include @@ -18,7 +18,7 @@ typedef struct { uintptr_t handler; unsigned long flags; -#ifdef __loongarch__ +#if defined(__loongarch__) || defined(__riscv) uint64_t mask; uintptr_t restorer; #else diff --git a/src/runtime/cgo/mmap.go b/src/runtime/cgo/mmap.go index 144af2b2caf826..a9973b41dc2d99 100644 --- a/src/runtime/cgo/mmap.go +++ b/src/runtime/cgo/mmap.go @@ -2,7 +2,7 @@ // 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 || loong64)) || (freebsd && amd64) +//go:build (linux && (amd64 || arm64 || loong64 || riscv64)) || (freebsd && amd64) package cgo diff --git a/src/runtime/cgo/sigaction.go b/src/runtime/cgo/sigaction.go index 62b144dbd45110..11345f1e37e09f 100644 --- a/src/runtime/cgo/sigaction.go +++ b/src/runtime/cgo/sigaction.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build (linux && (386 || amd64 || arm64 || loong64 || ppc64 || ppc64le)) || (freebsd && amd64) +//go:build (linux && (386 || amd64 || arm64 || loong64 || ppc64 || ppc64le || riscv64)) || (freebsd && amd64) package cgo diff --git a/src/runtime/cgo_mmap.go b/src/runtime/cgo_mmap.go index 36d776e628143e..6ad4e6abbe577c 100644 --- a/src/runtime/cgo_mmap.go +++ b/src/runtime/cgo_mmap.go @@ -4,7 +4,7 @@ // Support for memory sanitizer. See runtime/cgo/mmap.go. -//go:build (linux && (amd64 || arm64 || loong64)) || (freebsd && amd64) +//go:build (linux && (amd64 || arm64 || loong64 || riscv64)) || (freebsd && amd64) package runtime diff --git a/src/runtime/cgo_sigaction.go b/src/runtime/cgo_sigaction.go index b78a336a214755..d697f05bc99b08 100644 --- a/src/runtime/cgo_sigaction.go +++ b/src/runtime/cgo_sigaction.go @@ -6,7 +6,7 @@ // Also used on linux/386 to clear the SA_RESTORER flag // when using cgo; see issue #75253. -//go:build (linux && (386 || amd64 || arm64 || loong64 || ppc64 || ppc64le)) || (freebsd && amd64) +//go:build (linux && (386 || amd64 || arm64 || loong64 || ppc64 || ppc64le || riscv64)) || (freebsd && amd64) package runtime diff --git a/src/runtime/mmap.go b/src/runtime/mmap.go index 9a7b2985623d68..61568529e81c28 100644 --- a/src/runtime/mmap.go +++ b/src/runtime/mmap.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !aix && !darwin && !js && !((linux && (amd64 || arm64 || loong64)) || (freebsd && amd64)) && !openbsd && !plan9 && !solaris && !windows +//go:build !aix && !darwin && !js && !((linux && (amd64 || arm64 || loong64 || riscv64)) || (freebsd && amd64)) && !openbsd && !plan9 && !solaris && !windows package runtime diff --git a/src/runtime/sigaction.go b/src/runtime/sigaction.go index 79497763546639..898be53dbf8a44 100644 --- a/src/runtime/sigaction.go +++ b/src/runtime/sigaction.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build (linux && !386 && !amd64 && !arm64 && !loong64 && !ppc64 && !ppc64le) || (freebsd && !amd64) +//go:build (linux && !386 && !amd64 && !arm64 && !loong64 && !ppc64 && !ppc64le && !riscv64) || (freebsd && !amd64) package runtime diff --git a/src/runtime/sys_linux_riscv64.s b/src/runtime/sys_linux_riscv64.s index 72534f4128689c..313952b23d0cd8 100644 --- a/src/runtime/sys_linux_riscv64.s +++ b/src/runtime/sys_linux_riscv64.s @@ -396,31 +396,28 @@ TEXT runtime·cgoSigtramp(SB),NOSPLIT,$0 MOV $runtime·sigtramp(SB), T1 JALR ZERO, T1 +// func callCgoSigaction(sig uintptr, new, old *sigactiont) int32 +TEXT runtime·callCgoSigaction(SB),NOSPLIT,$0 + MOV _cgo_sigaction(SB), A7 + JALR X1, A7 + MOV X10, X10 // return value from C, NOP OP + RET + // func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) (p unsafe.Pointer, err int) -TEXT runtime·mmap(SB),NOSPLIT|NOFRAME,$0 - MOV addr+0(FP), A0 - MOV n+8(FP), A1 - MOVW prot+16(FP), A2 - MOVW flags+20(FP), A3 - MOVW fd+24(FP), A4 - MOVW off+28(FP), A5 +TEXT runtime·sysMmap(SB),NOSPLIT|NOFRAME,$0 MOV $SYS_mmap, A7 ECALL MOV $-4096, T0 - BGEU T0, A0, 5(PC) - SUB A0, ZERO, A0 - MOV ZERO, p+32(FP) - MOV A0, err+40(FP) + BGEU T0, A0, ok + SUB A0, ZERO, A1 + MOV ZERO, A0 RET ok: - MOV A0, p+32(FP) - MOV ZERO, err+40(FP) + MOV ZERO, A1 RET // func munmap(addr unsafe.Pointer, n uintptr) -TEXT runtime·munmap(SB),NOSPLIT|NOFRAME,$0 - MOV addr+0(FP), A0 - MOV n+8(FP), A1 +TEXT runtime·sysMunmap(SB),NOSPLIT|NOFRAME,$0 MOV $SYS_munmap, A7 ECALL MOV $-4096, T0 @@ -428,6 +425,19 @@ TEXT runtime·munmap(SB),NOSPLIT|NOFRAME,$0 WORD $0 // crash RET +// func callCgoMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) uintptr +TEXT runtime·callCgoMmap(SB),NOSPLIT,$0 + MOV _cgo_mmap(SB), A7 + JALR X1, A7 + MOV X10, X10 // return value from C, NOP OP + RET + +// func callCgoMunmap(addr unsafe.Pointer, n uintptr) +TEXT runtime·callCgoMunmap(SB),NOSPLIT,$0 + MOV _cgo_munmap(SB), A7 + JALR X1, A7 + RET + // func madvise(addr unsafe.Pointer, n uintptr, flags int32) TEXT runtime·madvise(SB),NOSPLIT,$0 MOV $SYS_madvise, A7