Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(377)

Delta Between Two Patch Sets: src/runtime/os_plan9.go

Issue 152570049: [dev.power64] code review 152570049: all: merge default into dev.power64 (Closed)
Left Patch Set: Created 10 years, 4 months ago
Right Patch Set: diff -r 36f7fc9495481ed67a159eea0eb2fac35b7c46a5 https://code.google.com/p/go Created 10 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/runtime/os_plan9.c ('k') | src/runtime/os_solaris.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2014 The Go Authors. All rights reserved. 1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package runtime 5 package runtime
6 6
7 import "unsafe" 7 import "unsafe"
8 8
9 func pread(fd int32, buf unsafe.Pointer, nbytes int32, offset int64) int32 9 func pread(fd int32, buf unsafe.Pointer, nbytes int32, offset int64) int32
10 func pwrite(fd int32, buf unsafe.Pointer, nbytes int32, offset int64) int32 10 func pwrite(fd int32, buf unsafe.Pointer, nbytes int32, offset int64) int32
11 func seek(fd int32, offset int64, whence int32) int64 11 func seek(fd int32, offset int64, whence int32) int64
12 func exits(msg *byte) 12 func exits(msg *byte)
13 func brk_(addr unsafe.Pointer) uintptr 13 func brk_(addr unsafe.Pointer) uintptr
14 func sleep(ms int32) int32 14 func sleep(ms int32) int32
15 func rfork(flags int32, stk, mm, gg, fn unsafe.Pointer) int32 15 func rfork(flags int32) int32
16 func plan9_semacquire(addr *uint32, block int32) int32 16 func plan9_semacquire(addr *uint32, block int32) int32
17 func plan9_tsemacquire(addr *uint32, ms int32) int32 17 func plan9_tsemacquire(addr *uint32, ms int32) int32
18 func plan9_semrelease(addr *uint32, count int32) int32 18 func plan9_semrelease(addr *uint32, count int32) int32
19 func notify(fn unsafe.Pointer) int32 19 func notify(fn unsafe.Pointer) int32
20 func noted(mode int32) int32 20 func noted(mode int32) int32
21 func nsec(*int64) int64 21 func nsec(*int64) int64
22 func sigtramp(ureg, msg unsafe.Pointer) 22 func sigtramp(ureg, msg unsafe.Pointer)
23 func setfpmasks() 23 func setfpmasks()
24 func tstart_plan9(newm *m)
24 func errstr() string 25 func errstr() string
25
26 // The size of the note handler frame varies among architectures,
27 // but 512 bytes should be enough for every implementation.
28 const stackSystem = 512
29 26
30 type _Plink uintptr 27 type _Plink uintptr
31 28
32 func os_sigpipe() { 29 func os_sigpipe() {
33 gothrow("too many writes on closed pipe") 30 gothrow("too many writes on closed pipe")
34 } 31 }
32
33 func sigpanic() {
34 g := getg()
35 if !canpanic(g) {
36 gothrow("unexpected signal during runtime execution")
37 }
38
39 note := gostringnocopy((*byte)(unsafe.Pointer(g.m.notesig)))
40 switch g.sig {
41 case _SIGRFAULT, _SIGWFAULT:
42 addr := note[index(note, "addr=")+5:]
43 g.sigcode1 = uintptr(atolwhex(addr))
44 if g.sigcode1 < 0x1000 || g.paniconfault {
45 panicmem()
46 }
47 print("unexpected fault address ", hex(g.sigcode1), "\n")
48 gothrow("fault")
49 case _SIGTRAP:
50 if g.paniconfault {
51 panicmem()
52 }
53 gothrow(note)
54 case _SIGINTDIV:
55 panicdivide()
56 case _SIGFLOAT:
57 panicfloat()
58 default:
59 panic(errorString(note))
60 }
61 }
62
63 func atolwhex(p string) int64 {
64 for hasprefix(p, " ") || hasprefix(p, "\t") {
65 p = p[1:]
66 }
67 neg := false
68 if hasprefix(p, "-") || hasprefix(p, "+") {
69 neg = p[0] == '-'
70 p = p[1:]
71 for hasprefix(p, " ") || hasprefix(p, "\t") {
72 p = p[1:]
73 }
74 }
75 var n int64
76 switch {
77 case hasprefix(p, "0x"), hasprefix(p, "0X"):
78 p = p[2:]
79 for ; len(p) > 0; p = p[1:] {
80 if '0' <= p[0] && p[0] <= '9' {
81 n = n*16 + int64(p[0]-'0')
82 } else if 'a' <= p[0] && p[0] <= 'f' {
83 n = n*16 + int64(p[0]-'a'+10)
84 } else if 'A' <= p[0] && p[0] <= 'F' {
85 n = n*16 + int64(p[0]-'A'+10)
86 } else {
87 break
88 }
89 }
90 case hasprefix(p, "0"):
91 for ; len(p) > 0 && '0' <= p[0] && p[0] <= '7'; p = p[1:] {
92 n = n*8 + int64(p[0]-'0')
93 }
94 default:
95 for ; len(p) > 0 && '0' <= p[0] && p[0] <= '9'; p = p[1:] {
96 n = n*10 + int64(p[0]-'0')
97 }
98 }
99 if neg {
100 n = -n
101 }
102 return n
103 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b