You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: time_fake.go
    path of file: ./repos/gccrs/libgo/go/runtime
    
    the code of the file until where you have to start completion: // Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build faketime && !windows

// Faketime isn't currently supported on Windows. This would require
// modifying syscall.Write to call syscall.faketimeWrite,

    
func write(fd uintptr, p unsafe.Pointer, n int32) int32 {
	if !(fd == 1 || fd == 2) {
		// Do an ordinary write.
		return write1(fd, p, n)
	}

	// Write with the playback header.

	// First, lock to avoid interleaving writes.
	lock(&faketimeState.lock)

	// If the current fd doesn't match the fd of the previous write,
	// ensure that the timestamp is strictly greater. That way, we can
	// recover the original order even if we read the fds separately.
	t := faketimeState.lastfaketime
	if fd != faketimeState.lastfd {
		t++
		faketimeState.lastfd = fd
	}
	if faketime > t {
		t = faketime
	}
	faketimeState.lastfaketime = t

	// Playback header: 0 0 P B <8-byte time> <4-byte data length> (big endian)
	var buf [4 + 8 + 4]byte
	buf[2] = 'P'
	buf[3] = 'B'
	tu := uint64(t)
	buf[4] = byte(tu >> (7 * 8))
	buf[5] = byte(tu >> (6 * 8))
	buf[6] = byte(tu >> (5 * 8))
	buf[7] = byte(tu >> (4 * 8))
	buf[8] = byte(tu >> (3 * 8))
	buf[9] = byte(tu >> (2 * 8))
	buf[10] = byte(tu >> (1 * 8))
	buf[11] = byte(tu >> (0 * 8))
	nu := uint32(n)
	buf[12] = byte(nu >> (3 * 8))
	buf[13] = byte(nu >> (2 * 8))
	buf[14] = byte(nu >> (1 * 8))
	buf[15] = byte(nu >> (0 * 8))
	write1(fd, unsafe.Pointer(&buf[0]), int32(len(buf)))

	// Write actual data.
	res := write1(fd, p, n)

	unlock(&faketimeState.lock)
	return res
}