OSDN Git Service

new repo
[bytom/vapor.git] / vendor / golang.org / x / sys / unix / syscall_freebsd_386.go
1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // +build 386,freebsd
6
7 package unix
8
9 import (
10         "syscall"
11         "unsafe"
12 )
13
14 func Getpagesize() int { return 4096 }
15
16 func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
17
18 func NsecToTimespec(nsec int64) (ts Timespec) {
19         ts.Sec = int32(nsec / 1e9)
20         ts.Nsec = int32(nsec % 1e9)
21         return
22 }
23
24 func NsecToTimeval(nsec int64) (tv Timeval) {
25         nsec += 999 // round up to microsecond
26         tv.Usec = int32(nsec % 1e9 / 1e3)
27         tv.Sec = int32(nsec / 1e9)
28         return
29 }
30
31 func SetKevent(k *Kevent_t, fd, mode, flags int) {
32         k.Ident = uint32(fd)
33         k.Filter = int16(mode)
34         k.Flags = uint16(flags)
35 }
36
37 func (iov *Iovec) SetLen(length int) {
38         iov.Len = uint32(length)
39 }
40
41 func (msghdr *Msghdr) SetControllen(length int) {
42         msghdr.Controllen = uint32(length)
43 }
44
45 func (cmsg *Cmsghdr) SetLen(length int) {
46         cmsg.Len = uint32(length)
47 }
48
49 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
50         var writtenOut uint64 = 0
51         _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
52
53         written = int(writtenOut)
54
55         if e1 != 0 {
56                 err = e1
57         }
58         return
59 }
60
61 func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)