...
1// Copyright 2023 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 unix
6
7// The unix C definitions for trace.go. That file uses //export so
8// it can't put function definitions in the "C" import comment.
9
10#include <pthread.h>
11#include <assert.h>
12
13extern void goCalledFromC(void);
14extern void goCalledFromCThread(void);
15
16static void* cCalledFromCThread(void *p) {
17 goCalledFromCThread();
18 return NULL;
19}
20
21void cCalledFromGo(void) {
22 goCalledFromC();
23
24 pthread_t thread;
25 assert(pthread_create(&thread, NULL, cCalledFromCThread, NULL) == 0);
26 assert(pthread_join(thread, NULL) == 0);
27}
View as plain text