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

Side by Side Diff: src/pkg/runtime/print.go

Issue 138740043: code review 138740043: cmd/cc, runtime: preserve C runtime type names in gener... (Closed)
Patch Set: diff -r 14ab6d0208b61ae3aa52a24c89905571e8973d4e https://code.google.com/p/go/ Created 10 years, 6 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:
View unified diff | Download patch
« no previous file with comments | « src/pkg/runtime/mprof.goc ('k') | src/pkg/runtime/proc.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 ( 7 import (
8 "unsafe" 8 "unsafe"
9 ) 9 )
10 10
11 // these 4 functions are complicated enough that we will share 11 // these 4 functions are complicated enough that we will share
12 // the print logic with the C printf. 12 // the print logic with the C printf.
13 var ( 13 var (
14 printstring_m, 14 printstring_m,
15 printuint_m, 15 printuint_m,
16 printhex_m, 16 printhex_m,
17 printfloat_m mFunction 17 printfloat_m mFunction
18 ) 18 )
19 19
20 func printstring(s string) { 20 func printstring(s string) {
21 mp := acquirem() 21 mp := acquirem()
22 » mp.scalararg[0] = uint(len(s)) 22 » mp.scalararg[0] = uintptr(len(s))
23 mp.ptrarg[0] = (*stringStruct)(unsafe.Pointer(&s)).str 23 mp.ptrarg[0] = (*stringStruct)(unsafe.Pointer(&s)).str
24 onM(&printstring_m) 24 onM(&printstring_m)
25 releasem(mp) 25 releasem(mp)
26 } 26 }
27 27
28 func printuint(x uint64) { 28 func printuint(x uint64) {
29 mp := acquirem() 29 mp := acquirem()
30 *(*uint64)(unsafe.Pointer(&mp.scalararg[0])) = x 30 *(*uint64)(unsafe.Pointer(&mp.scalararg[0])) = x
31 onM(&printuint_m) 31 onM(&printuint_m)
32 releasem(mp) 32 releasem(mp)
33 } 33 }
34 34
35 func printhex(x uintptr) { 35 func printhex(x uintptr) {
36 mp := acquirem() 36 mp := acquirem()
37 » mp.scalararg[0] = uint(x) 37 » mp.scalararg[0] = uintptr(x)
38 onM(&printhex_m) 38 onM(&printhex_m)
39 releasem(mp) 39 releasem(mp)
40 } 40 }
41 41
42 func printfloat(x float64) { 42 func printfloat(x float64) {
43 mp := acquirem() 43 mp := acquirem()
44 *(*float64)(unsafe.Pointer(&mp.scalararg[0])) = x 44 *(*float64)(unsafe.Pointer(&mp.scalararg[0])) = x
45 onM(&printfloat_m) 45 onM(&printfloat_m)
46 releasem(mp) 46 releasem(mp)
47 } 47 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 103
104 func printslice(b []byte) { 104 func printslice(b []byte) {
105 printstring("[") 105 printstring("[")
106 printint(int64(len(b))) 106 printint(int64(len(b)))
107 printstring("/") 107 printstring("/")
108 printint(int64(cap(b))) 108 printint(int64(cap(b)))
109 printstring("]") 109 printstring("]")
110 printhex((*[3]uintptr)(unsafe.Pointer(&b))[0]) 110 printhex((*[3]uintptr)(unsafe.Pointer(&b))[0])
111 } 111 }
OLDNEW
« no previous file with comments | « src/pkg/runtime/mprof.goc ('k') | src/pkg/runtime/proc.go » ('j') | no next file with comments »

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