Home | History | Annotate | Download | only in runtime
      1 // Copyright 2014 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 package runtime
      6 
      7 import "unsafe"
      8 
      9 type libcFunc uintptr
     10 
     11 var asmsysvicall6 libcFunc
     12 
     13 //go:noescape
     14 func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer)
     15 
     16 //go:nosplit
     17 func sysvicall0(fn *libcFunc) uintptr {
     18 	libcall := &getg().m.libcall
     19 	libcall.fn = uintptr(unsafe.Pointer(fn))
     20 	libcall.n = 0
     21 	libcall.args = uintptr(unsafe.Pointer(fn)) // it's unused but must be non-nil, otherwise crashes
     22 	asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
     23 	return libcall.r1
     24 }
     25 
     26 //go:nosplit
     27 func sysvicall1(fn *libcFunc, a1 uintptr) uintptr {
     28 	libcall := &getg().m.libcall
     29 	libcall.fn = uintptr(unsafe.Pointer(fn))
     30 	libcall.n = 1
     31 	// TODO(rsc): Why is noescape necessary here and below?
     32 	libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
     33 	asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
     34 	return libcall.r1
     35 }
     36 
     37 //go:nosplit
     38 func sysvicall2(fn *libcFunc, a1, a2 uintptr) uintptr {
     39 	libcall := &getg().m.libcall
     40 	libcall.fn = uintptr(unsafe.Pointer(fn))
     41 	libcall.n = 2
     42 	libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
     43 	asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
     44 	return libcall.r1
     45 }
     46 
     47 //go:nosplit
     48 func sysvicall3(fn *libcFunc, a1, a2, a3 uintptr) uintptr {
     49 	libcall := &getg().m.libcall
     50 	libcall.fn = uintptr(unsafe.Pointer(fn))
     51 	libcall.n = 3
     52 	libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
     53 	asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
     54 	return libcall.r1
     55 }
     56 
     57 //go:nosplit
     58 func sysvicall4(fn *libcFunc, a1, a2, a3, a4 uintptr) uintptr {
     59 	libcall := &getg().m.libcall
     60 	libcall.fn = uintptr(unsafe.Pointer(fn))
     61 	libcall.n = 4
     62 	libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
     63 	asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
     64 	return libcall.r1
     65 }
     66 
     67 //go:nosplit
     68 func sysvicall5(fn *libcFunc, a1, a2, a3, a4, a5 uintptr) uintptr {
     69 	libcall := &getg().m.libcall
     70 	libcall.fn = uintptr(unsafe.Pointer(fn))
     71 	libcall.n = 5
     72 	libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
     73 	asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
     74 	return libcall.r1
     75 }
     76 
     77 //go:nosplit
     78 func sysvicall6(fn *libcFunc, a1, a2, a3, a4, a5, a6 uintptr) uintptr {
     79 	libcall := &getg().m.libcall
     80 	libcall.fn = uintptr(unsafe.Pointer(fn))
     81 	libcall.n = 6
     82 	libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
     83 	asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
     84 	return libcall.r1
     85 }
     86