Skip to content

Commit

Permalink
unix: add support for freebsd/arm64
Browse files Browse the repository at this point in the history
Updates golang/go#24715

DO NOT REVIEW
DO NOT SUBMIT

For now zerrors_freebsd_arm64.go and ztypes_freebsd_arm64.go are just
copie of the freebsd/amd64 version of the files. Regenerate once
bootstrapping a compiler works.

Change-Id: I90a7e3ea0c0b6ecab4033f2908331b7be164a236
  • Loading branch information
tklauser committed Nov 27, 2018
1 parent 62eef0e commit d1e0ef8
Show file tree
Hide file tree
Showing 7 changed files with 4,894 additions and 0 deletions.
29 changes: 29 additions & 0 deletions unix/asm_freebsd_arm64.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2018 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.

// +build !gccgo

#include "textflag.h"

//
// System call support for ARM64, FreeBSD
//

// Just jump to package syscall's implementation for all these functions.
// The runtime may know about them.

TEXT ·Syscall(SB),NOSPLIT,$0-56
JMP syscall·Syscall(SB)

TEXT ·Syscall6(SB),NOSPLIT,$0-80
JMP syscall·Syscall6(SB)

TEXT ·Syscall9(SB),NOSPLIT,$0-104
JMP syscall·Syscall9(SB)

TEXT ·RawSyscall(SB),NOSPLIT,$0-56
JMP syscall·RawSyscall(SB)

TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
JMP syscall·RawSyscall6(SB)
7 changes: 7 additions & 0 deletions unix/mkall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ freebsd_arm)
# API consistent across platforms.
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
;;
freebsd_arm64)
mkerrors="$mkerrors"
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
# Let the type of C char be signed to make the bare syscall
# API consistent between platforms.
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
;;
linux_sparc64)
GOOSARCH_in=syscall_linux_sparc64.go
unistd_h=/usr/include/sparc64-linux-gnu/asm/unistd.h
Expand Down
52 changes: 52 additions & 0 deletions unix/syscall_freebsd_arm64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2018 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.

// +build arm64,freebsd

package unix

import (
"syscall"
"unsafe"
)

func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
}

func setTimeval(sec, usec int64) Timeval {
return Timeval{Sec: sec, Usec: usec}
}

func SetKevent(k *Kevent_t, fd, mode, flags int) {
k.Ident = uint64(fd)
k.Filter = int16(mode)
k.Flags = uint16(flags)
}

func (iov *Iovec) SetLen(length int) {
iov.Len = uint64(length)
}

func (msghdr *Msghdr) SetControllen(length int) {
msghdr.Controllen = uint32(length)
}

func (cmsg *Cmsghdr) SetLen(length int) {
cmsg.Len = uint32(length)
}

func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
var writtenOut uint64 = 0
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)

written = int(writtenOut)

if e1 != 0 {
err = e1
}
return
}

func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
Loading

0 comments on commit d1e0ef8

Please sign in to comment.