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 windows
6 7 package poll
8 9 import "syscall"
10 11 // Do the interface allocations only once for common
12 // Errno values.
13 14 var (
15 errERROR_IO_PENDING error = syscall.Errno(syscall.ERROR_IO_PENDING)
16 )
17 18 // errnoErr returns common boxed Errno values, to prevent
19 // allocations at runtime.
20 func errnoErr(e syscall.Errno) error {
21 switch e {
22 case 0:
23 return nil
24 case syscall.ERROR_IO_PENDING:
25 return errERROR_IO_PENDING
26 }
27 // TODO: add more here, after collecting data on the common
28 // error values see on Windows. (perhaps when running
29 // all.bat?)
30 return e
31 }
32