Source file src/internal/syscall/unix/nonblocking_wasip1.go

     1  // Copyright 2023 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 wasip1
     6  
     7  package unix
     8  
     9  import (
    10  	"syscall"
    11  	_ "unsafe" // for go:linkname
    12  )
    13  
    14  func IsNonblock(fd int) (nonblocking bool, err error) {
    15  	flags, e1 := fd_fdstat_get_flags(fd)
    16  	if e1 != nil {
    17  		return false, e1
    18  	}
    19  	return flags&syscall.FDFLAG_NONBLOCK != 0, nil
    20  }
    21  
    22  func HasNonblockFlag(flag int) bool {
    23  	return flag&syscall.FDFLAG_NONBLOCK != 0
    24  }
    25  
    26  // This helper is implemented in the syscall package. It means we don't have
    27  // to redefine the fd_fdstat_get host import or the fdstat struct it
    28  // populates.
    29  //
    30  //go:linkname fd_fdstat_get_flags syscall.fd_fdstat_get_flags
    31  func fd_fdstat_get_flags(fd int) (uint32, error)
    32  

View as plain text