cgo

Imports

Imports #

_ "unsafe"
"C"
"internal/runtime/sys"
"sync"
"sync/atomic"
"unsafe"
_ "unsafe"
_ "unsafe"
_ "unsafe"
_ "unsafe"
_ "unsafe"
_ "unsafe"
_ "unsafe"
_ "unsafe"
_ "unsafe"
"unsafe"

Constants & Variables

___ps_strings var #

var ___ps_strings uintptr

_cgo_bindm var #

var _cgo_bindm = *ast.UnaryExpr

_cgo_callers var #

var _cgo_callers = *ast.UnaryExpr

_cgo_getstackbound var #

var _cgo_getstackbound = *ast.UnaryExpr

_cgo_init var #

var _cgo_init = *ast.UnaryExpr

_cgo_libc_setegid var #

go:cgo_import_static _cgo_libc_setegid go:linkname _cgo_libc_setegid _cgo_libc_setegid go:linkname cgo_libc_setegid syscall.cgo_libc_setegid

var _cgo_libc_setegid byte

_cgo_libc_seteuid var #

go:cgo_import_static _cgo_libc_seteuid go:linkname _cgo_libc_seteuid _cgo_libc_seteuid go:linkname cgo_libc_seteuid syscall.cgo_libc_seteuid

var _cgo_libc_seteuid byte

_cgo_libc_setgid var #

go:cgo_import_static _cgo_libc_setgid go:linkname _cgo_libc_setgid _cgo_libc_setgid go:linkname cgo_libc_setgid syscall.cgo_libc_setgid

var _cgo_libc_setgid byte

_cgo_libc_setgroups var #

go:cgo_import_static _cgo_libc_setgroups go:linkname _cgo_libc_setgroups _cgo_libc_setgroups go:linkname cgo_libc_setgroups syscall.cgo_libc_setgroups

var _cgo_libc_setgroups byte

_cgo_libc_setregid var #

go:cgo_import_static _cgo_libc_setregid go:linkname _cgo_libc_setregid _cgo_libc_setregid go:linkname cgo_libc_setregid syscall.cgo_libc_setregid

var _cgo_libc_setregid byte

_cgo_libc_setresgid var #

go:cgo_import_static _cgo_libc_setresgid go:linkname _cgo_libc_setresgid _cgo_libc_setresgid go:linkname cgo_libc_setresgid syscall.cgo_libc_setresgid

var _cgo_libc_setresgid byte

_cgo_libc_setresuid var #

go:cgo_import_static _cgo_libc_setresuid go:linkname _cgo_libc_setresuid _cgo_libc_setresuid go:linkname cgo_libc_setresuid syscall.cgo_libc_setresuid

var _cgo_libc_setresuid byte

_cgo_libc_setreuid var #

go:cgo_import_static _cgo_libc_setreuid go:linkname _cgo_libc_setreuid _cgo_libc_setreuid go:linkname cgo_libc_setreuid syscall.cgo_libc_setreuid

var _cgo_libc_setreuid byte

_cgo_libc_setuid var #

go:cgo_import_static _cgo_libc_setuid go:linkname _cgo_libc_setuid _cgo_libc_setuid go:linkname cgo_libc_setuid syscall.cgo_libc_setuid

var _cgo_libc_setuid byte

_cgo_mmap var #

var _cgo_mmap = *ast.UnaryExpr

_cgo_munmap var #

var _cgo_munmap = *ast.UnaryExpr

_cgo_notify_runtime_init_done var #

var _cgo_notify_runtime_init_done = *ast.UnaryExpr

_cgo_pthread_key_created var #

var _cgo_pthread_key_created = *ast.UnaryExpr

_cgo_set_context_function var #

var _cgo_set_context_function = *ast.UnaryExpr

_cgo_setenv var #

var _cgo_setenv = *ast.UnaryExpr

_cgo_sigaction var #

var _cgo_sigaction = *ast.UnaryExpr

_cgo_sys_thread_create var #

var _cgo_sys_thread_create = *ast.UnaryExpr

_cgo_thread_start var #

var _cgo_thread_start = *ast.UnaryExpr

_cgo_unsetenv var #

var _cgo_unsetenv = *ast.UnaryExpr

_cgo_yield var #

go:cgo_import_static _cgo_yield go:linkname _cgo_yield _cgo_yield

var _cgo_yield unsafe.Pointer

