LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // +build darwin freebsd netbsd openbsd | 5 // +build darwin freebsd netbsd openbsd |
6 | 6 |
7 // BSD system call wrappers shared by *BSD based systems | 7 // BSD system call wrappers shared by *BSD based systems |
8 // including OS X (Darwin) and FreeBSD. Like the other | 8 // including OS X (Darwin) and FreeBSD. Like the other |
9 // syscall_*.go files it is compiled as Go code but also | 9 // syscall_*.go files it is compiled as Go code but also |
10 // used as input to mksyscall which parses the //sys | 10 // used as input to mksyscall which parses the //sys |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 } | 602 } |
603 | 603 |
604 //sys utimes(path string, timeval *[2]Timeval) (err error) | 604 //sys utimes(path string, timeval *[2]Timeval) (err error) |
605 func Utimes(path string, tv []Timeval) (err error) { | 605 func Utimes(path string, tv []Timeval) (err error) { |
606 if len(tv) != 2 { | 606 if len(tv) != 2 { |
607 return EINVAL | 607 return EINVAL |
608 } | 608 } |
609 return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) | 609 return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) |
610 } | 610 } |
611 | 611 |
| 612 func UtimesNano(path string, ts []Timespec) error { |
| 613 // TODO: The BSDs can do utimensat with SYS_UTIMENSAT but it |
| 614 // isn't supported by darwin so this uses utimes instead |
| 615 if len(ts) != 2 { |
| 616 return EINVAL |
| 617 } |
| 618 // Not as efficient as it could be because Timespec and |
| 619 // Timeval have different types in the different OSes |
| 620 tv := [2]Timeval{ |
| 621 NsecToTimeval(TimespecToNsec(ts[0])), |
| 622 NsecToTimeval(TimespecToNsec(ts[1])), |
| 623 } |
| 624 return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) |
| 625 } |
| 626 |
612 //sys futimes(fd int, timeval *[2]Timeval) (err error) | 627 //sys futimes(fd int, timeval *[2]Timeval) (err error) |
613 func Futimes(fd int, tv []Timeval) (err error) { | 628 func Futimes(fd int, tv []Timeval) (err error) { |
614 if len(tv) != 2 { | 629 if len(tv) != 2 { |
615 return EINVAL | 630 return EINVAL |
616 } | 631 } |
617 return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) | 632 return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) |
618 } | 633 } |
619 | 634 |
620 //sys fcntl(fd int, cmd int, arg int) (val int, err error) | 635 //sys fcntl(fd int, cmd int, arg int) (val int, err error) |
621 | 636 |
(...skipping 11 matching lines...) Expand all Loading... |
633 munmap: munmap, | 648 munmap: munmap, |
634 } | 649 } |
635 | 650 |
636 func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, e
rr error) { | 651 func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, e
rr error) { |
637 return mapper.Mmap(fd, offset, length, prot, flags) | 652 return mapper.Mmap(fd, offset, length, prot, flags) |
638 } | 653 } |
639 | 654 |
640 func Munmap(b []byte) (err error) { | 655 func Munmap(b []byte) (err error) { |
641 return mapper.Munmap(b) | 656 return mapper.Munmap(b) |
642 } | 657 } |
LEFT | RIGHT |