Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/runtime/cgo/gcc_mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <errno.h>
#include <stdint.h>
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/cgo/gcc_sigaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <errno.h>
#include <stddef.h>
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/cgo/mmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/cgo/sigaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/cgo_mmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/cgo_sigaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/mmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/sigaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
42 changes: 26 additions & 16 deletions src/runtime/sys_linux_riscv64.s
Original file line number Diff line number Diff line change
Expand Up @@ -396,38 +396,48 @@ 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<ABIInternal>(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<ABIInternal>(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<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
MOV $SYS_munmap, A7
ECALL
MOV $-4096, T0
BLTU A0, T0, 2(PC)
WORD $0 // crash
RET

// func callCgoMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) uintptr
TEXT runtime·callCgoMmap<ABIInternal>(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<ABIInternal>(SB),NOSPLIT,$0
MOV _cgo_munmap(SB), A7
JALR X1, A7
RET

// func madvise(addr unsafe.Pointer, n uintptr, flags int32)
TEXT runtime·madvise<ABIInternal>(SB),NOSPLIT,$0
MOV $SYS_madvise, A7
Expand Down
Loading