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

Delta Between Two Patch Sets: src/pkg/runtime/print.go

Issue 160200044: [dev.power64] code review 160200044: build: merge default into dev.power64 (Closed)
Left Patch Set: diff -r be0c14f62257b42485019e9e1db23cf40d2e249f https://code.google.com/p/go Created 10 years, 4 months ago
Right Patch Set: diff -r be0c14f62257b42485019e9e1db23cf40d2e249f 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/pkg/runtime/print.c ('k') | src/pkg/runtime/print1.go » ('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.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package runtime
6
7 import (
8 "unsafe"
9 )
10
11 // these 4 functions are complicated enough that we will share
12 // the print logic with the C printf.
13 var printstring_m byte
14 var printuint_m byte
15 var printhex_m byte
16 var printfloat_m byte
17
18 func printstring(s string) {
19 mp := acquirem()
20 mp.scalararg[0] = uint(len(s))
21 mp.ptrarg[0] = (*stringStruct)(unsafe.Pointer(&s)).str
22 onM(&printstring_m)
23 releasem(mp)
24 }
25
26 func printuint(x uint64) {
27 mp := acquirem()
28 *(*uint64)(unsafe.Pointer(&mp.scalararg[0])) = x
29 onM(&printuint_m)
30 releasem(mp)
31 }
32
33 func printhex(x uintptr) {
34 mp := acquirem()
35 mp.scalararg[0] = uint(x)
36 onM(&printhex_m)
37 releasem(mp)
38 }
39
40 func printfloat(x float64) {
41 mp := acquirem()
42 *(*float64)(unsafe.Pointer(&mp.scalararg[0])) = x
43 onM(&printfloat_m)
44 releasem(mp)
45 }
46
47 // all other print functions are expressible as combinations
48 // of the above 4 functions.
49 func printnl() {
50 printstring("\n")
51 }
52
53 func printsp() {
54 printstring(" ")
55 }
56
57 func printbool(b bool) {
58 if b {
59 printstring("true")
60 } else {
61 printstring("false")
62 }
63 }
64
65 func printpointer(p unsafe.Pointer) {
66 printhex(uintptr(p))
67 }
68
69 func printint(x int64) {
70 if x < 0 {
71 printstring("-")
72 x = -x
73 }
74 printuint(uint64(x))
75 }
76
77 func printcomplex(x complex128) {
78 printstring("(")
79 printfloat(real(x))
80 printfloat(imag(x))
81 printstring("i)")
82 }
83
84 func printiface(i interface {
85 f()
86 }) {
87 printstring("(")
88 printhex((*[2]uintptr)(unsafe.Pointer(&i))[0])
89 printstring(",")
90 printhex((*[2]uintptr)(unsafe.Pointer(&i))[1])
91 printstring(")")
92 }
93
94 func printeface(e interface{}) {
95 printstring("(")
96 printhex((*[2]uintptr)(unsafe.Pointer(&e))[0])
97 printstring(",")
98 printhex((*[2]uintptr)(unsafe.Pointer(&e))[1])
99 printstring(")")
100 }
101
102 func printslice(b []byte) {
103 printstring("[")
104 printint(int64(len(b)))
105 printstring("/")
106 printint(int64(cap(b)))
107 printstring("]")
108 printhex((*[3]uintptr)(unsafe.Pointer(&b))[0])
109 }
LEFTRIGHT

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