Fix "PR c++/92804 ICE trying to use concept as a nested-name-specifier"
[official-gcc.git] / libgo / go / syscall / syscall_errno.go
blob0d781decdb89c65aa09dbc714b6b730edd578959
1 // Copyright 2009 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.
5 package syscall
7 import "internal/oserror"
9 // An Errno is an unsigned number describing an error condition.
10 // It implements the error interface. The zero Errno is by convention
11 // a non-error, so code to convert from Errno to error should use:
12 // err = nil
13 // if errno != 0 {
14 // err = errno
15 // }
17 // Errno values can be tested against error values from the os package
18 // using errors.Is. For example:
20 // _, _, err := syscall.Syscall(...)
21 // if errors.Is(err, os.ErrNotExist) ...
22 type Errno uintptr
24 func (e Errno) Error() string {
25 return Errstr(int(e))
28 func (e Errno) Is(target error) bool {
29 switch target {
30 case oserror.ErrPermission:
31 return e == EACCES || e == EPERM
32 case oserror.ErrExist:
33 return e == EEXIST || e == ENOTEMPTY
34 case oserror.ErrNotExist:
35 return e == ENOENT
37 return false
40 func (e Errno) Temporary() bool {
41 return e == EINTR || e == EMFILE || e == ENFILE || e.Timeout()
44 func (e Errno) Timeout() bool {
45 return e == EAGAIN || e == EWOULDBLOCK || e == ETIMEDOUT