func Read(fd int, p []byte) (n int, err error) { n, err = read(fd, p) if race.Enabled { if n > 0 { race.WriteRange(unsafe.Pointer(&p[0]), n) } if err == nil { race.Acquire(unsafe.Pointer(&ioSync)) } } if msanenabled && n > 0 { msanWrite(unsafe.Pointer(&p[0]), n) } return }
func Read(fd Handle, p []byte) (n int, err error) { var done uint32 e := ReadFile(fd, p, &done, nil) if e != nil { if e == ERROR_BROKEN_PIPE { // NOTE(brainman): work around ERROR_BROKEN_PIPE is returned on reading EOF from stdin return 0, nil } return 0, e } if race.Enabled { if done > 0 { race.WriteRange(unsafe.Pointer(&p[0]), int(done)) } race.Acquire(unsafe.Pointer(&ioSync)) } if msanenabled && done > 0 { msanWrite(unsafe.Pointer(&p[0]), int(done)) } return int(done), nil }