Commit 68a71b6b authored by Shawn Walker-Salas's avatar Shawn Walker-Salas Committed by Aram Hăvărneanu

unix: add various missing syscalls available on Linux

Various syscalls offered by x/sys/unix on Linux are not available on
Solaris and should be, such as Mkfifo, Getwd(), Futimes() and others.
In particular, all of the *at() variants of existing functions were
added where appropriate.

Getgroups() was fixed to use the correct value for its sanity check on
the maximum number of groups.

Utimesnano() was updated to use the native Solaris utimensat function
for setting nanosecond-precision time.

Utimes() was updated to have the same error semantics and checking as
other platforms.

Getgroups(), anysocktoaddr(), and Recvmsg() were fixed to check the
return value before assuming syscall failure instead of relying solely
on errno being set.

mksyscall_solaris.pl needed some updates to better match the output of
the one found in syscall.

mkerrors.sh needed some updates to work out of the box on Solaris,
matching those recently done to the one in syscall.

The signatures (names) of some function parameters were changed to be
consistent with other platforms for the sake of documentation.

Fixes #8609

Change-Id: I9e4e2fee6d3ecfad9f4d845a5702ffde5166e804
Reviewed-on: https://go-review.googlesource.com/14643Reviewed-by: 's avatarAram Hăvărneanu <aram@mgk.ro>
parent 131454b5
......@@ -12,12 +12,17 @@ export LC_ALL=C
export LC_CTYPE=C
if test -z "$GOARCH" -o -z "$GOOS"; then
echo 1>&2 "GOARCH or GOOS not defined in environment"
exit 1
echo 1>&2 "GOARCH or GOOS not defined in environment"
exit 1
fi
CC=${CC:-gcc}
if [[ "$GOOS" -eq "solaris" ]]; then
# Assumes GNU versions of utilities in PATH.
export PATH=/usr/gnu/bin:$PATH
fi
uname=$(uname)
includes_Darwin='
......@@ -200,6 +205,7 @@ includes_OpenBSD='
'
includes_SunOS='
#include <limits.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/sockio.h>
......
......@@ -110,9 +110,9 @@ while(<>) {
$sysname =~ y/A-Z/a-z/; # All libc functions are lowercase.
# Runtime import of function to allow cross-platform builds.
$dynimports .= "//go:cgo_import_dynamic ${modname}_${sysname} ${sysname} \"$modname.so\"\n";
$dynimports .= "//go:cgo_import_dynamic libc_${sysname} ${sysname} \"$modname.so\"\n";
# Link symbol to proc address variable.
$linknames .= "//go:linkname ${sysvarname} ${modname}_${sysname}\n";
$linknames .= "//go:linkname ${sysvarname} libc_${sysname}\n";
# Library proc address variable.
push @vars, $sysvarname;
......
This diff is collapsed.
......@@ -15,8 +15,14 @@ package unix
/*
#define KERNEL
// These defines ensure that builds done on newer versions of Solaris are
// backwards-compatible with older versions of Solaris and
// OpenSolaris-based derivatives.
#define __USE_SUNOS_SOCKETS__ // msghdr
#define __USE_LEGACY_PROTOTYPES__ // iovec
#include <dirent.h>
#include <fcntl.h>
#include <limits.h>
#include <signal.h>
#include <termios.h>
#include <stdio.h>
......@@ -30,7 +36,9 @@ package unix
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <net/bpf.h>
......@@ -40,6 +48,8 @@ package unix
#include <netinet/in.h>
#include <netinet/icmp6.h>
#include <netinet/tcp.h>
#include <ustat.h>
#include <utime.h>
enum {
sizeofPtr = sizeof(void*),
......@@ -69,6 +79,7 @@ const (
sizeofInt = C.sizeof_int
sizeofLong = C.sizeof_long
sizeofLongLong = C.sizeof_longlong
PathMax = C.PATH_MAX
)
// Basic types
......@@ -88,6 +99,10 @@ type Timeval C.struct_timeval
type Timeval32 C.struct_timeval32
type Tms C.struct_tms
type Utimbuf C.struct_utimbuf
// Processes
type Rusage C.struct_rusage
......@@ -175,6 +190,20 @@ const (
type FdSet C.fd_set
// Misc
type Utsname C.struct_utsname
type Ustat_t C.struct_ustat
const (
AT_FDCWD = C.AT_FDCWD
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW
AT_REMOVEDIR = C.AT_REMOVEDIR
AT_EACCESS = C.AT_EACCESS
)
// Routing and interface messages
const (
......
This diff is collapsed.
// +build amd64,solaris
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs types_solaris.go
// +build amd64,solaris
package unix
const (
......@@ -11,6 +10,7 @@ const (
sizeofInt = 0x4
sizeofLong = 0x8
sizeofLongLong = 0x8
PathMax = 0x400
)
type (
......@@ -35,6 +35,18 @@ type Timeval32 struct {
Usec int32
}
type Tms struct {
Utime int64
Stime int64
Cutime int64
Cstime int64
}
type Utimbuf struct {
Actime int64
Modtime int64
}
type Rusage struct {
Utime Timeval
Stime Timeval
......@@ -230,6 +242,30 @@ type FdSet struct {
Bits [1024]int64
}
type Utsname struct {
Sysname [257]int8
Nodename [257]int8
Release [257]int8
Version [257]int8
Machine [257]int8
}
type Ustat_t struct {
Tfree int64
Tinode uint64
Fname [6]int8
Fpack [6]int8
Pad_cgo_0 [4]byte
}
const (
AT_FDCWD = -0x2e6aad
AT_SYMLINK_NOFOLLOW = 0x1000
AT_SYMLINK_FOLLOW = 0x2000
AT_REMOVEDIR = 0x1
AT_EACCESS = 0x4
)
const (
SizeofIfMsghdr = 0x54
SizeofIfData = 0x44
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment