]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
runtime: use _libgo_off_t_type when calling C mmap
authorIan Lance Taylor <iant@golang.org>
Thu, 27 Oct 2022 00:23:42 +0000 (17:23 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 28 Oct 2022 00:12:57 +0000 (17:12 -0700)
The last argument to the C mmap function is type off_t, not uintptr.
On some 32-bit systems, off_t is larger than uintptr.

Based on patch by Sören Tempel.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/445735

gcc/go/gofrontend/MERGE
libgo/go/runtime/mem_gccgo.go

index 5b95b38a5410b3375e862a5828309a121e9b3710..7e531c3f90b826fa476937b2c8a7e8300285a8e1 100644 (file)
@@ -1,4 +1,4 @@
-6c188108858e3ae8c8ea8e4cc55427d8cf01bbc8
+5e658f4659c551330ea68f5667e4f951b218f32d
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index fa3389d857eac1acfaaf52bd1062eab8920a400f..1e84f4f5c561558c8bb17b45c46069e9f42b838a 100644 (file)
@@ -15,7 +15,7 @@ import (
 //go:linkname sysFree
 
 //extern mmap
-func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer
+func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off _libgo_off_t_type) unsafe.Pointer
 
 //extern munmap
 func munmap(addr unsafe.Pointer, length uintptr) int32
@@ -38,7 +38,7 @@ func init() {
 }
 
 func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) {
-       p := sysMmap(addr, n, prot, flags, fd, off)
+       p := sysMmap(addr, n, prot, flags, fd, _libgo_off_t_type(off))
        if uintptr(p) == _MAP_FAILED {
                return nil, errno()
        }
@@ -47,6 +47,7 @@ func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (u
 
 // Don't split the stack as this method may be invoked without a valid G, which
 // prevents us from allocating more stack.
+//
 //go:nosplit
 func sysAlloc(n uintptr, sysStat *sysMemStat) unsafe.Pointer {
        p, err := mmap(nil, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, mmapFD, 0)
@@ -165,6 +166,7 @@ func sysHugePage(v unsafe.Pointer, n uintptr) {
 
 // Don't split the stack as this function may be invoked without a valid G,
 // which prevents us from allocating more stack.
+//
 //go:nosplit
 func sysFree(v unsafe.Pointer, n uintptr, sysStat *sysMemStat) {
        sysStat.add(-int64(n))