errno.mx raw

   1  //go:build baremetal || moxie.wasm || wasm_unknown || nintendoswitch
   2  
   3  package syscall
   4  
   5  import "internal/itoa"
   6  
   7  // Most code here has been copied from the Go sources:
   8  //   https://github.com/golang/go/blob/go1.12/src/syscall/syscall_js.go
   9  // It has the following copyright note:
  10  //
  11  //     Copyright 2018 The Go Authors. All rights reserved.
  12  //     Use of this source code is governed by a BSD-style
  13  //     license that can be found in the LICENSE file.
  14  
  15  // An Errno is an unsigned number describing an error condition.
  16  // It implements the error interface. The zero Errno is by convention
  17  // a non-error, so code to convert from Errno to error should use:
  18  //
  19  //	err = nil
  20  //	if errno != 0 {
  21  //	        err = errno
  22  //	}
  23  type Errno uintptr
  24  
  25  func (e Errno) Error() string {
  26  	return "errno " + itoa.Itoa(int(e))
  27  }
  28  
  29  func (e Errno) Temporary() bool {
  30  	return e == EINTR || e == EMFILE || e.Timeout()
  31  }
  32  
  33  func (e Errno) Timeout() bool {
  34  	return e == EAGAIN || e == EWOULDBLOCK || e == ETIMEDOUT
  35  }
  36