Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
eccea198
Commit
eccea198
authored
Jul 26, 2008
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add fstat, stat
R=ken OCL=13497 CL=13497
parent
20a02661
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
159 additions
and
100 deletions
+159
-100
Makefile
src/syscall/Makefile
+1
-0
stat_amd64_darwin.go
src/syscall/stat_amd64_darwin.go
+49
-0
stat_amd64_linux.go
src/syscall/stat_amd64_linux.go
+47
-0
syscall.go
src/syscall/syscall.go
+6
-2
syscall_amd64_darwin.s
src/syscall/syscall_amd64_darwin.s
+25
-45
syscall_amd64_linux.s
src/syscall/syscall_amd64_linux.s
+31
-53
No files found.
src/syscall/Makefile
View file @
eccea198
...
@@ -13,6 +13,7 @@ PKG=syscall.a
...
@@ -13,6 +13,7 @@ PKG=syscall.a
OFILES
=
\
OFILES
=
\
syscall.
$O
\
syscall.
$O
\
errstr_
$(GOOS)
.
$O
\
errstr_
$(GOOS)
.
$O
\
stat_
$(GOARCH)
_
$(GOOS)
.
$O
\
syscall_
$(GOARCH)
_
$(GOOS)
.
$O
\
syscall_
$(GOARCH)
_
$(GOOS)
.
$O
\
...
...
src/syscall/stat_amd64_darwin.go
0 → 100644
View file @
eccea198
// 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
func
stat
(
*
byte
,
*
Stat
)
(
ret
int64
,
errno
int64
);
func
fstat
(
int64
,
*
Stat
)
(
ret
int64
,
errno
int64
);
export
Stat
export
stat
,
fstat
// Stat and relatives for Linux
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
;
}
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
;
}
src/syscall/stat_amd64_linux.go
0 → 100644
View file @
eccea198
// 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
func
stat
(
*
byte
,
*
Stat
)
(
ret
int64
,
errno
int64
);
func
fstat
(
int64
,
*
Stat
)
(
ret
int64
,
errno
int64
);
export
Stat
export
stat
,
fstat
// Stat and relatives for Linux
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
;
}
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 */
}
src/syscall/syscall.go
View file @
eccea198
...
@@ -4,8 +4,12 @@
...
@@ -4,8 +4,12 @@
package
syscall
package
syscall
// for simplicity of addressing in assembler, all integers are 64 bits
/*
// in these calling sequences.
* These calls have signatures that are independent of operating system.
*
* For simplicity of addressing in assembler, all integers are 64 bits
* in these calling sequences.
*/
func
open
(
*
byte
,
int64
)
(
ret
int64
,
errno
int64
);
func
open
(
*
byte
,
int64
)
(
ret
int64
,
errno
int64
);
func
close
(
int64
)
(
ret
int64
,
errno
int64
);
func
close
(
int64
)
(
ret
int64
,
errno
int64
);
...
...
src/syscall/syscall_amd64_darwin.s
View file @
eccea198
...
@@ -6,13 +6,6 @@
...
@@ -6,13 +6,6 @@
// System calls for AMD64, Darwin
// System calls for AMD64, Darwin
//
//
//TEXT syscall·exit(SB),1,$-8
// MOVL 8(SP), DI // arg 1 exit status
// MOVL $(0x2000000+1), AX // syscall entry
// SYSCALL
// CALL notok(SB)
// RET
TEXT syscall·open(SB),1,$-8
TEXT syscall·open(SB),1,$-8
MOVQ 8(SP), DI
MOVQ 8(SP), DI
MOVQ 16(SP), SI
MOVQ 16(SP), SI
...
@@ -67,41 +60,28 @@ TEXT syscall·write(SB),1,$-8
...
@@ -67,41 +60,28 @@ TEXT syscall·write(SB),1,$-8
MOVQ $0, 40(SP)
MOVQ $0, 40(SP)
RET
RET
//TEXT fstat(SB),1,$-8
TEXT syscall·stat(SB),1,$-8
// MOVL 8(SP), DI
MOVQ 8(SP), DI
// MOVQ 16(SP), SI
MOVQ 16(SP), SI
// MOVL $(0x2000000+339), AX // syscall entry; really fstat64
MOVL $(0x2000000+338), AX // syscall entry
// SYSCALL
SYSCALL
// RET
JCC 4(PC)
//
MOVQ $-1, 24(SP)
//TEXT syscall·sigaction(SB),1,$-8
MOVQ AX, 32(SP)
// MOVL 8(SP), DI // arg 1 sig
RET
// MOVQ 16(SP), SI // arg 2 act
MOVQ AX, 24(SP)
// MOVQ 24(SP), DX // arg 3 oact
MOVQ $0, 32(SP)
// MOVQ 24(SP), CX // arg 3 oact
RET
// MOVQ 24(SP), R10 // arg 3 oact
// MOVL $(0x2000000+46), AX // syscall entry
TEXT syscall·fstat(SB),1,$-8
// SYSCALL
MOVQ 8(SP), DI
// JCC 2(PC)
MOVQ 16(SP), SI
// CALL notok(SB)
MOVL $(0x2000000+339), AX // syscall entry
// RET
SYSCALL
//
JCC 4(PC)
//TEXT sigtramp(SB),1,$24
MOVQ $-1, 24(SP)
// MOVL DX,0(SP)
MOVQ AX, 32(SP)
// MOVQ CX,8(SP)
RET
// MOVQ R8,16(SP)
MOVQ AX, 24(SP)
// CALL sighandler(SB)
MOVQ $0, 32(SP)
// RET
RET
//
//TEXT syscall·mmap(SB),1,$-8
// MOVQ 8(SP), DI // arg 1 addr
// MOVL 16(SP), SI // arg 2 len
// MOVL 20(SP), DX // arg 3 prot
// MOVL 24(SP), R10 // arg 4 flags
// MOVL 28(SP), R8 // arg 5 fid
// MOVL 32(SP), R9 // arg 6 offset
// MOVL $(0x2000000+197), AX // syscall entry
// SYSCALL
// JCC 2(PC)
// CALL notok(SB)
// RET
src/syscall/syscall_amd64_linux.s
View file @
eccea198
...
@@ -6,12 +6,6 @@
...
@@ -6,12 +6,6 @@
// System calls for AMD64, Linux
// System calls for AMD64, Linux
//
//
//TEXT sys·exit(SB),1,$0-8
// MOVL 8(SP), DI
// MOVL $60, AX
// SYSCALL
// RET
TEXT syscall·open(SB),1,$0-16
TEXT syscall·open(SB),1,$0-16
MOVQ 8(SP), DI
MOVQ 8(SP), DI
MOVQ 16(SP), SI
MOVQ 16(SP), SI
...
@@ -42,13 +36,6 @@ TEXT syscall·close(SB),1,$0-16
...
@@ -42,13 +36,6 @@ TEXT syscall·close(SB),1,$0-16
MOVQ $0, 24(SP)
MOVQ $0, 24(SP)
RET
RET
//TEXT fstat(SB),1,$0-16
// MOVL 8(SP), DI
// MOVQ 16(SP), SI
// MOVL $5, AX // syscall entry
// SYSCALL
// RET
TEXT syscall·read(SB),1,$0-16
TEXT syscall·read(SB),1,$0-16
MOVL 8(SP), DI
MOVL 8(SP), DI
MOVQ 16(SP), SI
MOVQ 16(SP), SI
...
@@ -81,43 +68,34 @@ TEXT syscall·write(SB),1,$0-16
...
@@ -81,43 +68,34 @@ TEXT syscall·write(SB),1,$0-16
MOVQ $0, 40(SP)
MOVQ $0, 40(SP)
RET
RET
//TEXT sys·rt_sigaction(SB),1,$0-32
TEXT syscall·stat(SB),1,$0-16
// MOVL 8(SP), DI
MOVQ 8(SP), DI
// MOVQ 16(SP), SI
MOVQ 16(SP), SI
// MOVQ 24(SP), DX
MOVQ $0, DX
// MOVQ 32(SP), CX
MOVQ $5, AX // syscall entry
// MOVL CX, R10
SYSCALL
// MOVL $13, AX // syscall entry
CMPQ AX, $0xfffffffffffff001
// SYSCALL
JLS 5(PC)
// RET
MOVQ $-1, 24(SP)
//
NEGQ AX
//TEXT sigtramp(SB),1,$24-16
MOVQ AX, 32(SP)
// MOVQ DI,0(SP)
RET
// MOVQ SI,8(SP)
MOVQ AX, 24(SP)
// MOVQ DX,16(SP)
MOVQ $0, 32(SP)
// CALL sighandler(SB)
RET
// RET
//
TEXT syscall·fstat(SB),1,$0-16
//TEXT sys·mmap(SB),1,$0-32
MOVL 8(SP), DI
// MOVQ 8(SP), DI
MOVQ 16(SP), SI
// MOVL 16(SP), SI
MOVQ $0, DX
// MOVL 20(SP), DX
MOVQ $5, AX // syscall entry
// MOVL 24(SP), CX
SYSCALL
// MOVL 28(SP), R8
CMPQ AX, $0xfffffffffffff001
// MOVL 32(SP), R9
JLS 5(PC)
//
MOVQ $-1, 24(SP)
///* flags arg for ANON is 1000 but sb 20 */
NEGQ AX
// MOVL CX, AX
MOVQ AX, 32(SP)
// ANDL $~0x1000, CX
RET
// ANDL $0x1000, AX
MOVQ AX, 24(SP)
// SHRL $7, AX
MOVQ $0, 32(SP)
// ORL AX, CX
RET
//
// MOVL CX, R10
// MOVL $9, AX // syscall entry
// SYSCALL
// CMPQ AX, $0xfffffffffffff001
// JLS 2(PC)
// CALL notok(SB)
// RET
//
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment