github.com/aykevl/tinygo@v0.5.0/src/syscall/syscall_libc.go (about)

     1  // +build darwin
     2  
     3  package syscall
     4  
     5  import (
     6  	"unsafe"
     7  )
     8  
     9  func Close(fd int) (err error) {
    10  	return ENOSYS // TODO
    11  }
    12  
    13  func Write(fd int, p []byte) (n int, err error) {
    14  	buf, count := splitSlice(p)
    15  	n = libc_write(int32(fd), buf, uint(count))
    16  	if n < 0 {
    17  		err = getErrno()
    18  	}
    19  	return
    20  }
    21  
    22  func Read(fd int, p []byte) (n int, err error) {
    23  	return 0, ENOSYS // TODO
    24  }
    25  
    26  func Seek(fd int, offset int64, whence int) (off int64, err error) {
    27  	return 0, ENOSYS // TODO
    28  }
    29  
    30  func Open(path string, mode int, perm uint32) (fd int, err error) {
    31  	return 0, ENOSYS // TODO
    32  }
    33  
    34  func Kill(pid int, sig Signal) (err error) {
    35  	return ENOSYS // TODO
    36  }
    37  
    38  func Getpid() (pid int) {
    39  	panic("unimplemented: getpid") // TODO
    40  }
    41  
    42  func Getenv(key string) (value string, found bool) {
    43  	return "", false // TODO
    44  }
    45  
    46  func splitSlice(p []byte) (buf *byte, len uintptr) {
    47  	slice := (*struct {
    48  		buf *byte
    49  		len uintptr
    50  		cap uintptr
    51  	})(unsafe.Pointer(&p))
    52  	return slice.buf, slice.len
    53  }
    54  
    55  // ssize_t write(int fd, const void *buf, size_t count)
    56  //go:export write
    57  func libc_write(fd int32, buf *byte, count uint) int