Source File
print.go
Belonging Package
runtime
package runtime
import (
)
printBacklog [512]byte
printBacklogIndex int
)
for := 0; < len(); {
:= copy(printBacklog[printBacklogIndex:], [:])
+=
printBacklogIndex +=
printBacklogIndex %= len(printBacklog)
}
}
printunlock()
}
var debuglock mutex
func () {
:= getg().m
.locks++ // do not reschedule between printlock++ and lock(&debuglock).
.printlock++
if .printlock == 1 {
lock(&debuglock)
}
.locks-- // now we know debuglock is held and holding up mp.locks for us.
}
func () {
:= getg().m
.printlock--
if .printlock == 0 {
unlock(&debuglock)
}
}
func ( []byte) {
if len() == 0 {
return
}
recordForPanic()
if == nil || .writebuf == nil || .m.dying > 0 {
writeErr()
return
}
:= copy(.writebuf[len(.writebuf):cap(.writebuf)], )
.writebuf = .writebuf[:len(.writebuf)+]
}
func () {
printstring(" ")
}
func () {
printstring("\n")
}
func ( bool) {
if {
printstring("true")
} else {
printstring("false")
}
}
func ( float64) {
switch {
case != :
printstring("NaN")
return
case + == && > 0:
printstring("+Inf")
return
case + == && < 0:
printstring("-Inf")
return
}
const = 7 // digits printed
var [ + 7]byte
[0] = '+'
:= 0 // exp
if == 0 {
if 1/ < 0 {
[0] = '-'
}
} else {
if < 0 {
= -
[0] = '-'
}
for >= 10 {
++
/= 10
}
for < 1 {
--
*= 10
}
:= 5.0
for := 0; < ; ++ {
/= 10
}
+=
if >= 10 {
++
/= 10
}
}
for := 0; < ; ++ {
:= int()
[+2] = byte( + '0')
-= float64()
*= 10
}
[1] = [2]
[2] = '.'
[+2] = 'e'
[+3] = '+'
if < 0 {
= -
[+3] = '-'
}
[+4] = byte(/100) + '0'
[+5] = byte(/10)%10 + '0'
[+6] = byte(%10) + '0'
gwrite([:])
}
func ( complex128) {
print("(", real(), imag(), "i)")
}
func ( uint64) {
var [100]byte
:= len()
for --; > 0; -- {
[] = byte(%10 + '0')
if < 10 {
break
}
/= 10
}
gwrite([:])
}
func ( int64) {
if < 0 {
printstring("-")
= -
}
printuint(uint64())
}
func ( uint64) {
const = "0123456789abcdef"
var [100]byte
:= len()
for --; > 0; -- {
[] = [%16]
if < 16 {
break
}
/= 16
}
--
[] = 'x'
--
[] = '0'
gwrite([:])
}
func ( unsafe.Pointer) {
printhex(uint64(uintptr()))
}
func ( uintptr) {
printhex(uint64())
}
func ( string) {
gwrite(bytes())
}
func ( []byte) {
:= (*slice)(unsafe.Pointer(&))
print("[", len(), "/", cap(), "]")
printpointer(.array)
}
func ( eface) {
print("(", ._type, ",", .data, ")")
}
func ( iface) {
print("(", .tab, ",", .data, ")")
}
func (, uintptr, func(uintptr) byte) {
:= func( uintptr) {
var [2 * sys.PtrSize]byte
for := len() - 1; >= 0; -- {
if &0xF < 10 {
[] = byte(&0xF) + '0'
} else {
[] = byte(&0xF) - 10 + 'a'
}
>>= 4
}
gwrite([:])
}
printlock()
var [1]byte
[0] = ' '
for := uintptr(0); + < ; += sys.PtrSize {
if %16 == 0 {
if != 0 {
println()
}
( + )
print(": ")
}
if != nil {
[0] = ( + )
if [0] == 0 {
[0] = ' '
}
}
gwrite([:])
:= *(*uintptr)(unsafe.Pointer( + ))
()
print(" ")
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |