...

Text file src/runtime/testdata/testprogcgo/trace_windows.c

Documentation: runtime/testdata/testprogcgo

     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// The windows C definitions for trace.go. That file uses //export so
     6// it can't put function definitions in the "C" import comment.
     7
     8#define WIN32_LEAN_AND_MEAN
     9#include <windows.h>
    10#include <process.h>
    11#include "_cgo_export.h"
    12
    13extern void goCalledFromC(void);
    14extern void goCalledFromCThread(void);
    15
    16__stdcall
    17static unsigned int cCalledFromCThread(void *p) {
    18	goCalledFromCThread();
    19	return 0;
    20}
    21
    22void cCalledFromGo(void) {
    23	goCalledFromC();
    24
    25	uintptr_t thread;
    26	thread = _beginthreadex(NULL, 0, cCalledFromCThread, NULL, 0, NULL);
    27	WaitForSingleObject((HANDLE)thread, INFINITE);
    28	CloseHandle((HANDLE)thread);
    29}

View as plain text