Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
4a2d30e1
Commit
4a2d30e1
authored
Nov 17, 2011
by
Anthony Martin
Committed by
Russ Cox
Nov 17, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runtime: add nanotime for Plan 9
R=paulzhol, rsc, dave, rminnich CC=golang-dev
https://golang.org/cl/5327063
parent
f6279b46
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
19 deletions
+58
-19
src/pkg/runtime/plan9/386/signal.c
src/pkg/runtime/plan9/386/signal.c
+0
-6
src/pkg/runtime/plan9/386/sys.s
src/pkg/runtime/plan9/386/sys.s
+8
-10
src/pkg/runtime/plan9/os.h
src/pkg/runtime/plan9/os.h
+10
-3
src/pkg/runtime/plan9/thread.c
src/pkg/runtime/plan9/thread.c
+40
-0
No files found.
src/pkg/runtime/plan9/386/signal.c
View file @
4a2d30e1
...
...
@@ -4,12 +4,6 @@
#include "runtime.h"
int64
runtime
·
nanotime
(
void
)
{
// Won't compile.
}
String
runtime
·
signame
(
int32
)
{
...
...
src/pkg/runtime/plan9/386/sys.s
View file @
4a2d30e1
...
...
@@ -14,16 +14,14 @@ TEXT runtime·open(SB),7,$0
INT
$
64
RET
//
TODO
(
ality
):
remove
use
of
deprecated
system
calls
TEXT
runtime
·
read
(
SB
),7,$0
MOVL
$
15
,
AX
INT
$
64
TEXT
runtime
·
pread
(
SB
),7,$0
MOVL
$
50
,
AX
INT
$
64
RET
TEXT
runtime
·
write
(
SB
),7,$0
MOVL
$
20
,
AX
INT
$
64
TEXT
runtime
·
p
write
(
SB
),7,$0
MOVL
$
51
,
AX
INT
$
64
RET
TEXT
runtime
·
close
(
SB
),7,$0
...
...
@@ -90,9 +88,9 @@ TEXT runtime·rfork(SB),7,$0
MOVL
0
(
BX
),
BX
//
more
paranoia
; check that stack splitting code works
PUSH
AL
PUSH
L
SI
CALL
runtime
·
emptyfunc
(
SB
)
POP
AL
POP
L
SI
CALL
SI
//
fn
()
CALL
runtime
·
exit
(
SB
)
...
...
src/pkg/runtime/plan9/os.h
View file @
4a2d30e1
...
...
@@ -4,6 +4,8 @@
// Plan 9-specific system calls
int32
runtime
·
open
(
uint8
*
file
,
int32
mode
);
int32
runtime
·
pread
(
int32
fd
,
void
*
buf
,
int32
nbytes
,
int64
offset
);
int32
runtime
·
pwrite
(
int32
fd
,
void
*
buf
,
int32
nbytes
,
int64
offset
);
int32
runtime
·
read
(
int32
fd
,
void
*
buf
,
int32
nbytes
);
int32
runtime
·
close
(
int32
fd
);
void
runtime
·
exits
(
int8
*
msg
);
...
...
@@ -16,9 +18,14 @@ int32 runtime·plan9_semrelease(uint32 *addr, int32 count);
/* open */
enum
{
OREAD
=
0
,
OWRITE
=
1
,
ORDWR
=
2
OREAD
=
0
,
OWRITE
=
1
,
ORDWR
=
2
,
OEXEC
=
3
,
OTRUNC
=
16
,
OCEXEC
=
32
,
ORCLOSE
=
64
,
OEXCL
=
0x1000
};
/* rfork */
...
...
src/pkg/runtime/plan9/thread.c
View file @
4a2d30e1
...
...
@@ -69,6 +69,34 @@ runtime·usleep(uint32 µs)
runtime
·
sleep
(
ms
);
}
int64
runtime
·
nanotime
(
void
)
{
static
int32
fd
=
-
1
;
byte
b
[
8
];
uint32
hi
,
lo
;
// As long as all goroutines share the same file
// descriptor table we can get away with using
// just a static fd. Without a lock the file can
// be opened twice but that's okay.
//
// Using /dev/bintime gives us a latency on the
// order of ten microseconds between two calls.
//
// The naïve implementation (without the cached
// file descriptor) is roughly four times slower
// in 9vx on a 2.16 GHz Intel Core 2 Duo.
if
(
fd
<
0
&&
(
fd
=
runtime
·
open
((
byte
*
)
"/dev/bintime"
,
OREAD
|
OCEXEC
))
<
0
)
return
0
;
if
(
runtime
·
pread
(
fd
,
b
,
sizeof
b
,
0
)
!=
sizeof
b
)
return
0
;
hi
=
b
[
0
]
<<
24
|
b
[
1
]
<<
16
|
b
[
2
]
<<
8
|
b
[
3
];
lo
=
b
[
4
]
<<
24
|
b
[
5
]
<<
16
|
b
[
6
]
<<
8
|
b
[
7
];
return
(
int64
)
hi
<<
32
|
(
int64
)
lo
;
}
extern
Tos
*
_tos
;
void
runtime
·
exit
(
int32
)
...
...
@@ -183,3 +211,15 @@ void
runtime
·
sigpanic
(
void
)
{
}
int32
runtime
·
read
(
int32
fd
,
void
*
buf
,
int32
nbytes
)
{
return
runtime
·
pread
(
fd
,
buf
,
nbytes
,
-
1LL
);
}
int32
runtime
·
write
(
int32
fd
,
void
*
buf
,
int32
nbytes
)
{
return
runtime
·
pwrite
(
fd
,
buf
,
nbytes
,
-
1LL
);
}
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