internal/socket: add ppc system call definitions, for use with gccgo

Add system call definitions for 32-bit PowerPC (ppc). These are
expected to be used with gccgo, as gc does not have a suitable code
generator.

* Define the system call numbers for recvmmsg() and sendmmsg()
* Enable the 32-bit definitions of cmsghdr, iovec, and msghdr structures
* Add the structure definitions generated by godefs

This has been tested with a program that listens for UDP connections
and then sends back multiple messages with PacketConn.WriteBatch.

Fixes golang/go#45677

Change-Id: Idd7bbcfcea373db674759d3cb86aab60312403dc
GitHub-Last-Rev: dfc1dfce613590f7f5c10bb6a88354e7d1dcb3d5
GitHub-Pull-Request: golang/net#101
Reviewed-on: https://go-review.googlesource.com/c/net/+/312710
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/internal/socket/cmsghdr_linux_32bit.go b/internal/socket/cmsghdr_linux_32bit.go
index 623cf30..4936e8a 100644
--- a/internal/socket/cmsghdr_linux_32bit.go
+++ b/internal/socket/cmsghdr_linux_32bit.go
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build (arm || mips || mipsle || 386) && linux
-// +build arm mips mipsle 386
+//go:build (arm || mips || mipsle || 386 || ppc) && linux
+// +build arm mips mipsle 386 ppc
 // +build linux
 
 package socket
diff --git a/internal/socket/iovec_32bit.go b/internal/socket/iovec_32bit.go
index 1f42d03..2b8fbb3 100644
--- a/internal/socket/iovec_32bit.go
+++ b/internal/socket/iovec_32bit.go
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build (arm || mips || mipsle || 386) && (darwin || dragonfly || freebsd || linux || netbsd || openbsd)
-// +build arm mips mipsle 386
+//go:build (arm || mips || mipsle || 386 || ppc) && (darwin || dragonfly || freebsd || linux || netbsd || openbsd)
+// +build arm mips mipsle 386 ppc
 // +build darwin dragonfly freebsd linux netbsd openbsd
 
 package socket
diff --git a/internal/socket/msghdr_linux_32bit.go b/internal/socket/msghdr_linux_32bit.go
index 2e09e26..b4658fb 100644
--- a/internal/socket/msghdr_linux_32bit.go
+++ b/internal/socket/msghdr_linux_32bit.go
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build (arm || mips || mipsle || 386) && linux
-// +build arm mips mipsle 386
+//go:build (arm || mips || mipsle || 386 || ppc) && linux
+// +build arm mips mipsle 386 ppc
 // +build linux
 
 package socket
diff --git a/internal/socket/sys_linux_ppc.go b/internal/socket/sys_linux_ppc.go
new file mode 100644
index 0000000..90cfaa9
--- /dev/null
+++ b/internal/socket/sys_linux_ppc.go
@@ -0,0 +1,10 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package socket
+
+const (
+	sysRECVMMSG = 0x157
+	sysSENDMMSG = 0x15d
+)
diff --git a/internal/socket/zsys_linux_ppc.go b/internal/socket/zsys_linux_ppc.go
new file mode 100644
index 0000000..59b71da
--- /dev/null
+++ b/internal/socket/zsys_linux_ppc.go
@@ -0,0 +1,35 @@
+// Code generated by cmd/cgo -godefs; DO NOT EDIT.
+// cgo -godefs defs_linux.go
+
+package socket
+
+type iovec struct {
+	Base	*byte
+	Len	uint32
+}
+
+type msghdr struct {
+	Name		*byte
+	Namelen		uint32
+	Iov		*iovec
+	Iovlen		uint32
+	Control		*byte
+	Controllen	uint32
+	Flags		int32
+}
+
+type mmsghdr struct {
+	Hdr	msghdr
+	Len	uint32
+}
+
+type cmsghdr struct {
+	Len	uint32
+	Level	int32
+	Type	int32
+}
+
+const (
+	sizeofIovec	= 0x8
+	sizeofMsghdr	= 0x1c
+)