Source file src/syscall/time_fake.go
Documentation: syscall
1 // Copyright 2019 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 //go:build faketime 6 // +build faketime 7 8 package syscall 9 10 import "unsafe" 11 12 const faketime = true 13 14 // When faketime is enabled, we redirect writes to FDs 1 and 2 through 15 // the runtime's write function, since that adds the framing that 16 // reports the emulated time. 17 18 //go:linkname runtimeWrite runtime.write 19 func runtimeWrite(fd uintptr, p unsafe.Pointer, n int32) int32 20 21 func faketimeWrite(fd int, p []byte) int { 22 var pp *byte 23 if len(p) > 0 { 24 pp = &p[0] 25 } 26 return int(runtimeWrite(uintptr(fd), unsafe.Pointer(pp), int32(len(p)))) 27 } 28