github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/syscall/errno.go (about)

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