Source file src/runtime/cgo/callbacks_c.go

     1  // Copyright 2011 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  //go:build !goexperiment.runtimecgopurego || msan || tsan
     6  
     7  package cgo
     8  
     9  import "unsafe"
    10  
    11  // Calls a libc function to execute background work injected via libc
    12  // interceptors, such as processing pending signals under the thread
    13  // sanitizer.
    14  //
    15  // Left as a nil pointer if no libc interceptors are expected.
    16  
    17  //go:cgo_import_static _cgo_yield
    18  //go:linkname _cgo_yield _cgo_yield
    19  var _cgo_yield unsafe.Pointer
    20  
    21  // Indicates whether a dummy thread key has been created or not.
    22  //
    23  // When calling go exported function from C, we register a destructor
    24  // callback, for a dummy thread key, by using pthread_key_create.
    25  
    26  //go:cgo_import_static x_cgo_pthread_key_created
    27  //go:linkname x_cgo_pthread_key_created x_cgo_pthread_key_created
    28  //go:linkname _cgo_pthread_key_created _cgo_pthread_key_created
    29  var x_cgo_pthread_key_created byte
    30  var _cgo_pthread_key_created = &x_cgo_pthread_key_created
    31  
    32  // Export crosscall2 to a c function pointer variable.
    33  // Used to dropm in pthread key destructor, while C thread is exiting.
    34  
    35  //go:cgo_import_static x_crosscall2_ptr
    36  //go:linkname x_crosscall2_ptr x_crosscall2_ptr
    37  //go:linkname _crosscall2_ptr _crosscall2_ptr
    38  var x_crosscall2_ptr byte
    39  var _crosscall2_ptr = &x_crosscall2_ptr
    40  
    41  // Notifies that the runtime has been initialized.
    42  //
    43  // We currently block at every CGO entry point (via _cgo_wait_runtime_init_done)
    44  // to ensure that the runtime has been initialized before the CGO call is
    45  // executed. This is necessary for shared libraries where we kickoff runtime
    46  // initialization in a separate thread and return without waiting for this
    47  // thread to complete the init.
    48  
    49  //go:cgo_import_static x_cgo_notify_runtime_init_done
    50  //go:linkname x_cgo_notify_runtime_init_done x_cgo_notify_runtime_init_done
    51  //go:linkname _cgo_notify_runtime_init_done _cgo_notify_runtime_init_done
    52  var x_cgo_notify_runtime_init_done byte
    53  var _cgo_notify_runtime_init_done = &x_cgo_notify_runtime_init_done
    54  
    55  // Sets the traceback, context, and symbolizer functions. See
    56  // runtime.SetCgoTraceback.
    57  
    58  //go:cgo_import_static x_cgo_set_traceback_functions
    59  //go:linkname x_cgo_set_traceback_functions x_cgo_set_traceback_functions
    60  //go:linkname _cgo_set_traceback_functions _cgo_set_traceback_functions
    61  var x_cgo_set_traceback_functions byte
    62  var _cgo_set_traceback_functions = &x_cgo_set_traceback_functions
    63  
    64  // Call the traceback function registered with x_cgo_set_traceback_functions.
    65  
    66  //go:cgo_import_static x_cgo_call_traceback_function
    67  //go:linkname x_cgo_call_traceback_function x_cgo_call_traceback_function
    68  //go:linkname _cgo_call_traceback_function _cgo_call_traceback_function
    69  var x_cgo_call_traceback_function byte
    70  var _cgo_call_traceback_function = &x_cgo_call_traceback_function
    71  
    72  // Call the symbolizer function registered with x_cgo_set_symbolizer_functions.
    73  
    74  //go:cgo_import_static x_cgo_call_symbolizer_function
    75  //go:linkname x_cgo_call_symbolizer_function x_cgo_call_symbolizer_function
    76  //go:linkname _cgo_call_symbolizer_function _cgo_call_symbolizer_function
    77  var x_cgo_call_symbolizer_function byte
    78  var _cgo_call_symbolizer_function = &x_cgo_call_symbolizer_function
    79  

View as plain text