LEFT | RIGHT |
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 const ImplementsUtimens = false | 612 func UtimesNano(path string, ts []Timespec) error { |
613 | 613 » // TODO: The BSDs can do utimensat with SYS_UTIMENSAT but it |
614 // TODO: The BSDs can do utimensat with SYS_UTIMENSAT but it isn't supported by
darwin | 614 » // isn't supported by darwin so this uses utimes instead |
615 // | 615 » if len(ts) != 2 { |
616 //s*ys» utimensat(dirfd int, path string, times *[2]Timespec) (err error) | 616 » » return EINVAL |
617 func Utimens(path string, ts []Timespec) (err error) { | 617 » } |
618 » return ENOTSUP | 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]))) |
619 } | 625 } |
620 | 626 |
621 //sys futimes(fd int, timeval *[2]Timeval) (err error) | 627 //sys futimes(fd int, timeval *[2]Timeval) (err error) |
622 func Futimes(fd int, tv []Timeval) (err error) { | 628 func Futimes(fd int, tv []Timeval) (err error) { |
623 if len(tv) != 2 { | 629 if len(tv) != 2 { |
624 return EINVAL | 630 return EINVAL |
625 } | 631 } |
626 return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) | 632 return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) |
627 } | 633 } |
628 | 634 |
(...skipping 13 matching lines...) Expand all Loading... |
642 munmap: munmap, | 648 munmap: munmap, |
643 } | 649 } |
644 | 650 |
645 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) { |
646 return mapper.Mmap(fd, offset, length, prot, flags) | 652 return mapper.Mmap(fd, offset, length, prot, flags) |
647 } | 653 } |
648 | 654 |
649 func Munmap(b []byte) (err error) { | 655 func Munmap(b []byte) (err error) { |
650 return mapper.Munmap(b) | 656 return mapper.Munmap(b) |
651 } | 657 } |
LEFT | RIGHT |