github.com/euank/go@v0.0.0-20160829210321-495514729181/src/runtime/cgo/gcc_libinit_openbsd.c (about)

     1  // Copyright 2015 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  #include <stdio.h>
     6  #include <stdlib.h>
     7  #include "libcgo.h"
     8  
     9  // The context function, used when tracing back C calls into Go.
    10  static void (*cgo_context_function)(struct context_arg*);
    11  
    12  void
    13  x_cgo_sys_thread_create(void* (*func)(void*), void* arg) {
    14  	fprintf(stderr, "x_cgo_sys_thread_create not implemented");
    15  	abort();
    16  }
    17  
    18  uintptr_t
    19  _cgo_wait_runtime_init_done() {
    20  	void (*pfn)(struct context_arg*);
    21  
    22  	// TODO(spetrovic): implement this method.
    23  
    24  	pfn = _cgo_get_context_function();
    25  	if (pfn != nil) {
    26  		struct context_arg arg;
    27  
    28  		arg.Context = 0;
    29  		(*pfn)(&arg);
    30  		return arg.Context;
    31  	}
    32  	return 0;
    33  }
    34  
    35  void
    36  x_cgo_notify_runtime_init_done(void* dummy) {
    37  	// TODO(spetrovic): implement this method.
    38  }
    39  
    40  // Sets the context function to call to record the traceback context
    41  // when calling a Go function from C code. Called from runtime.SetCgoTraceback.
    42  void x_cgo_set_context_function(void (*context)(struct context_arg*)) {
    43  	// TODO(iant): Needs synchronization.
    44  	cgo_context_function = context;
    45  }
    46  
    47  // Gets the context function.
    48  void (*(_cgo_get_context_function(void)))(struct context_arg*) {
    49  	return cgo_context_function;
    50  }