public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: soeren@soeren-tempel.net
To: gcc-patches@gcc.gnu.org
Cc: gofrontend-dev@googlegroups.com, iant@golang.org
Subject: [PATCH] libgo: Explicitly define SYS_timer_settime for 32-bit musl targets
Date: Thu, 28 Jul 2022 20:14:23 +0200	[thread overview]
Message-ID: <20220728181422.6959-1-soeren@soeren-tempel.net> (raw)

From: Sören Tempel <soeren+git@soeren-tempel.net>

On 32-bit systems, musl only defines SYS_timer_settime32 not
SYS_timer_settime. This causes the following compilation error:

            os_linux.go:251:30: error: reference to undefined name '_SYS_timer_settime'
              251 |         return int32(syscall(_SYS_timer_settime, uintptr(timerid), uintptr(flags), uintptr(unsafe.Pointer(new)), uintptr(unsafe.Pointer(old)), 0, 0))
                  |                              ^

This commit fixes this error by "aliasing" SYS_timer_settime to
SYS_timer_settime32 if the latter is defined. This is also what
musl does internally [1].

[1]: https://git.musl-libc.org/cgit/musl/tree/src/internal/syscall.h?h=v1.2.3#n212
---
 libgo/sysinfo.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
index fc021099..6848fba5 100644
--- a/libgo/sysinfo.c
+++ b/libgo/sysinfo.c
@@ -354,6 +354,12 @@ enum {
 };
 #endif
 
+// musl libc does not have SYS_timer_settime on 32-bit platforms
+// but defines SYS_timer_settime32 instead, alias accordingly.
+#ifdef SYS_timer_settime32
+#define SYS_timer_settime SYS_timer_settime32
+#endif
+
 #if defined(HAVE_LOFF_T)
 // loff_t can be defined as a macro; for -fgo-dump-spec make sure we
 // see a typedef.

             reply	other threads:[~2022-07-28 18:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-28 18:14 soeren [this message]
2022-07-30 17:35 ` Ian Lance Taylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220728181422.6959-1-soeren@soeren-tempel.net \
    --to=soeren@soeren-tempel.net \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gofrontend-dev@googlegroups.com \
    --cc=iant@golang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).