github.com/0xKiwi/rules_go@v0.24.3/tests/legacy/cgo_pthread_flag/cgo_pthread_flag.go (about)

     1  package cgo_pthread_flag
     2  
     3  /*
     4  #include <pthread.h>
     5  
     6  void* f(void* p) {
     7  	*(int*) p = 42;
     8  	return NULL;
     9  }
    10  
    11  int callFInBackground() {
    12  	int x;
    13  	pthread_t thread;
    14  	pthread_create(&thread, NULL, f, &x);
    15  	pthread_join(thread, NULL);
    16  	return x;
    17  }
    18  */
    19  import "C"
    20  
    21  // Wrapper for callFInBackground. We don't support using Cgo directly from
    22  // tests yet.
    23  func callFFromGo() int {
    24  	return int(C.callFInBackground())
    25  }