func Stat(path string, sta *Stat_t) (err error) {
	var statLE Stat_LE_t
	err = stat(path, &statLE)
	copyStat(sta, &statLE)
	return
}
sys	Mkdir(path string, mode uint32) (err error) = SYS___MKDIR_A
sys   Mkfifo(path string, mode uint32) (err error) = SYS___MKFIFO_A
sys	Mknod(path string, mode uint32, dev int) (err error) = SYS___MKNOD_A
sys	Pread(fd int, p []byte, offset int64) (n int, err error)
sys	Pwrite(fd int, p []byte, offset int64) (n int, err error)
sys	Readlink(path string, buf []byte) (n int, err error) = SYS___READLINK_A
sys	Rename(from string, to string) (err error) = SYS___RENAME_A
sys	Rmdir(path string) (err error) = SYS___RMDIR_A
sys   Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
sys	Setpriority(which int, who int, prio int) (err error)
sysnb	Setpgid(pid int, pgid int) (err error) = SYS_SETPGID
sysnb	Setrlimit(resource int, lim *Rlimit) (err error)
sysnb	Setregid(rgid int, egid int) (err error) = SYS_SETREGID
sysnb	Setreuid(ruid int, euid int) (err error) = SYS_SETREUID
sysnb	Setsid() (pid int, err error) = SYS_SETSID
sys	Setuid(uid int) (err error) = SYS_SETUID
sys	Setgid(uid int) (err error) = SYS_SETGID
sys	Shutdown(fd int, how int) (err error)
sys	stat(path string, statLE *Stat_LE_t) (err error) = SYS___STAT_A
package unix
import (
	"bytes"
	"runtime"
	"sort"
	"sync"
	"syscall"
	"unsafe"
)
const (
	O_CLOEXEC = 0        
	AF_LOCAL  = AF_UNIX  
)
func syscall_syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
func syscall_rawsyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
func syscall_syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
func syscall_rawsyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
func syscall_syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno)
func syscall_rawsyscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno)
func copyStat(stat *Stat_t, statLE *Stat_LE_t) {
	stat.Dev = uint64(statLE.Dev)
	stat.Ino = uint64(statLE.Ino)
	stat.Nlink = uint64(statLE.Nlink)
	stat.Mode = uint32(statLE.Mode)
	stat.Uid = uint32(statLE.Uid)
	stat.Gid = uint32(statLE.Gid)
	stat.Rdev = uint64(statLE.Rdev)
	stat.Size = statLE.Size
	stat.Atim.Sec = int64(statLE.Atim)
	stat.Atim.Nsec = 0  
	stat.Mtim.Sec = int64(statLE.Mtim)
	stat.Mtim.Nsec = 0  
	stat.Ctim.Sec = int64(statLE.Ctim)
	stat.Ctim.Nsec = 0  
	stat.Blksize = int64(statLE.Blksize)
	stat.Blocks = statLE.Blocks
}
func svcCall(fnptr unsafe.Pointer, argv *unsafe.Pointer, dsa *uint64)
func svcLoad(name *byte) unsafe.Pointer
func svcUnload(name *byte, fnptr unsafe.Pointer) int64
func (d *Dirent) NameString() string {
	if d == nil {
		return ""
	}
	return string(d.Name[:d.Namlen])
}
func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
	if sa.Port < 0 || sa.Port > 0xFFFF {
		return nil, 0, EINVAL
	}
	sa.raw.Len = SizeofSockaddrInet4
	sa.raw.Family = AF_INET
	p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
	p[0] = byte(sa.Port >> 8)
	p[1] = byte(sa.Port)
	for i := 0; i < len(sa.Addr); i++ {
		sa.raw.Addr[i] = sa.Addr[i]
	}
	return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
}
func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) {
	if sa.Port < 0 || sa.Port > 0xFFFF {
		return nil, 0, EINVAL
	}
	sa.raw.Len = SizeofSockaddrInet6
	sa.raw.Family = AF_INET6
	p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
	p[0] = byte(sa.Port >> 8)
	p[1] = byte(sa.Port)
	sa.raw.Scope_id = sa.ZoneId
	for i := 0; i < len(sa.Addr); i++ {
		sa.raw.Addr[i] = sa.Addr[i]
	}
	return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
}
func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
	name := sa.Name
	n := len(name)
	if n >= len(sa.raw.Path) || n == 0 {
		return nil, 0, EINVAL
	}
	sa.raw.Len = byte(3 + n)  
	sa.raw.Family = AF_UNIX
	for i := 0; i < n; i++ {
		sa.raw.Path[i] = int8(name[i])
	}
	return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
}
func anyToSockaddr(_ int, rsa *RawSockaddrAny) (Sockaddr, error) {
	switch rsa.Addr.Family {
	case AF_UNIX:
		pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
		sa := new(SockaddrUnix)
		if pp.Len != 0 && pp.Path[0] == 0 {
			pp.Path[0] = '@'
		}
		n := 0
		for n < int(pp.Len) && pp.Path[n] != 0 {
			n++
		}
		bytes := (*[len(pp.Path)]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
		sa.Name = string(bytes)
		return sa, nil
	case AF_INET:
		pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
		sa := new(SockaddrInet4)
		p := (*[2]byte)(unsafe.Pointer(&pp.Port))
		sa.Port = int(p[0])<<8 + int(p[1])
		for i := 0; i < len(sa.Addr); i++ {
			sa.Addr[i] = pp.Addr[i]
		}
		return sa, nil
	case AF_INET6:
		pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa))
		sa := new(SockaddrInet6)
		p := (*[2]byte)(unsafe.Pointer(&pp.Port))
		sa.Port = int(p[0])<<8 + int(p[1])
		sa.ZoneId = pp.Scope_id
		for i := 0; i < len(sa.Addr); i++ {
			sa.Addr[i] = pp.Addr[i]
		}
		return sa, nil
	}
	return nil, EAFNOSUPPORT
}
func Accept(fd int) (nfd int, sa Sockaddr, err error) {
	var rsa RawSockaddrAny
	var len _Socklen = SizeofSockaddrAny
	nfd, err = accept(fd, &rsa, &len)
	if err != nil {
		return
	}
	sa, err = anyToSockaddr(0, &rsa)
	if err != nil {
		Close(nfd)
		nfd = 0
	}
	return
}
func (iov *Iovec) SetLen(length int) {
	iov.Len = uint64(length)
}
func (msghdr *Msghdr) SetControllen(length int) {
	msghdr.Controllen = int32(length)
}
func (cmsg *Cmsghdr) SetLen(length int) {
	cmsg.Len = int32(length)
}
func Fstat(fd int, stat *Stat_t) (err error) {
	var statLE Stat_LE_t
	err = fstat(fd, &statLE)
	copyStat(stat, &statLE)
	return
}
func Ptsname(fd int) (name string, err error) {
	r0, _, e1 := syscall_syscall(SYS___PTSNAME_A, uintptr(fd), 0, 0)
	name = u2s(unsafe.Pointer(r0))
	if e1 != 0 {
		err = errnoErr(e1)
	}
	return
}
func u2s(cstr unsafe.Pointer) string {
	str := (*[1024]uint8)(cstr)
	i := 0
	for str[i] != 0 {
		i++
	}
	return string(str[:i])
}
func Close(fd int) (err error) {
	_, _, e1 := syscall_syscall(SYS_CLOSE, uintptr(fd), 0, 0)
	for i := 0; e1 == EAGAIN && i < 10; i++ {
		_, _, _ = syscall_syscall(SYS_USLEEP, uintptr(10), 0, 0)
		_, _, e1 = syscall_syscall(SYS_CLOSE, uintptr(fd), 0, 0)
	}
	if e1 != 0 {
		err = errnoErr(e1)
	}
	return
}
var mapper = &mmapper{
	active: make(map[*byte][]byte),
	mmap:   mmap,
	munmap: munmap,
}
func Madvise(b []byte, advice int) (err error) {
	return
}
func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
	return mapper.Mmap(fd, offset, length, prot, flags)
}
func Munmap(b []byte) (err error) {
	return mapper.Munmap(b)
}
func Getpgrp() (pid int) {
	pid, _ = Getpgid(0)
	return
}
func Getrusage(who int, rusage *Rusage) (err error) {
	var ruz rusage_zos
	err = getrusage(who, &ruz)
	rusage.Utime.Sec = ruz.Utime.Sec
	rusage.Utime.Usec = int64(ruz.Utime.Usec)
	rusage.Stime.Sec = ruz.Stime.Sec
	rusage.Stime.Usec = int64(ruz.Stime.Usec)
	return
}
func Lstat(path string, stat *Stat_t) (err error) {
	var statLE Stat_LE_t
	err = lstat(path, &statLE)
	copyStat(stat, &statLE)
	return
}