github.com/moontrade/nogc@v0.1.7/alloc/rpmalloc/cgo_tinygo.go (about)

     1  //go:build tinygo
     2  // +build tinygo
     3  
     4  package rpmalloc
     5  
     6  import (
     7  	"github.com/moontrade/nogc/alloc/rpmalloc/tinygo"
     8  )
     9  
    10  //// ReadThreadStats get thread statistics
    11  //func ReadThreadStats(stats *ThreadStats) {
    12  //	rpmalloc.ReadThreadStats(stats)
    13  //}
    14  //
    15  //// ReadGlobalStats get global statistics
    16  ////go:nosplit
    17  ////go:noescape
    18  //func ReadGlobalStats(stats *GlobalStats) {
    19  //	rpmalloc.ReadGlobalStats(stats)
    20  //}
    21  
    22  // Malloc allocate a memory block of at least the given size
    23  //go:nosplit
    24  //go:noescape
    25  func Malloc(size uintptr) uintptr {
    26  	return rpmalloc.Malloc(size)
    27  }
    28  
    29  // MallocCap allocate a memory block of at least the given size
    30  //go:nosplit
    31  //go:noescape
    32  func MallocCap(size uintptr) (uintptr, uintptr) {
    33  	return rpmalloc.MallocCap(size)
    34  }
    35  
    36  // MallocZero allocate a memory block of at least the given size
    37  //go:nosplit
    38  //go:noescape
    39  func MallocZeroed(size uintptr) uintptr {
    40  	return rpmalloc.MallocZeroed(size)
    41  }
    42  
    43  // MallocZeroCap allocate a memory block of at least the given size
    44  //go:nosplit
    45  //go:noescape
    46  func MallocZeroedCap(size uintptr) (uintptr, uintptr) {
    47  	return rpmalloc.MallocZeroedCap(size)
    48  }
    49  
    50  // Calloc Allocates a memory block of at least the given size and zero initialize it
    51  //go:nosplit
    52  //go:noescape
    53  func Calloc(num, size uintptr) uintptr {
    54  	return rpmalloc.Calloc(num, size)
    55  }
    56  
    57  // CallocCap Allocates a memory block of at least the given size and zero initialize it
    58  //go:nosplit
    59  //go:noescape
    60  func CallocCap(num, size uintptr) (uintptr, uintptr) {
    61  	return rpmalloc.CallocCap(num, size)
    62  }
    63  
    64  // Realloc the given block to at least the given size
    65  //go:nosplit
    66  //go:noescape
    67  func Realloc(ptr, size uintptr) uintptr {
    68  	return rpmalloc.Realloc(ptr, size)
    69  }
    70  
    71  // ReallocCap the given block to at least the given size
    72  func ReallocCap(ptr, size uintptr) (uintptr, uintptr) {
    73  	return rpmalloc.ReallocCap(ptr, size)
    74  }
    75  
    76  // UsableSize Query the usable size of the given memory block (from given pointer to the end of block)
    77  func UsableSize(ptr uintptr) uintptr {
    78  	return rpmalloc.UsableSize(ptr)
    79  }
    80  
    81  // Free the given memory block
    82  func Free(ptr uintptr) {
    83  	rpmalloc.Free(ptr)
    84  }