_crosscall2_ptr var #

var _crosscall2_ptr = *ast.UnaryExpr

_environ var #

var _environ uintptr

_environ var #

var _environ uintptr

_environ var #

var _environ uintptr

_guard_local var #

var _guard_local uintptr

_iscgo var #

go:linkname _iscgo runtime.iscgo

var _iscgo bool = true

_progname var #

var _progname uintptr

_progname var #

var _progname uintptr

_progname var #

var _progname uintptr

_set_crosscall2 var #

go:linkname _set_crosscall2 runtime.set_crosscall2

var _set_crosscall2 = set_crosscall2

cgo_libc_setegid var #

var cgo_libc_setegid = *ast.CallExpr

cgo_libc_seteuid var #

var cgo_libc_seteuid = *ast.CallExpr

cgo_libc_setgid var #

var cgo_libc_setgid = *ast.CallExpr

cgo_libc_setgroups var #

var cgo_libc_setgroups = *ast.CallExpr

cgo_libc_setregid var #

var cgo_libc_setregid = *ast.CallExpr

cgo_libc_setresgid var #

var cgo_libc_setresgid = *ast.CallExpr

cgo_libc_setresuid var #

var cgo_libc_setresuid = *ast.CallExpr

cgo_libc_setreuid var #

var cgo_libc_setreuid = *ast.CallExpr

cgo_libc_setuid var #

var cgo_libc_setuid = *ast.CallExpr

handleIdx var #

var handleIdx atomic.Uintptr

handles var #

var handles = sync.Map{...}

x_cgo_bindm var #

go:cgo_import_static x_cgo_bindm go:linkname x_cgo_bindm x_cgo_bindm go:linkname _cgo_bindm _cgo_bindm

var x_cgo_bindm byte

x_cgo_callers var #

go:cgo_import_static x_cgo_callers go:linkname x_cgo_callers x_cgo_callers go:linkname _cgo_callers _cgo_callers

var x_cgo_callers byte

x_cgo_getstackbound var #

go:cgo_import_static x_cgo_getstackbound go:linkname x_cgo_getstackbound x_cgo_getstackbound go:linkname _cgo_getstackbound _cgo_getstackbound

var x_cgo_getstackbound byte

x_cgo_init var #

go:cgo_import_static x_cgo_init go:linkname x_cgo_init x_cgo_init go:linkname _cgo_init _cgo_init

var x_cgo_init byte

x_cgo_mmap var #

go:cgo_import_static x_cgo_mmap go:linkname x_cgo_mmap x_cgo_mmap go:linkname _cgo_mmap _cgo_mmap

var x_cgo_mmap byte

x_cgo_munmap var #

go:cgo_import_static x_cgo_munmap go:linkname x_cgo_munmap x_cgo_munmap go:linkname _cgo_munmap _cgo_munmap

var x_cgo_munmap byte

x_cgo_notify_runtime_init_done var #

go:cgo_import_static x_cgo_notify_runtime_init_done go:linkname x_cgo_notify_runtime_init_done x_cgo_notify_runtime_init_done go:linkname _cgo_notify_runtime_init_done _cgo_notify_runtime_init_done

var x_cgo_notify_runtime_init_done byte

x_cgo_pthread_key_created var #

go:cgo_import_static x_cgo_pthread_key_created go:linkname x_cgo_pthread_key_created x_cgo_pthread_key_created go:linkname _cgo_pthread_key_created _cgo_pthread_key_created

var x_cgo_pthread_key_created byte

x_cgo_set_context_function var #

go:cgo_import_static x_cgo_set_context_function go:linkname x_cgo_set_context_function x_cgo_set_context_function go:linkname _cgo_set_context_function _cgo_set_context_function

var x_cgo_set_context_function byte

x_cgo_setenv var #

go:cgo_import_static x_cgo_setenv go:linkname x_cgo_setenv x_cgo_setenv go:linkname _cgo_setenv runtime._cgo_setenv

var x_cgo_setenv byte

x_cgo_sigaction var #

go:cgo_import_static x_cgo_sigaction go:linkname x_cgo_sigaction x_cgo_sigaction go:linkname _cgo_sigaction _cgo_sigaction

var x_cgo_sigaction byte

x_cgo_sys_thread_create var #

go:cgo_import_static x_cgo_sys_thread_create go:linkname x_cgo_sys_thread_create x_cgo_sys_thread_create go:linkname _cgo_sys_thread_create _cgo_sys_thread_create

