...
Run Format

Source file src/syscall/syscall_linux_amd64.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	package syscall
     6	
     7	const (
     8		_SYS_dup       = SYS_DUP2
     9		_SYS_getdents  = SYS_GETDENTS64
    10		_SYS_setgroups = SYS_SETGROUPS
    11	)
    12	
    13	//sys	Dup2(oldfd int, newfd int) (err error)
    14	//sys	Fchown(fd int, uid int, gid int) (err error)
    15	//sys	Fstat(fd int, stat *Stat_t) (err error)
    16	//sys	Fstatfs(fd int, buf *Statfs_t) (err error)
    17	//sys	Ftruncate(fd int, length int64) (err error)
    18	//sysnb	Getegid() (egid int)
    19	//sysnb	Geteuid() (euid int)
    20	//sysnb	Getgid() (gid int)
    21	//sysnb	Getrlimit(resource int, rlim *Rlimit) (err error)
    22	//sysnb	Getuid() (uid int)
    23	//sysnb	InotifyInit() (fd int, err error)
    24	//sys	Ioperm(from int, num int, on int) (err error)
    25	//sys	Iopl(level int) (err error)
    26	//sys	Lchown(path string, uid int, gid int) (err error)
    27	//sys	Listen(s int, n int) (err error)
    28	//sys	Lstat(path string, stat *Stat_t) (err error)
    29	//sys	Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
    30	//sys	Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
    31	//sys	Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
    32	//sys	Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
    33	//sys	sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
    34	//sys	Setfsgid(gid int) (err error)
    35	//sys	Setfsuid(uid int) (err error)
    36	//sysnb	Setregid(rgid int, egid int) (err error)
    37	//sysnb	Setresgid(rgid int, egid int, sgid int) (err error)
    38	//sysnb	Setresuid(ruid int, euid int, suid int) (err error)
    39	//sysnb	Setrlimit(resource int, rlim *Rlimit) (err error)
    40	//sysnb	Setreuid(ruid int, euid int) (err error)
    41	//sys	Shutdown(fd int, how int) (err error)
    42	//sys	Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
    43	//sys	Stat(path string, stat *Stat_t) (err error)
    44	//sys	Statfs(path string, buf *Statfs_t) (err error)
    45	//sys	SyncFileRange(fd int, off int64, n int64, flags int) (err error)
    46	//sys	Truncate(path string, length int64) (err error)
    47	//sys	accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
    48	//sys	accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
    49	//sys	bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    50	//sys	connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    51	//sysnb	getgroups(n int, list *_Gid_t) (nn int, err error)
    52	//sysnb	setgroups(n int, list *_Gid_t) (err error)
    53	//sys	getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
    54	//sys	setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
    55	//sysnb	socket(domain int, typ int, proto int) (fd int, err error)
    56	//sysnb	socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
    57	//sysnb	getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    58	//sysnb	getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    59	//sys	recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
    60	//sys	sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
    61	//sys	recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
    62	//sys	sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
    63	//sys	mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
    64	
    65	//go:noescape
    66	func gettimeofday(tv *Timeval) (err Errno)
    67	
    68	func Gettimeofday(tv *Timeval) (err error) {
    69		errno := gettimeofday(tv)
    70		if errno != 0 {
    71			return errno
    72		}
    73		return nil
    74	}
    75	
    76	func Time(t *Time_t) (tt Time_t, err error) {
    77		var tv Timeval
    78		errno := gettimeofday(&tv)
    79		if errno != 0 {
    80			return 0, errno
    81		}
    82		if t != nil {
    83			*t = Time_t(tv.Sec)
    84		}
    85		return Time_t(tv.Sec), nil
    86	}
    87	
    88	func setTimespec(sec, nsec int64) Timespec {
    89		return Timespec{Sec: sec, Nsec: nsec}
    90	}
    91	
    92	func setTimeval(sec, usec int64) Timeval {
    93		return Timeval{Sec: sec, Usec: usec}
    94	}
    95	
    96	//sysnb	pipe(p *[2]_C_int) (err error)
    97	
    98	func Pipe(p []int) (err error) {
    99		if len(p) != 2 {
   100			return EINVAL
   101		}
   102		var pp [2]_C_int
   103		err = pipe(&pp)
   104		p[0] = int(pp[0])
   105		p[1] = int(pp[1])
   106		return
   107	}
   108	
   109	//sysnb pipe2(p *[2]_C_int, flags int) (err error)
   110	
   111	func Pipe2(p []int, flags int) (err error) {
   112		if len(p) != 2 {
   113			return EINVAL
   114		}
   115		var pp [2]_C_int
   116		err = pipe2(&pp, flags)
   117		p[0] = int(pp[0])
   118		p[1] = int(pp[1])
   119		return
   120	}
   121	
   122	func (r *PtraceRegs) PC() uint64 { return r.Rip }
   123	
   124	func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc }
   125	
   126	func (iov *Iovec) SetLen(length int) {
   127		iov.Len = uint64(length)
   128	}
   129	
   130	func (msghdr *Msghdr) SetControllen(length int) {
   131		msghdr.Controllen = uint64(length)
   132	}
   133	
   134	func (cmsg *Cmsghdr) SetLen(length int) {
   135		cmsg.Len = uint64(length)
   136	}
   137	

View as plain text