From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from magnesium.8pit.net (magnesium.8pit.net [45.76.88.171]) by sourceware.org (Postfix) with ESMTPS id EA7143858D1E for ; Sat, 22 Oct 2022 13:45:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EA7143858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=soeren-tempel.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=soeren-tempel.net DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=opensmtpd; bh=3/DLStVg2c emtOBApR307KV+l1AGpYjrsGFAmKiNTBc=; h=in-reply-to:references:from: subject:cc:to:date; d=soeren-tempel.net; b=k54IWNQN6bt6d+XTWm5H6KgtbTF W36lO3A+puAbc12ycMKxFvXIDs/ilzbVXySY2/SOE1j3zYGh4wFUeW6++CJaPxzzH4s7+p o7BACHCnHgnqFW0lb2jL2g8ubUbwJpeYSR2iI4cl4gNaHzJbFshi2bVT7H3Gzq4t32srCi nXZE= Received: from localhost ( [2a02:8109:3b40:22d0:d3a0:d968:2b67:ae0d]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id 237ed689 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Sat, 22 Oct 2022 15:45:24 +0200 (CEST) Date: Sat, 22 Oct 2022 15:45:19 +0200 To: iant@golang.org Cc: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Re: [PATCH] libgo: use _off_t for mmap offset argument From: =?UTF-8?Q?S=C3=B6ren?= Tempel References: <20220929144912.21826-1-soeren@soeren-tempel.net> In-Reply-To: <20220929144912.21826-1-soeren@soeren-tempel.net> Message-Id: <2T94HQTK7FOFK.2UPCTYUHVIT0G@8pit.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: PING. soeren@soeren-tempel.net wrote: > From: S=C3=B6ren Tempel >=20 > On glibc-based systems, off_t is a 32-bit type on 32-bit systems and a > 64-bit type on 64-bit systems by default. However, on systems using musl > libc off_t is unconditionally a 64-bit type. As such, it is insufficient > to use a uintptr type for the mmap offset parameter. >=20 > Presently, the (incorrect) mmap declaration causes a libgo run-time > failure on 32-bit musl systems (fatal error: runtime: cannot allocate > memory). This commit fixes this run-time error. >=20 > Signed-off-by: S=C3=B6ren Tempel > --- > This implements what has been proposed by Ian in a GitHub comment > https://github.com/golang/go/issues/51280#issuecomment-1046322011 >=20 > I don't have access to a 32-bit glibc system to test this on but > this does seem to work fine on 32-bit and 64-bit musl systems. >=20 > libgo/go/runtime/mem_gccgo.go | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/libgo/go/runtime/mem_gccgo.go b/libgo/go/runtime/mem_gccgo.g= o > index fa3389d8..07bf325a 100644 > --- a/libgo/go/runtime/mem_gccgo.go > +++ b/libgo/go/runtime/mem_gccgo.go > @@ -15,7 +15,7 @@ import ( > //go:linkname sysFree > =20 > //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 = _off_t) unsafe.Pointer > =20 > //extern munmap > func munmap(addr unsafe.Pointer, length uintptr) int32 > @@ -38,7 +38,7 @@ func init() { > } > =20 > func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uin= tptr) (unsafe.Pointer, int) { > - p :=3D sysMmap(addr, n, prot, flags, fd, off) > + p :=3D sysMmap(addr, n, prot, flags, fd, _off_t(off)) > if uintptr(p) =3D=3D _MAP_FAILED { > return nil, errno() > }