Skip to content

Commit

Permalink
ch3.6.6: 修复函数返回值
Browse files Browse the repository at this point in the history
  • Loading branch information
chai2010 committed Dec 27, 2018
1 parent e4451a8 commit 16a588e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ch3-asm/ch3-06-func-again.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func NewTwiceFunClosure(x int) func() int {
func ptrToFunc(p unsafe.Pointer) func() int

func asmFunTwiceClosureAddr() uintptr
func asmFunTwiceClosureBody()
func asmFunTwiceClosureBody() int
```

其中`ptrToFunc`用于将指针转化为`func() int`类型的闭包函数,`asmFunTwiceClosureAddr`用于返回闭包函数机器指令的开始地址(类似全局函数的地址),`asmFunTwiceClosureBody`是闭包函数对应的全局函数的实现。
Expand Down
2 changes: 1 addition & 1 deletion examples/ch3.6/closure-02/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewTwiceFunClosure(x int) func() int {
func ptrToFunc(p unsafe.Pointer) func() int

func asmFunTwiceClosureAddr() uintptr
func asmFunTwiceClosureBody()
func asmFunTwiceClosureBody() int

func main() {
fnTwice := NewTwiceFunClosure(1)
Expand Down

0 comments on commit 16a588e

Please sign in to comment.