百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

fastcgo

> 编程语言
开源

fastcgo 通过汇编跳板进行快速(但不安全)的 Cgo 调用。受 rustgo 的启发。UnsafeCall 函数接受一个指向 Cgo 函数的指针,并将其传递给 Cgo 执行。

197 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

fastcgo 通过汇编跳板进行快速(但不安全)的 Cgo 调用。受 rustgo 的启发。UnsafeCall 函数接受一个指向 Cgo 函数的指针,并将其传递给 Cgo 执行。

fastcgo

Fast (but unsafe) Cgo calls via an assembly trampoline. Inspired by rustgo. The UnsafeCall* function takes a pointer to a Cgo function and a number of arguments and executes the function on the "system stack" of the thread the current Goroutine is running on. Usage looks like:

package hello

// #include 
// #include 
// void hello(uint64_t arg) {
//   printf("Hello, C: %lld\n", arg)
// }
import "C"

import (
	"github.com/petermattis/fastcgo"
)

func Hello(arg uint64) {
	fastcgo.UnsafeCall4(C.hello, arg, 0, 0, 0)
}

The upshot is significantly faster transitions into C/C++:

~/go/src/github.com/petermattis/fastcgo master go test -run=- -bench=. ./bench/
...
BenchmarkGO-8        	2000000000	         1.90 ns/op
BenchmarkCGO-8       	30000000	        60.1  ns/op
BenchmarkFastCGO-8   	300000000	         4.63 ns/op
...

WARNING: No attempt is made to play nice with the Go scheduler or GC. The goroutine executing a fastcgo call will never be interrupted and will delay the starting or completion of GC until it finishes.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Go

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言