go cgo_test_main 源码

  • 2022-07-15
  • 浏览 (819)

golang cgo_test_main 代码

文件路径:/src/runtime/race/testdata/cgo_test_main.go

// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

/*
int sync;

void Notify(void)
{
	__sync_fetch_and_add(&sync, 1);
}

void Wait(void)
{
	while(__sync_fetch_and_add(&sync, 0) == 0) {}
}
*/
import "C"

func main() {
	data := 0
	go func() {
		data = 1
		C.Notify()
	}()
	C.Wait()
	_ = data
}

相关信息

go 源码目录

相关文章

go atomic_test 源码

go cgo_test 源码

go chan_test 源码

go comp_test 源码

go finalizer_test 源码

go io_test 源码

go issue12225_test 源码

go issue12664_test 源码

go issue13264_test 源码

go map_test 源码

0  赞