OLD | NEW |
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 // TODO: The BSDs can do utimensat with SYS_UTIMENSAT but it isn't supported by
darwin |
| 613 // so this uses utimes instead |
| 614 // |
| 615 //s*ys utimensat(dirfd int, path string, times *[2]Timespec) (err error) |
| 616 func UtimesNano(path string, ts []Timespec) (err error) { |
| 617 if len(ts) != 2 { |
| 618 return EINVAL |
| 619 } |
| 620 // Not as efficient as it could be because Timespec and |
| 621 // Timeval have different types in the different OSes |
| 622 tv := [2]Timeval{ |
| 623 NsecToTimeval(TimespecToNsec(ts[0])), |
| 624 NsecToTimeval(TimespecToNsec(ts[1])), |
| 625 } |
| 626 return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) |
| 627 } |
| 628 |
612 //sys futimes(fd int, timeval *[2]Timeval) (err error) | 629 //sys futimes(fd int, timeval *[2]Timeval) (err error) |
613 func Futimes(fd int, tv []Timeval) (err error) { | 630 func Futimes(fd int, tv []Timeval) (err error) { |
614 if len(tv) != 2 { | 631 if len(tv) != 2 { |
615 return EINVAL | 632 return EINVAL |
616 } | 633 } |
617 return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) | 634 return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) |
618 } | 635 } |
619 | 636 |
620 //sys fcntl(fd int, cmd int, arg int) (val int, err error) | 637 //sys fcntl(fd int, cmd int, arg int) (val int, err error) |
621 | 638 |
(...skipping 11 matching lines...) Expand all Loading... |
633 munmap: munmap, | 650 munmap: munmap, |
634 } | 651 } |
635 | 652 |
636 func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, e
rr error) { | 653 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) | 654 return mapper.Mmap(fd, offset, length, prot, flags) |
638 } | 655 } |
639 | 656 |
640 func Munmap(b []byte) (err error) { | 657 func Munmap(b []byte) (err error) { |
641 return mapper.Munmap(b) | 658 return mapper.Munmap(b) |
642 } | 659 } |
OLD | NEW |