Source file src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_arm.go
     1	
     2	
     3	
     4	
     5	
     6	
     7	package unix
     8	
     9	import (
    10		"syscall"
    11		"unsafe"
    12	)
    13	
    14	func setTimespec(sec, nsec int64) Timespec {
    15		return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
    16	}
    17	
    18	func setTimeval(sec, usec int64) Timeval {
    19		return Timeval{Sec: int32(sec), Usec: int32(usec)}
    20	}
    21	
    22	
    23	
    24	func Pipe(p []int) (err error) {
    25		if len(p) != 2 {
    26			return EINVAL
    27		}
    28		var pp [2]_C_int
    29		
    30		err = pipe2(&pp, 0)
    31		if err == ENOSYS {
    32			err = pipe(&pp)
    33		}
    34		p[0] = int(pp[0])
    35		p[1] = int(pp[1])
    36		return
    37	}
    38	
    39	
    40	
    41	func Pipe2(p []int, flags int) (err error) {
    42		if len(p) != 2 {
    43			return EINVAL
    44		}
    45		var pp [2]_C_int
    46		err = pipe2(&pp, flags)
    47		p[0] = int(pp[0])
    48		p[1] = int(pp[1])
    49		return
    50	}
    51	
    52	
    53	
    54	func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno)
    55	
    56	func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
    57		newoffset, errno := seek(fd, offset, whence)
    58		if errno != 0 {
    59			return 0, errno
    60		}
    61		return newoffset, nil
    62	}
    63	
    64	
    65	
    66	
    67	
    68	
    69	
    70	
    71	
    72	
    73	
    74	
    75	
    76	
    77	
    78	
    79	
    80	
    81	
    82	
    83	
    84	
    85	
    86	
    87	
    88	
    89	
    90	
    91	
    92	
    93	
    94	
    95	
    96	
    97	
    98	
    99	
   100	
   101	
   102	
   103	
   104	
   105	
   106	
   107	
   108	
   109	
   110	
   111	
   112	
   113	
   114	
   115	func Time(t *Time_t) (Time_t, error) {
   116		var tv Timeval
   117		err := Gettimeofday(&tv)
   118		if err != nil {
   119			return 0, err
   120		}
   121		if t != nil {
   122			*t = Time_t(tv.Sec)
   123		}
   124		return Time_t(tv.Sec), nil
   125	}
   126	
   127	func Utime(path string, buf *Utimbuf) error {
   128		tv := []Timeval{
   129			{Sec: buf.Actime},
   130			{Sec: buf.Modtime},
   131		}
   132		return Utimes(path, tv)
   133	}
   134	
   135	
   136	
   137	
   138	
   139	
   140	
   141	
   142	func Fadvise(fd int, offset int64, length int64, advice int) (err error) {
   143		_, _, e1 := Syscall6(SYS_ARM_FADVISE64_64, uintptr(fd), uintptr(advice), uintptr(offset), uintptr(offset>>32), uintptr(length), uintptr(length>>32))
   144		if e1 != 0 {
   145			err = errnoErr(e1)
   146		}
   147		return
   148	}
   149	
   150	
   151	
   152	func Fstatfs(fd int, buf *Statfs_t) (err error) {
   153		_, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
   154		if e != 0 {
   155			err = e
   156		}
   157		return
   158	}
   159	
   160	func Statfs(path string, buf *Statfs_t) (err error) {
   161		pathp, err := BytePtrFromString(path)
   162		if err != nil {
   163			return err
   164		}
   165		_, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(pathp)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
   166		if e != 0 {
   167			err = e
   168		}
   169		return
   170	}
   171	
   172	func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
   173		page := uintptr(offset / 4096)
   174		if offset != int64(page)*4096 {
   175			return 0, EINVAL
   176		}
   177		return mmap2(addr, length, prot, flags, fd, page)
   178	}
   179	
   180	type rlimit32 struct {
   181		Cur uint32
   182		Max uint32
   183	}
   184	
   185	
   186	
   187	const rlimInf32 = ^uint32(0)
   188	const rlimInf64 = ^uint64(0)
   189	
   190	func Getrlimit(resource int, rlim *Rlimit) (err error) {
   191		err = prlimit(0, resource, nil, rlim)
   192		if err != ENOSYS {
   193			return err
   194		}
   195	
   196		rl := rlimit32{}
   197		err = getrlimit(resource, &rl)
   198		if err != nil {
   199			return
   200		}
   201	
   202		if rl.Cur == rlimInf32 {
   203			rlim.Cur = rlimInf64
   204		} else {
   205			rlim.Cur = uint64(rl.Cur)
   206		}
   207	
   208		if rl.Max == rlimInf32 {
   209			rlim.Max = rlimInf64
   210		} else {
   211			rlim.Max = uint64(rl.Max)
   212		}
   213		return
   214	}
   215	
   216	
   217	
   218	func Setrlimit(resource int, rlim *Rlimit) (err error) {
   219		err = prlimit(0, resource, rlim, nil)
   220		if err != ENOSYS {
   221			return err
   222		}
   223	
   224		rl := rlimit32{}
   225		if rlim.Cur == rlimInf64 {
   226			rl.Cur = rlimInf32
   227		} else if rlim.Cur < uint64(rlimInf32) {
   228			rl.Cur = uint32(rlim.Cur)
   229		} else {
   230			return EINVAL
   231		}
   232		if rlim.Max == rlimInf64 {
   233			rl.Max = rlimInf32
   234		} else if rlim.Max < uint64(rlimInf32) {
   235			rl.Max = uint32(rlim.Max)
   236		} else {
   237			return EINVAL
   238		}
   239	
   240		return setrlimit(resource, &rl)
   241	}
   242	
   243	func (r *PtraceRegs) PC() uint64 { return uint64(r.Uregs[15]) }
   244	
   245	func (r *PtraceRegs) SetPC(pc uint64) { r.Uregs[15] = uint32(pc) }
   246	
   247	func (iov *Iovec) SetLen(length int) {
   248		iov.Len = uint32(length)
   249	}
   250	
   251	func (msghdr *Msghdr) SetControllen(length int) {
   252		msghdr.Controllen = uint32(length)
   253	}
   254	
   255	func (cmsg *Cmsghdr) SetLen(length int) {
   256		cmsg.Len = uint32(length)
   257	}
   258	
   259	
   260	
   261	func Poll(fds []PollFd, timeout int) (n int, err error) {
   262		if len(fds) == 0 {
   263			return poll(nil, 0, timeout)
   264		}
   265		return poll(&fds[0], len(fds), timeout)
   266	}
   267	
   268	
   269	
   270	func SyncFileRange(fd int, off int64, n int64, flags int) error {
   271		
   272		
   273		return armSyncFileRange(fd, flags, off, n)
   274	}
   275	
View as plain text