public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libgo: include asm/ptrace.h for pt_regs definition on PowerPC
@ 2022-01-02 16:37 soeren
  2022-02-20 10:43 ` Sören Tempel
                   ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: soeren @ 2022-01-02 16:37 UTC (permalink / raw)
  To: gcc-patches

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

Both glibc and musl libc declare pt_regs as an incomplete type. This
type has to be completed by inclusion of another header. On Linux, the
asm/ptrace.h header file provides this type definition. Without
including this header file, it is not possible to access the regs member
of the mcontext_t struct as done in libgo/runtime/go-signal.c. On glibc,
other headers (e.g. sys/user.h) include asm/ptrace.h but on musl
asm/ptrace.h is not included by other headers and thus the
aforementioned files do not compile without an explicit include of
asm/ptrace.h:

	libgo/runtime/go-signal.c: In function 'getSiginfo':
	libgo/runtime/go-signal.c:227:63: error: invalid use of undefined type 'struct pt_regs'
	  227 |         ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.regs->nip;
	      |

See also:

* https://git.musl-libc.org/cgit/musl/commit/?id=c2518a8efb6507f1b41c3b12e03b06f8f2317a1f
* https://github.com/kaniini/libucontext/issues/36

Signed-off-by: Sören Tempel <soeren@soeren-tempel.net>

ChangeLog:

	* libgo/runtime/go-signal.c: Include asm/ptrace.h for the
	  definition of pt_regs (used by mcontext_t) on PowerPC.
---
 libgo/runtime/go-signal.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c
index d30d1603adc..fc01e04e4a1 100644
--- a/libgo/runtime/go-signal.c
+++ b/libgo/runtime/go-signal.c
@@ -10,6 +10,12 @@
 #include <sys/time.h>
 #include <ucontext.h>
 
+// On PowerPC, ucontext.h uses a pt_regs struct as an incomplete
+// type. This type must be completed by including asm/ptrace.h.
+#ifdef __PPC__
+#include <asm/ptrace.h>
+#endif
+
 #include "runtime.h"
 
 #ifndef SA_RESTART

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2022-04-21  0:50 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-02 16:37 [PATCH] libgo: include asm/ptrace.h for pt_regs definition on PowerPC soeren
2022-02-20 10:43 ` Sören Tempel
2022-02-21 17:25   ` [gofrontend-dev] " Ian Lance Taylor
2022-03-06 12:49     ` Sören Tempel
2022-03-06 15:22     ` Rich Felker
2022-03-06 16:59       ` Rich Felker
2022-02-20 11:01 ` Andreas Schwab
2022-03-06 18:59 ` [PATCH v2] libgo: Don't use pt_regs member in mcontext_t soeren
2022-03-06 21:21   ` Rich Felker
2022-03-07  7:09     ` [PATCH v3] " soeren
2022-03-07 22:59       ` Ian Lance Taylor
2022-03-08 13:23         ` Rich Felker
2022-03-09  7:26         ` Sören Tempel
2022-03-09 11:52           ` Rich Felker
2022-03-11  7:34             ` [PATCH v4] " soeren
2022-03-31 16:41               ` Sören Tempel
2022-03-31 20:26                 ` Ian Lance Taylor
2022-04-02  8:21                   ` Sören Tempel
2022-04-03  2:02                     ` Ian Lance Taylor
2022-04-03  9:28                       ` Sören Tempel
2022-04-11 17:25                         ` Sören Tempel
2022-04-11 17:35                           ` Ian Lance Taylor
2022-04-11 18:28                             ` Sören Tempel
2022-04-14 22:15                               ` Ian Lance Taylor
2022-04-21  0:50                                 ` Ian Lance Taylor

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).