syscall: add support for s390x
On s390x char is unsigned. We cannot force it to be signed using
-fsigned-char (see arm64) because the s390x gccgo API is already
public and we need to stick as closely as possible to it to avoid
breaking existing projects. In order to match the gccgo API we
also force the RawSockaddr.Data and RawSockaddrUnix.Path fields
to be signed.
This CL adds a post-processing pass (mkpost.go) to mkall.sh in
order to export the types of fields in PtraceRegs on s390x
without affecting the API on other platforms. The types of these
fields match their counterparts in gccgo. mkpost.go also cleans
up the Pad_cgo* fields and X_* fields (these fields are not
exported by gccgo currently). It could be extended to add build
tags on platforms that need them.
Change-Id: I66bdf5b86ec98af70baf666989027bb354df9e3e
Reviewed-on: https://go-review.googlesource.com/20961
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/src/syscall/types_linux.go b/src/syscall/types_linux.go
index cff4069..9bccfca 100644
--- a/src/syscall/types_linux.go
+++ b/src/syscall/types_linux.go
@@ -77,8 +77,8 @@
// copied from /usr/include/linux/un.h
struct my_sockaddr_un {
sa_family_t sun_family;
-#if defined(__ARM_EABI__) || defined(__powerpc64__)
- // on ARM and PPC char is by default unsigned
+#if defined(__ARM_EABI__) || defined(__powerpc64__) || defined(__s390x__)
+ // on ARM, PPC and s390x char is by default unsigned
signed char sun_path[108];
#else
char sun_path[108];
@@ -93,10 +93,22 @@
typedef struct pt_regs PtraceRegs;
#elif defined(__mips__)
typedef struct user PtraceRegs;
+#elif defined(__s390x__)
+typedef struct _user_regs_struct PtraceRegs;
#else
typedef struct user_regs_struct PtraceRegs;
#endif
+#if defined(__s390x__)
+typedef struct _user_psw_struct ptracePsw;
+typedef struct _user_fpregs_struct ptraceFpregs;
+typedef struct _user_per_struct ptracePer;
+#else
+typedef struct {} ptracePsw;
+typedef struct {} ptraceFpregs;
+typedef struct {} ptracePer;
+#endif
+
// The real epoll_event is a union, and godefs doesn't handle it well.
struct my_epoll_event {
uint32_t events;
@@ -367,6 +379,13 @@
// Register structures
type PtraceRegs C.PtraceRegs
+// Structures contained in PtraceRegs on s390x (exported by post.go)
+type ptracePsw C.ptracePsw
+
+type ptraceFpregs C.ptraceFpregs
+
+type ptracePer C.ptracePer
+
// Misc
type FdSet C.fd_set