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