github.com/notti/go-dynamic@v0.0.0-20190619201224-fc443047424c/internal/fakecgo/libccall.go (about)

     1  package fakecgo
     2  
     3  import "unsafe"
     4  
     5  // wrapper functions to provide go func definitions with arguments
     6  
     7  func asmlibccall6(fn, n, args uintptr) uintptr
     8  
     9  //go:nosplit
    10  func libcCall0(fn *libcFunc) uintptr {
    11  	return asmlibccall6(uintptr(unsafe.Pointer(fn)), 0, 0)
    12  }
    13  
    14  //go:nosplit
    15  //go:noinline
    16  func libcCall1(fn *libcFunc, a1 uintptr) uintptr {
    17  	return asmlibccall6(uintptr(unsafe.Pointer(fn)), 1, uintptr(unsafe.Pointer(&a1)))
    18  }
    19  
    20  //go:nosplit
    21  //go:noinline
    22  func libcCall2(fn *libcFunc, a1 uintptr, a2 uintptr) uintptr {
    23  	return asmlibccall6(uintptr(unsafe.Pointer(fn)), 2, uintptr(unsafe.Pointer(&a1)))
    24  }
    25  
    26  //go:nosplit
    27  //go:noinline
    28  func libcCall3(fn *libcFunc, a1 uintptr, a2 uintptr, a3 uintptr) uintptr {
    29  	return asmlibccall6(uintptr(unsafe.Pointer(fn)), 3, uintptr(unsafe.Pointer(&a1)))
    30  }
    31  
    32  //go:nosplit
    33  //go:noinline
    34  func libcCall4(fn *libcFunc, a1 uintptr, a2 uintptr, a3 uintptr, a4 uintptr) uintptr {
    35  	return asmlibccall6(uintptr(unsafe.Pointer(fn)), 4, uintptr(unsafe.Pointer(&a1)))
    36  }
    37  
    38  //go:nosplit
    39  //go:noinline
    40  func libcCall5(fn *libcFunc, a1 uintptr, a2 uintptr, a3 uintptr, a4 uintptr, a5 uintptr) uintptr {
    41  	return asmlibccall6(uintptr(unsafe.Pointer(fn)), 5, uintptr(unsafe.Pointer(&a1)))
    42  }
    43  
    44  //go:nosplit
    45  //go:noinline
    46  func libcCall6(fn *libcFunc, a1 uintptr, a2 uintptr, a3 uintptr, a4 uintptr, a5 uintptr, a6 uintptr) uintptr {
    47  	return asmlibccall6(uintptr(unsafe.Pointer(fn)), 6, uintptr(unsafe.Pointer(&a1)))
    48  }