var x_cgo_sys_thread_create byte

x_cgo_thread_start var #

go:cgo_import_static x_cgo_thread_start go:linkname x_cgo_thread_start x_cgo_thread_start go:linkname _cgo_thread_start _cgo_thread_start

var x_cgo_thread_start byte

x_cgo_unsetenv var #

go:cgo_import_static x_cgo_unsetenv go:linkname x_cgo_unsetenv x_cgo_unsetenv go:linkname _cgo_unsetenv runtime._cgo_unsetenv

var x_cgo_unsetenv byte

x_crosscall2_ptr var #

go:cgo_import_static x_crosscall2_ptr go:linkname x_crosscall2_ptr x_crosscall2_ptr go:linkname _crosscall2_ptr _crosscall2_ptr

var x_crosscall2_ptr byte

Type Aliases

Handle type #

Handle provides a way to pass values that contain Go pointers (pointers to memory allocated by Go) between Go and C without breaking the cgo pointer passing rules. A Handle is an integer value that can represent any Go value. A Handle can be passed through C and back to Go, and Go code can use the Handle to retrieve the original Go value. The underlying type of Handle is guaranteed to fit in an integer type that is large enough to hold the bit pattern of any pointer. The zero value of a Handle is not valid, and thus is safe to use as a sentinel in C APIs. For instance, on the Go side: package main /* #include // for uintptr_t extern void MyGoPrint(uintptr_t handle); void myprint(uintptr_t handle); import "C" import "runtime/cgo" //export MyGoPrint func MyGoPrint(handle C.uintptr_t) { h := cgo.Handle(handle) val := h.Value().(string) println(val) h.Delete() } func main() { val := "hello Go" C.myprint(C.uintptr_t(cgo.NewHandle(val))) // Output: hello Go } and on the C side: #include // for uintptr_t // A Go function extern void MyGoPrint(uintptr_t handle); // A C function void myprint(uintptr_t handle) { MyGoPrint(handle); } Some C functions accept a void* argument that points to an arbitrary data value supplied by the caller. It is not safe to coerce a [cgo.Handle] (an integer) to a Go [unsafe.Pointer], but instead we can pass the address of the cgo.Handle to the void* parameter, as in this variant of the previous example: package main /* extern void MyGoPrint(void *context); static inline void myprint(void *context) { MyGoPrint(context); } import "C" import ( "runtime/cgo" "unsafe" ) //export MyGoPrint func MyGoPrint(context unsafe.Pointer) { h := *(*cgo.Handle)(context) val := h.Value().(string) println(val) h.Delete() } func main() { val := "hello Go" h := cgo.NewHandle(val) C.myprint(unsafe.Pointer(&h)) // Output: hello Go }

type Handle uintptr

Structs

Incomplete struct #

Incomplete is used specifically for the semantics of incomplete C types.

type Incomplete struct {
_ sys.NotInHeap
}

Functions

Delete method #

Delete invalidates a handle. This method should only be called once the program no longer needs to pass the handle to C and the C code no longer has a copy of the handle value. The method panics if the handle is invalid.

func (h Handle) Delete()

NewHandle function #

NewHandle returns a handle for a given value. The handle is valid until the program calls Delete on it. The handle uses resources, and this package assumes that C code may hold on to the handle, so a program must explicitly call Delete when the handle is no longer needed. The intended use is to pass the returned handle to C code, which passes it back to Go, which calls Value.

func NewHandle(v any) Handle

Value method #

Value returns the associated Go value for a valid handle. The method panics if the handle is invalid.

func (h Handle) Value() any

_cgo_panic function #

go:linkname _cgo_panic _cgo_panic go:cgo_export_static _cgo_panic go:cgo_export_dynamic _cgo_panic

func _cgo_panic(a *struct{...})

_runtime_cgo_panic_internal function #

go:linkname _runtime_cgo_panic_internal runtime._cgo_panic_internal

func _runtime_cgo_panic_internal(p *byte)

set_crosscall2 function #

Set the x_crosscall2_ptr C function pointer variable point to crosscall2. It's for the runtime package to call at init time.

func set_crosscall2()

xx_cgo_panicmem function #

go:cgo_export_static xx_cgo_panicmem xx_cgo_panicmem

func xx_cgo_panicmem()

Generated with Arrow