From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2116) id DB9E83858008; Fri, 28 Oct 2022 00:13:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB9E83858008 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666915995; bh=pSZhLhGVlViUIITwEzJFqrzJK8Vhzm5oPlq7QrbK9G4=; h=From:To:Subject:Date:From; b=c7lelSy0ZU91H0aUWXAC1Jj7i4ktaUmLLgDD6rPS73BvyrazU+PkWHmk9JKVQeulE IRyD1YREuF7shiEOGe6ML0u9RLie5V1xwKqTEFb8RIMdQWYmxZUc3viZLkVq7/NgLy 4+AI02tx0XED2+HWR5m5d6OsB1iJ3RKwwALQJoTE= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Ian Lance Taylor To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3532] runtime: use _libgo_off_t_type when calling C mmap X-Act-Checkin: gcc X-Git-Author: Ian Lance Taylor X-Git-Refname: refs/heads/master X-Git-Oldrev: fc01cfa96786ba94077e45c475768f38592e63cf X-Git-Newrev: 0a2984dd10598ba091b8e992145998fb1640a9b8 Message-Id: <20221028001315.DB9E83858008@sourceware.org> Date: Fri, 28 Oct 2022 00:13:15 +0000 (GMT) List-Id: https://gcc.gnu.org/g:0a2984dd10598ba091b8e992145998fb1640a9b8 commit r13-3532-g0a2984dd10598ba091b8e992145998fb1640a9b8 Author: Ian Lance Taylor Date: Wed Oct 26 17:23:42 2022 -0700 runtime: use _libgo_off_t_type when calling C mmap 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 Diff: --- gcc/go/gofrontend/MERGE | 2 +- libgo/go/runtime/mem_gccgo.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 5b95b38a541..7e531c3f90b 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -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. diff --git a/libgo/go/runtime/mem_gccgo.go b/libgo/go/runtime/mem_gccgo.go index fa3389d857e..1e84f4f5c56 100644 --- a/libgo/go/runtime/mem_gccgo.go +++ b/libgo/go/runtime/mem_gccgo.go @@ -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))