From 687ca8b7fc95d73ae35fcca03efe8d731876f43d Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 26 Sep 2008 14:11:26 -0700 Subject: move src/syscall to src/lib/syscall. enforce rule: all kernel data structures and constants go in syscall module. move things that should be in syscall out of net. make net a single package. R=r OCL=15985 CL=15994 --- src/syscall/Makefile | 54 ------- src/syscall/errstr_darwin.go | 242 ------------------------------ src/syscall/errstr_linux.go | 292 ------------------------------------- src/syscall/file_amd64_darwin.go | 149 ------------------- src/syscall/file_amd64_linux.go | 151 ------------------- src/syscall/syscall.go | 28 ---- src/syscall/syscall_amd64_darwin.s | 59 -------- src/syscall/syscall_amd64_linux.s | 71 --------- src/syscall/time_amd64_darwin.go | 19 --- src/syscall/time_amd64_linux.go | 19 --- 10 files changed, 1084 deletions(-) delete mode 100644 src/syscall/Makefile delete mode 100644 src/syscall/errstr_darwin.go delete mode 100644 src/syscall/errstr_linux.go delete mode 100644 src/syscall/file_amd64_darwin.go delete mode 100644 src/syscall/file_amd64_linux.go delete mode 100644 src/syscall/syscall.go delete mode 100644 src/syscall/syscall_amd64_darwin.s delete mode 100644 src/syscall/syscall_amd64_linux.s delete mode 100644 src/syscall/time_amd64_darwin.go delete mode 100644 src/syscall/time_amd64_linux.go (limited to 'src/syscall') diff --git a/src/syscall/Makefile b/src/syscall/Makefile deleted file mode 100644 index a34c96adf..000000000 --- a/src/syscall/Makefile +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright 2009 The Go Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -CFLAGS= -O=6 -CC=$(O)c -AS=$(O)a -GC=$(O)g - -PKG=$(GOROOT)/pkg/syscall.a - -O1=\ - syscall.$O \ - errstr_$(GOOS).$O \ - -O2=\ - file_$(GOARCH)_$(GOOS).$O \ - time_$(GOARCH)_$(GOOS).$O \ - syscall_$(GOARCH)_$(GOOS).$O \ - - -install: nuke $(PKG) - -$(PKG): a1 a2 - -a1: $(O1) - $(O)ar grc $(PKG) $(O1) - rm *.6 - -a2: $(O2) - $(O)ar grc $(PKG) $(O2) - rm *.6 - -$(O1): nuke -$(O2): a1 - -nuke: - rm -f *.$(O) *.a $(PKG) - -clean: - rm -f *.$(O) *.a - -%.$O: %.c - $(CC) $< - -sys_file.$O: sys_file.c sys_types.h $(OS_H) - $(CC) -D$(GOARCH)_$(GOOS) $< - -%.$O: %.s - $(AS) $< - -%.$O: %.go - $(GC) $< diff --git a/src/syscall/errstr_darwin.go b/src/syscall/errstr_darwin.go deleted file mode 100644 index 65c525501..000000000 --- a/src/syscall/errstr_darwin.go +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package syscall - -export const ( - ENONE=0; - EPERM=1; - ENOENT=2; - ESRCH=3; - EINTR=4; - EIO=5; - ENXIO=6; - E2BIG=7; - ENOEXEC=8; - EBADF=9; - ECHILD=10; - EDEADLK=11; - ENOMEM=12; - EACCES=13; - EFAULT=14; - ENOTBLK=15; - EBUSY=16; - EEXIST=17; - EXDEV=18; - ENODEV=19; - ENOTDIR=20; - EISDIR=21; - EINVAL=22; - ENFILE=23; - EMFILE=24; - ENOTTY=25; - ETXTBSY=26; - EFBIG=27; - ENOSPC=28; - ESPIPE=29; - EROFS=30; - EMLINK=31; - EPIPE=32; - EDOM=33; - ERANGE=34; - EAGAIN=35; - EINPROGRESS=36; - EALREADY=37; - ENOTSOCK=38; - EDESTADDRREQ=39; - EMSGSIZE=40; - EPROTOTYPE=41; - ENOPROTOOPT=42; - EPROTONOSUPPORT=43; - ESOCKTNOSUPPORT=44; - ENOTSUP=45; - EPFNOSUPPORT=46; - EAFNOSUPPORT=47; - EADDRINUSE=48; - EADDRNOTAVAIL=49; - ENETDOWN=50; - ENETUNREACH=51; - ENETRESET=52; - ECONNABORTED=53; - ECONNRESET=54; - ENOBUFS=55; - EISCONN=56; - ENOTCONN=57; - ESHUTDOWN=58; - ETOOMANYREFS=59; - ETIMEDOUT=60; - ECONNREFUSED=61; - ELOOP=62; - ENAMETOOLONG=63; - EHOSTDOWN=64; - EHOSTUNREACH=65; - ENOTEMPTY=66; - EPROCLIM=67; - EUSERS=68; - EDQUOT=69; - ESTALE=70; - EREMOTE=71; - EBADRPC=72; - ERPCMISMATCH=73; - EPROGUNAVAIL=74; - EPROGMISMATCH=75; - EPROCUNAVAIL=76; - ENOLCK=77; - ENOSYS=78; - EFTYPE=79; - EAUTH=80; - ENEEDAUTH=81; - EPWROFF=82; - EDEVERR=83; - EOVERFLOW=84; - EBADEXEC=85; - EBADARCH=86; - ESHLIBVERS=87; - EBADMACHO=88; - ECANCELED=89; - EIDRM=90; - ENOMSG=91; - EILSEQ=92; - ENOATTR=93; - EBADMSG=94; - EMULTIHOP=95; - ENODATA=96; - ENOLINK=97; - ENOSR=98; - ENOSTR=99; - EPROTO=100; - ETIME=101; - EOPNOTSUPP=102; - ELAST=103; -) - -var error [ELAST]string; - -func init(){ - error[ENONE] = "No error"; - error[EPERM] = "Operation not permitted"; - error[ENOENT] = "No such file or directory"; - error[ESRCH] = "No such process"; - error[EINTR] = "Interrupted system call"; - error[EIO] = "Input/output error"; - error[ENXIO] = "Device not configured"; - error[E2BIG] = "Argument list too long"; - error[ENOEXEC] = "Exec format error"; - error[EBADF] = "Bad file descriptor"; - error[ECHILD] = "No child processes"; - error[EDEADLK] = "Resource deadlock avoided"; - error[ENOMEM] = "Cannot allocate memory"; - error[EACCES] = "Permission denied"; - error[EFAULT] = "Bad address"; - error[ENOTBLK] = "Block device required"; - error[EBUSY] = "Device / Resource busy"; - error[EEXIST] = "File exists"; - error[EXDEV] = "Cross-device link"; - error[ENODEV] = "Operation not supported by device"; - error[ENOTDIR] = "Not a directory"; - error[EISDIR] = "Is a directory"; - error[EINVAL] = "Invalid argument"; - error[ENFILE] = "Too many open files in system"; - error[EMFILE] = "Too many open files"; - error[ENOTTY] = "Inappropriate ioctl for device"; - error[ETXTBSY] = "Text file busy"; - error[EFBIG] = "File too large"; - error[ENOSPC] = "No space left on device"; - error[ESPIPE] = "Illegal seek"; - error[EROFS] = "Read-only file system"; - error[EMLINK] = "Too many links"; - error[EPIPE] = "Broken pipe"; - error[EDOM] = "Numerical argument out of domain"; - error[ERANGE] = "Result too large"; - error[EAGAIN] = "Resource temporarily unavailable"; - error[EINPROGRESS] = "Operation now in progress"; - error[EALREADY] = "Operation already in progress"; - error[ENOTSOCK] = "Socket operation on non-socket"; - error[EDESTADDRREQ] = "Destination address required"; - error[EMSGSIZE] = "Message too long"; - error[EPROTOTYPE] = "Protocol wrong type for socket"; - error[ENOPROTOOPT] = "Protocol not available"; - error[EPROTONOSUPPORT] = "Protocol not supported"; - error[ESOCKTNOSUPPORT] = "Socket type not supported"; - error[ENOTSUP] = "Operation not supported"; - error[EPFNOSUPPORT] = "Protocol family not supported"; - error[EAFNOSUPPORT] = "Address family not supported by protocol family"; - error[EADDRINUSE] = "Address already in use"; - error[EADDRNOTAVAIL] = "Can't assign requested address"; - error[ENETDOWN] = "Network is down"; - error[ENETUNREACH] = "Network is unreachable"; - error[ENETRESET] = "Network dropped connection on reset"; - error[ECONNABORTED] = "Software caused connection abort"; - error[ECONNRESET] = "Connection reset by peer"; - error[ENOBUFS] = "No buffer space available"; - error[EISCONN] = "Socket is already connected"; - error[ENOTCONN] = "Socket is not connected"; - error[ESHUTDOWN] = "Can't send after socket shutdown"; - error[ETOOMANYREFS] = "Too many references: can't splice"; - error[ETIMEDOUT] = "Operation timed out"; - error[ECONNREFUSED] = "Connection refused"; - error[ELOOP] = "Too many levels of symbolic links"; - error[ENAMETOOLONG] = "File name too long"; - error[EHOSTDOWN] = "Host is down"; - error[EHOSTUNREACH] = "No route to host"; - error[ENOTEMPTY] = "Directory not empty"; - error[EPROCLIM] = "Too many processes"; - error[EUSERS] = "Too many users"; - error[EDQUOT] = "Disc quota exceeded"; - error[ESTALE] = "Stale NFS file handle"; - error[EREMOTE] = "Too many levels of remote in path"; - error[EBADRPC] = "RPC struct is bad"; - error[ERPCMISMATCH] = "RPC version wrong"; - error[EPROGUNAVAIL] = "RPC prog. not avail"; - error[EPROGMISMATCH] = "Program version wrong"; - error[EPROCUNAVAIL] = "Bad procedure for program"; - error[ENOLCK] = "No locks available"; - error[ENOSYS] = "Function not implemented"; - error[EFTYPE] = "Inappropriate file type or format"; - error[EAUTH] = "Authentication error"; - error[ENEEDAUTH] = "Need authenticator"; - error[EPWROFF] = "Device power is off"; - error[EDEVERR] = "Device error, e.g. paper out"; - error[EOVERFLOW] = "Value too large to be stored in data type"; - error[EBADEXEC] = "Bad executable"; - error[EBADARCH] = "Bad CPU type in executable"; - error[ESHLIBVERS] = "Shared library version mismatch"; - error[EBADMACHO] = "Malformed Macho file"; - error[ECANCELED] = "Operation canceled"; - error[EIDRM] = "Identifier removed"; - error[ENOMSG] = "No message of desired type"; - error[EILSEQ] = "Illegal byte sequence"; - error[ENOATTR] = "Attribute not found"; - error[EBADMSG] = "Bad message"; - error[EMULTIHOP] = "Reserved"; - error[ENODATA] = "No message available on STREAM"; - error[ENOLINK] = "Reserved"; - error[ENOSR] = "No STREAM resources"; - error[ENOSTR] = "Not a STREAM"; - error[EPROTO] = "Protocol error"; - error[ETIME] = "STREAM ioctl timeout"; - error[EOPNOTSUPP] = "Operation not supported on socket"; -} - -func str(val int64) string { // do it here rather than with fmt to avoid dependency - if val < 0 { - return "-" + str(-val); - } - var buf [32]byte; // big enough for int64 - i := len(buf)-1; - for val >= 10 { - buf[i] = byte(val%10 + '0'); - i--; - val /= 10; - } - buf[i] = byte(val + '0'); - return string(buf)[i:len(buf)]; -} - -export func errstr(errno int64) string { - if errno < 0 || errno >= len(error) { - return "Error " + str(errno) - } - return error[errno] -} diff --git a/src/syscall/errstr_linux.go b/src/syscall/errstr_linux.go deleted file mode 100644 index 20b46f28f..000000000 --- a/src/syscall/errstr_linux.go +++ /dev/null @@ -1,292 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package syscall - -export const ( - ENONE=0; - EPERM=1; - ENOENT=2; - ESRCH=3; - EINTR=4; - EIO=5; - ENXIO=6; - E2BIG=7; - ENOEXEC=8; - EBADF=9; - ECHILD=10; - EAGAIN=11; - ENOMEM=12; - EACCES=13; - EFAULT=14; - ENOTBLK=15; - EBUSY=16; - EEXIST=17; - EXDEV=18; - ENODEV=19; - ENOTDIR=20; - EISDIR=21; - EINVAL=22; - ENFILE=23; - EMFILE=24; - ENOTTY=25; - ETXTBSY=26; - EFBIG=27; - ENOSPC=28; - ESPIPE=29; - EROFS=30; - EMLINK=31; - EPIPE=32; - EDOM=33; - ERANGE=34; - EDEADLK=35; - ENAMETOOLONG=36; - ENOLCK=37; - ENOSYS=38; - ENOTEMPTY=39; - ELOOP=40; - ENOMSG=42; - EIDRM=43; - ECHRNG=44; - EL2NSYNC=45; - EL3HLT=46; - EL3RST=47; - ELNRNG=48; - EUNATCH=49; - ENOCSI=50; - EL2HLT=51; - EBADE=52; - EBADR=53; - EXFULL=54; - ENOANO=55; - EBADRQC=56; - EBADSLT=57; - EBFONT=59; - ENOSTR=60; - ENODATA=61; - ETIME=62; - ENOSR=63; - ENONET=64; - ENOPKG=65; - EREMOTE=66; - ENOLINK=67; - EADV=68; - ESRMNT=69; - ECOMM=70; - EPROTO=71; - EMULTIHOP=72; - EDOTDOT=73; - EBADMSG=74; - EOVERFLOW=75; - ENOTUNIQ=76; - EBADFD=77; - EREMCHG=78; - ELIBACC=79; - ELIBBAD=80; - ELIBSCN=81; - ELIBMAX=82; - ELIBEXEC=83; - EILSEQ=84; - ERESTART=85; - ESTRPIPE=86; - EUSERS=87; - ENOTSOCK=88; - EDESTADDRREQ=89; - EMSGSIZE=90; - EPROTOTYPE=91; - ENOPROTOOPT=92; - EPROTONOSUPPORT=93; - ESOCKTNOSUPPORT=94; - EOPNOTSUPP=95; - EPFNOSUPPORT=96; - EAFNOSUPPORT=97; - EADDRINUSE=98; - EADDRNOTAVAIL=99; - ENETDOWN=100; - ENETUNREACH=101; - ENETRESET=102; - ECONNABORTED=103; - ECONNRESET=104; - ENOBUFS=105; - EISCONN=106; - ENOTCONN=107; - ESHUTDOWN=108; - ETOOMANYREFS=109; - ETIMEDOUT=110; - ECONNREFUSED=111; - EHOSTDOWN=112; - EHOSTUNREACH=113; - EALREADY=114; - EINPROGRESS=115; - ESTALE=116; - EUCLEAN=117; - ENOTNAM=118; - ENAVAIL=119; - EISNAM=120; - EREMOTEIO=121; - EDQUOT=122; - ENOMEDIUM=123; - EMEDIUMTYPE=124; - ECANCELED=125; - ENOKEY=126; - EKEYEXPIRED=127; - EKEYREVOKED=128; - EKEYREJECTED=129; - ELAST=130; -) - -var error [ELAST]string; - -func init(){ - error[ENONE] = "No error"; - error[EPERM] = "Operation not permitted"; - error[ENOENT] = "No such file or directory"; - error[ESRCH] = "No such process"; - error[EINTR] = "Interrupted system call"; - error[EIO] = "I/O error"; - error[ENXIO] = "No such device or address"; - error[E2BIG] = "Argument list too long"; - error[ENOEXEC] = "Exec format error"; - error[EBADF] = "Bad file number"; - error[ECHILD] = "No child processes"; - error[EAGAIN] = "Try again"; - error[ENOMEM] = "Out of memory"; - error[EACCES] = "Permission denied"; - error[EFAULT] = "Bad address"; - error[ENOTBLK] = "Block device required"; - error[EBUSY] = "Device or resource busy"; - error[EEXIST] = "File exists"; - error[EXDEV] = "Cross-device link"; - error[ENODEV] = "No such device"; - error[ENOTDIR] = "Not a directory"; - error[EISDIR] = "Is a directory"; - error[EINVAL] = "Invalid argument"; - error[ENFILE] = "File table overflow"; - error[EMFILE] = "Too many open files"; - error[ENOTTY] = "Not a typewriter"; - error[ETXTBSY] = "Text file busy"; - error[EFBIG] = "File too large"; - error[ENOSPC] = "No space left on device"; - error[ESPIPE] = "Illegal seek"; - error[EROFS] = "Read-only file system"; - error[EMLINK] = "Too many links"; - error[EPIPE] = "Broken pipe"; - error[EDOM] = "Math argument out of domain of func"; - error[ERANGE] = "Math result not representable"; - error[EDEADLK] = "Resource deadlock would occur"; - error[ENAMETOOLONG] = "File name too long"; - error[ENOLCK] = "No record locks available"; - error[ENOSYS] = "Function not implemented"; - error[ENOTEMPTY] = "Directory not empty"; - error[ELOOP] = "Too many symbolic links encountered"; - error[ENOMSG] = "No message of desired type"; - error[EIDRM] = "Identifier removed"; - error[ECHRNG] = "Channel number out of range"; - error[EL2NSYNC] = "Level 2 not synchronized"; - error[EL3HLT] = "Level 3 halted"; - error[EL3RST] = "Level 3 reset"; - error[ELNRNG] = "Link number out of range"; - error[EUNATCH] = "Protocol driver not attached"; - error[ENOCSI] = "No CSI structure available"; - error[EL2HLT] = "Level 2 halted"; - error[EBADE] = "Invalid exchange"; - error[EBADR] = "Invalid request descriptor"; - error[EXFULL] = "Exchange full"; - error[ENOANO] = "No anode"; - error[EBADRQC] = "Invalid request code"; - error[EBADSLT] = "Invalid slot"; - error[EBFONT] = "Bad font file format"; - error[ENOSTR] = "Device not a stream"; - error[ENODATA] = "No data available"; - error[ETIME] = "Timer expired"; - error[ENOSR] = "Out of streams resources"; - error[ENONET] = "Machine is not on the network"; - error[ENOPKG] = "Package not installed"; - error[EREMOTE] = "Object is remote"; - error[ENOLINK] = "Link has been severed"; - error[EADV] = "Advertise error"; - error[ESRMNT] = "Srmount error"; - error[ECOMM] = "Communication error on send"; - error[EPROTO] = "Protocol error"; - error[EMULTIHOP] = "Multihop attempted"; - error[EDOTDOT] = "RFS specific error"; - error[EBADMSG] = "Not a data message"; - error[EOVERFLOW] = "Value too large for defined data type"; - error[ENOTUNIQ] = "Name not unique on network"; - error[EBADFD] = "File descriptor in bad state"; - error[EREMCHG] = "Remote address changed"; - error[ELIBACC] = "Can not access a needed shared library"; - error[ELIBBAD] = "Accessing a corrupted shared library"; - error[ELIBSCN] = ".lib section in a.out corrupted"; - error[ELIBMAX] = "Attempting to link in too many shared libraries"; - error[ELIBEXEC] = "Cannot exec a shared library directly"; - error[EILSEQ] = "Illegal byte sequence"; - error[ERESTART] = "Interrupted system call should be restarted"; - error[ESTRPIPE] = "Streams pipe error"; - error[EUSERS] = "Too many users"; - error[ENOTSOCK] = "Socket operation on non-socket"; - error[EDESTADDRREQ] = "Destination address required"; - error[EMSGSIZE] = "Message too long"; - error[EPROTOTYPE] = "Protocol wrong type for socket"; - error[ENOPROTOOPT] = "Protocol not available"; - error[EPROTONOSUPPORT] = "Protocol not supported"; - error[ESOCKTNOSUPPORT] = "Socket type not supported"; - error[EOPNOTSUPP] = "Operation not supported on transport endpoint"; - error[EPFNOSUPPORT] = "Protocol family not supported"; - error[EAFNOSUPPORT] = "Address family not supported by protocol"; - error[EADDRINUSE] = "Address already in use"; - error[EADDRNOTAVAIL] = "Cannot assign requested address"; - error[ENETDOWN] = "Network is down"; - error[ENETUNREACH] = "Network is unreachable"; - error[ENETRESET] = "Network dropped connection because of reset"; - error[ECONNABORTED] = "Software caused connection abort"; - error[ECONNRESET] = "Connection reset by peer"; - error[ENOBUFS] = "No buffer space available"; - error[EISCONN] = "Transport endpoint is already connected"; - error[ENOTCONN] = "Transport endpoint is not connected"; - error[ESHUTDOWN] = "Cannot send after transport endpoint shutdown"; - error[ETOOMANYREFS] = "Too many references: cannot splice"; - error[ETIMEDOUT] = "Connection timed out"; - error[ECONNREFUSED] = "Connection refused"; - error[EHOSTDOWN] = "Host is down"; - error[EHOSTUNREACH] = "No route to host"; - error[EALREADY] = "Operation already in progress"; - error[EINPROGRESS] = "Operation now in progress"; - error[ESTALE] = "Stale NFS file handle"; - error[EUCLEAN] = "Structure needs cleaning"; - error[ENOTNAM] = "Not a XENIX named type file"; - error[ENAVAIL] = "No XENIX semaphores available"; - error[EISNAM] = "Is a named type file"; - error[EREMOTEIO] = "Remote I/O error"; - error[EDQUOT] = "Quota exceeded"; - error[ENOMEDIUM] = "No medium found"; - error[EMEDIUMTYPE] = "Wrong medium type"; - error[ECANCELED] = "Operation Canceled"; - error[ENOKEY] = "Required key not available"; - error[EKEYEXPIRED] = "Key has expired"; - error[EKEYREVOKED] = "Key has been revoked"; - error[EKEYREJECTED] = "Key was rejected by service"; -} - -func str(val int64) string { // do it here rather than with fmt to avoid dependency - if val < 0 { - return "-" + str(-val); - } - var buf [32]byte; // big enough for int64 - i := len(buf)-1; - for val >= 10 { - buf[i] = byte(val%10 + '0'); - i--; - val /= 10; - } - buf[i] = byte(val + '0'); - return string(buf)[i:len(buf)]; -} - -export func errstr(errno int64) string { - if errno < 0 || errno >= len(error) { - return "Error " + str(errno) - } - return error[errno] -} diff --git a/src/syscall/file_amd64_darwin.go b/src/syscall/file_amd64_darwin.go deleted file mode 100644 index fcf6db0a7..000000000 --- a/src/syscall/file_amd64_darwin.go +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package syscall - -// File operations for Darwin - -import syscall "syscall" - -//export Stat -//export stat, fstat, lstat -//export open, creat, close, read, write, pipe -//export unlink - -func StatPtr(s *Stat) int64; - -type dev_t uint32; -type ino_t uint64; -type mode_t uint16; -type nlink_t uint16; -type uid_t uint32; -type gid_t uint32; -type off_t int64; -type blksize_t int64; -type blkcnt_t int64; -type time_t int64; - -type Timespec struct { - tv_sec time_t; - tv_nsec int64; -} - -export type Stat struct { - st_dev dev_t; /* ID of device containing file */ - st_mode mode_t; /* protection */ - st_nlink nlink_t; /* number of hard links */ - st_ino ino_t; /* inode number */ - st_uid uid_t; /* user ID of owner */ - st_gid gid_t; /* group ID of owner */ - st_rdev dev_t; /* device ID (if special file) */ - st_atime Timespec; /* time of last access */ - st_mtime Timespec; /* time of last modification */ - st_ctime Timespec; /* time of last status change */ - st_birthtimespec Timespec; /* birth time */ - st_size off_t; /* total size, in bytes */ - st_blocks blkcnt_t; /* number of blocks allocated */ - st_blksize blksize_t; /* blocksize for filesystem I/O */ - st_flags uint32; - st_gen uint32; - st_qspare[2] int64; -} - -export const ( - O_RDONLY = 0x0; - O_WRONLY = 0x1; - O_RDWR = 0x2; - O_APPEND = 0x8; - O_ASYNC = 0x40; - O_CREAT = 0x200; - O_NOCTTY = 0x20000; - O_NONBLOCK = 0x4; - O_NDELAY = O_NONBLOCK; - O_SYNC = 0x80; - O_TRUNC = 0x400; -) - -const NameBufsize = 512 - -export func open(name string, mode int64, perm int64) (ret int64, errno int64) { - var namebuf [NameBufsize]byte; - if !StringToBytes(&namebuf, name) { - return -1, syscall.ENAMETOOLONG - } - const SYSOPEN = 5; - r1, r2, err := syscall.Syscall(SYSOPEN, BytePtr(&namebuf[0]), mode, perm); - return r1, err; -} - -export func creat(name string, perm int64) (ret int64, errno int64) { - var namebuf [NameBufsize]byte; - if !StringToBytes(&namebuf, name) { - return -1, syscall.ENAMETOOLONG - } - const SYSOPEN = 5; - r1, r2, err := syscall.Syscall(SYSOPEN, BytePtr(&namebuf[0]), O_CREAT|O_WRONLY|O_TRUNC, perm); - return r1, err; -} - -export func close(fd int64) (ret int64, errno int64) { - const SYSCLOSE = 6; - r1, r2, err := syscall.Syscall(SYSCLOSE, fd, 0, 0); - return r1, err; -} - -export func read(fd int64, buf *byte, nbytes int64) (ret int64, errno int64) { - const SYSREAD = 3; - r1, r2, err := syscall.Syscall(SYSREAD, fd, BytePtr(buf), nbytes); - return r1, err; -} - -export func write(fd int64, buf *byte, nbytes int64) (ret int64, errno int64) { - const SYSWRITE = 4; - r1, r2, err := syscall.Syscall(SYSWRITE, fd, BytePtr(buf), nbytes); - return r1, err; -} - -export func pipe(fds *[2]int64) (ret int64, errno int64) { - const SYSPIPE = 42; - r1, r2, err := syscall.Syscall(SYSPIPE, 0, 0, 0); - if r1 < 0 { - return r1, err; - } - fds[0] = r1; - fds[1] = r2; - return 0, 0; -} - -export func stat(name string, buf *Stat) (ret int64, errno int64) { - var namebuf [NameBufsize]byte; - if !StringToBytes(&namebuf, name) { - return -1, syscall.ENAMETOOLONG - } - const SYSSTAT = 338; - r1, r2, err := syscall.Syscall(SYSSTAT, BytePtr(&namebuf[0]), StatPtr(buf), 0); - return r1, err; -} - -export func lstat(name *byte, buf *Stat) (ret int64, errno int64) { - const SYSLSTAT = 340; - r1, r2, err := syscall.Syscall(SYSLSTAT, BytePtr(name), StatPtr(buf), 0); - return r1, err; -} - -export func fstat(fd int64, buf *Stat) (ret int64, errno int64) { - const SYSFSTAT = 339; - r1, r2, err := syscall.Syscall(SYSFSTAT, fd, StatPtr(buf), 0); - return r1, err; -} - -export func unlink(name string) (ret int64, errno int64) { - var namebuf [NameBufsize]byte; - if !StringToBytes(&namebuf, name) { - return -1, syscall.ENAMETOOLONG - } - const SYSUNLINK = 10; - r1, r2, err := syscall.Syscall(SYSUNLINK, BytePtr(&namebuf[0]), 0, 0); - return r1, err; -} diff --git a/src/syscall/file_amd64_linux.go b/src/syscall/file_amd64_linux.go deleted file mode 100644 index 5b5d90359..000000000 --- a/src/syscall/file_amd64_linux.go +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package syscall - -// File operations for Linux - -import syscall "syscall" - -//export Stat -//export stat, fstat, lstat -//export open, creat, close, read, write, pipe -//export unlink - -func StatPtr(s *Stat) int64; -func Int32Ptr(s *int32) int64; - -type dev_t uint64; -type ino_t uint64; -type mode_t uint32; -type nlink_t uint64; -type uid_t uint32; -type gid_t uint32; -type off_t int64; -type blksize_t int64; -type blkcnt_t int64; -type time_t int64; - -type Timespec struct { - tv_sec time_t; - tv_nsec int64; -} - -export type Stat struct { - st_dev dev_t; /* ID of device containing file */ - st_ino ino_t; /* inode number */ - st_nlink nlink_t; /* number of hard links */ - st_mode mode_t; /* protection */ - st_uid uid_t; /* user ID of owner */ - st_gid gid_t; /* group ID of owner */ - pad0 int32; - st_rdev dev_t; /* device ID (if special file) */ - st_size off_t; /* total size, in bytes */ - st_blksize blksize_t; /* blocksize for filesystem I/O */ - st_blocks blkcnt_t; /* number of blocks allocated */ - st_atime Timespec; /* time of last access */ - st_mtime Timespec; /* time of last modification */ - st_ctime Timespec; /* time of last status change */ - st_unused4 int64; - st_unused5 int64; - st_unused6 int64; -} - -export const ( - O_RDONLY = 0x0; - O_WRONLY = 0x1; - O_RDWR = 0x2; - O_APPEND = 0x400; - O_ASYNC = 0x2000; - O_CREAT = 0x40; - O_NOCTTY = 0x100; - O_NONBLOCK = 0x800; - O_NDELAY = O_NONBLOCK; - O_SYNC = 0x1000; - O_TRUNC = 0x200; -) - -const NameBufsize = 512 - -export func open(name string, mode int64, perm int64) (ret int64, errno int64) { - var namebuf [NameBufsize]byte; - if !StringToBytes(&namebuf, name) { - return -1, syscall.ENAMETOOLONG - } - const SYSOPEN = 2; - r1, r2, err := syscall.Syscall(SYSOPEN, BytePtr(&namebuf[0]), mode, perm); - return r1, err; -} - -export func creat(name string, perm int64) (ret int64, errno int64) { - var namebuf [NameBufsize]byte; - if !StringToBytes(&namebuf, name) { - return -1, syscall.ENAMETOOLONG - } - const SYSOPEN = 2; - r1, r2, err := syscall.Syscall(SYSOPEN, BytePtr(&namebuf[0]), O_CREAT|O_WRONLY|O_TRUNC, perm); - return r1, err; -} - -export func close(fd int64) (ret int64, errno int64) { - const SYSCLOSE = 3; - r1, r2, err := syscall.Syscall(SYSCLOSE, fd, 0, 0); - return r1, err; -} - -export func read(fd int64, buf *byte, nbytes int64) (ret int64, errno int64) { - const SYSREAD = 0; - r1, r2, err := syscall.Syscall(SYSREAD, fd, BytePtr(buf), nbytes); - return r1, err; -} - -export func write(fd int64, buf *byte, nbytes int64) (ret int64, errno int64) { - const SYSWRITE = 1; - r1, r2, err := syscall.Syscall(SYSWRITE, fd, BytePtr(buf), nbytes); - return r1, err; -} - -export func pipe(fds *[2]int64) (ret int64, errno int64) { - const SYSPIPE = 22; - var t [2] int32; - r1, r2, err := syscall.Syscall(SYSPIPE, Int32Ptr(&t[0]), 0, 0); - if r1 < 0 { - return r1, err; - } - fds[0] = int64(t[0]); - fds[1] = int64(t[1]); - return 0, 0; -} - -export func stat(name string, buf *Stat) (ret int64, errno int64) { - var namebuf [NameBufsize]byte; - if !StringToBytes(&namebuf, name) { - return -1, syscall.ENAMETOOLONG - } - const SYSSTAT = 4; - r1, r2, err := syscall.Syscall(SYSSTAT, BytePtr(&namebuf[0]), StatPtr(buf), 0); - return r1, err; -} - -export func lstat(name *byte, buf *Stat) (ret int64, errno int64) { - const SYSLSTAT = 6; - r1, r2, err := syscall.Syscall(SYSLSTAT, BytePtr(name), StatPtr(buf), 0); - return r1, err; -} - -export func fstat(fd int64, buf *Stat) (ret int64, errno int64) { - const SYSFSTAT = 5; - r1, r2, err := syscall.Syscall(SYSFSTAT, fd, StatPtr(buf), 0); - return r1, err; -} - -export func unlink(name string) (ret int64, errno int64) { - var namebuf [NameBufsize]byte; - if !StringToBytes(&namebuf, name) { - return -1, syscall.ENAMETOOLONG - } - const SYSUNLINK = 87; - r1, r2, err := syscall.Syscall(SYSUNLINK, BytePtr(&namebuf[0]), 0, 0); - return r1, err; -} diff --git a/src/syscall/syscall.go b/src/syscall/syscall.go deleted file mode 100644 index 9ec14de27..000000000 --- a/src/syscall/syscall.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package syscall - -/* - * Foundation of system call interface. - */ - -export func Syscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64); -export func Syscall6(trap int64, a1, a2, a3, a4, a5, a6 int64) (r1, r2, err int64); -export func BytePtr(b *byte) int64; - -/* - * Used to convert file names to byte arrays for passing to kernel, - * but useful elsewhere too. - */ -export func StringToBytes(b *[]byte, s string) bool { - if len(s) >= len(b) { - return false - } - for i := 0; i < len(s); i++ { - b[i] = s[i] - } - b[len(s)] = '\000'; // not necessary - memory is zeroed - but be explicit - return true -} diff --git a/src/syscall/syscall_amd64_darwin.s b/src/syscall/syscall_amd64_darwin.s deleted file mode 100644 index 8677451d4..000000000 --- a/src/syscall/syscall_amd64_darwin.s +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// -// System call support for AMD64, Darwin -// - -// func Syscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64); -// func Syscall6(trap int64, a1, a2, a3, a4, a5, a6 int64) (r1, r2, err int64); -// Trap # in AX, args in DI SI DX, return in AX DX - -TEXT syscall·Syscall(SB),7,$-8 - MOVQ 16(SP), DI - MOVQ 24(SP), SI - MOVQ 32(SP), DX - MOVQ 8(SP), AX // syscall entry - ADDQ $0x2000000, AX - SYSCALL - JCC 5(PC) - MOVQ $-1, 40(SP) // r1 - MOVQ $0, 48(SP) // r2 - MOVQ AX, 56(SP) // errno - RET - MOVQ AX, 40(SP) // r1 - MOVQ DX, 48(SP) // r2 - MOVQ $0, 56(SP) // errno - RET - -TEXT syscall·Syscall6(SB),7,$-8 - MOVQ 16(SP), DI - MOVQ 24(SP), SI - MOVQ 32(SP), DX - MOVQ 40(SP), R10 - MOVQ 48(SP), R8 - MOVQ 56(SP), R9 - MOVQ 8(SP), AX // syscall entry - ADDQ $0x2000000, AX - SYSCALL - JCC 5(PC) - MOVQ $-1, 64(SP) // r1 - MOVQ $0, 72(SP) // r2 - MOVQ AX, 80(SP) // errno - RET - MOVQ AX, 64(SP) // r1 - MOVQ DX, 72(SP) // r2 - MOVQ $0, 80(SP) // errno - RET - -// conversion operators - really just casts -TEXT syscall·BytePtr(SB),7,$-8 - MOVQ 8(SP), AX - MOVQ AX, 16(SP) - RET - -TEXT syscall·StatPtr(SB),7,$-8 - MOVQ 8(SP), AX - MOVQ AX, 16(SP) - RET diff --git a/src/syscall/syscall_amd64_linux.s b/src/syscall/syscall_amd64_linux.s deleted file mode 100644 index 4fea6d55b..000000000 --- a/src/syscall/syscall_amd64_linux.s +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// -// System calls for AMD64, Linux -// - -// func Syscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64); -// Trap # in AX, args in DI SI DX R10 R8 R9, return in AX DX -// Note that this differs from "standard" ABI convention, which -// would pass 4th arg in CX, not R10. - -TEXT syscall·Syscall(SB),7,$-8 - MOVQ 16(SP), DI - MOVQ 24(SP), SI - MOVQ 32(SP), DX - MOVQ 8(SP), AX // syscall entry - SYSCALL - CMPQ AX, $0xfffffffffffff001 - JLS 6(PC) - MOVQ $-1, 40(SP) // r1 - MOVQ $0, 48(SP) // r2 - NEGQ AX - MOVQ AX, 56(SP) // errno - RET - MOVQ AX, 40(SP) // r1 - MOVQ DX, 48(SP) // r2 - MOVQ $0, 56(SP) // errno - RET - -TEXT syscall·Syscall6(SB),7,$-8 - MOVQ 16(SP), DI - MOVQ 24(SP), SI - MOVQ 32(SP), DX - MOVQ 40(SP), R10 - MOVQ 48(SP), R8 - MOVQ 56(SP), R9 - MOVQ 8(SP), AX // syscall entry - SYSCALL - JLS 6(PC) - MOVQ $-1, 64(SP) // r1 - MOVQ $0, 72(SP) // r2 - NEGQ AX - MOVQ AX, 80(SP) // errno - RET - MOVQ AX, 64(SP) // r1 - MOVQ DX, 72(SP) // r2 - MOVQ $0, 80(SP) // errno - RET - -// conversion operators - really just casts -TEXT syscall·BytePtr(SB),7,$-8 - MOVQ 8(SP), AX - MOVQ AX, 16(SP) - RET - -TEXT syscall·Int32Ptr(SB),7,$-8 - MOVQ 8(SP), AX - MOVQ AX, 16(SP) - RET - -TEXT syscall·Int64Ptr(SB),7,$-8 - MOVQ 8(SP), AX - MOVQ AX, 16(SP) - RET - -TEXT syscall·StatPtr(SB),7,$-8 - MOVQ 8(SP), AX - MOVQ AX, 16(SP) - RET diff --git a/src/syscall/time_amd64_darwin.go b/src/syscall/time_amd64_darwin.go deleted file mode 100644 index 4bcbe249f..000000000 --- a/src/syscall/time_amd64_darwin.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package syscall - -import syscall "syscall" - -export func gettimeofday() (sec, nsec, errno int64) { - const GETTIMEOFDAY = 116; - // The "1" in the call is the timeval pointer, which must be - // non-zero but is otherwise unused. The results - // are returned in r1, r2. - r1, r2, err := syscall.Syscall(GETTIMEOFDAY, 1, 0, 0); - if err != 0 { - return 0, 0, err - } - return r1, r2*1000, 0 -} diff --git a/src/syscall/time_amd64_linux.go b/src/syscall/time_amd64_linux.go deleted file mode 100644 index 71bd5658b..000000000 --- a/src/syscall/time_amd64_linux.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package syscall - -import syscall "syscall" - -func Int64Ptr(s *int64) int64; - -export func gettimeofday() (sec, nsec, errno int64) { - const GETTIMEOFDAY = 96 - var tv [2]int64; // struct timeval - r1, r2, err := syscall.Syscall(GETTIMEOFDAY, Int64Ptr(&tv[0]), 0, 0); - if err != 0 { - return 0, 0, err - } - return tv[0], tv[1]*1000, 0 -} -- cgit v1.2.1