Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.4.3参数和返回值的内存布局中 #517

Open
xujunhai opened this issue Jul 27, 2020 · 1 comment
Open

3.4.3参数和返回值的内存布局中 #517

xujunhai opened this issue Jul 27, 2020 · 1 comment
Assignees

Comments

@xujunhai
Copy link

type Foo_args struct {
a bool,
b int16,
c []byte
}

这个结构体应该包含全啦 参数和返回值啦~ 为什么下面还要定义一个
type Foo_returns struct{
c[]byte
}

下面的函数 Foo(FP *SomeFunc_args,FP_ret *SomeFunc_returns) 有几个问题
0.这里的 SomeFunc_args 和 SomeFunc_returns是指的上面定义的Foo_args和Foo_returns么?

  1. unsafe.Offset(FP)不能直接对FP用
    2.uintptr(FP) 需要用 uintptr(unsafe.Pointer(Fp)) 转一下吧
    3.我理解args(32字节)已经整个包含 参数和返回值吧, 下面的 framesize = sizeof(args)+sizeof(returns) 这不是增大啦么,这里framsize应该只caller的大小吧

然后第162页一句话
唯一的差异是每个函数的偏移量通过unsafe.Offsetof()函数自动生成
1.函数 = 参数 吧

@chai2010
Copy link
Owner

Foo_returns 是为了展示重新对齐的需求(类似数组的第二个元素),放前面则不完全一样

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants