github.com/primecitizens/pcz/std@v0.2.1/builtin/print/print_wasi.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  
     4  //go:build wasip1
     5  
     6  package stdprint
     7  
     8  import (
     9  	"github.com/primecitizens/pcz/std/core/mark"
    10  	"github.com/primecitizens/pcz/std/ffi/wasm/wasi"
    11  )
    12  
    13  func gwrite(b []byte) {
    14  	if len(b) == 0 {
    15  		return
    16  	}
    17  
    18  	var (
    19  		iovs = wasi.IOBuffer{
    20  			Ptr: wasi.Uintptr(mark.NoEscapeSliceDataPointer(b)),
    21  			Len: wasi.Size(len(b)),
    22  		}
    23  		n wasi.Size
    24  	)
    25  
    26  	wasi.Write(
    27  		wasi.Stderr,
    28  		mark.NoEscapePointer(&iovs),
    29  		1,
    30  		mark.NoEscapePointer(&n),
    31  	)
    32  }