golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
121.61k stars 17.41k forks source link

unsafe: document if `syscall.Syscall` exemption to `unsafe.Pointer` rules also applies to other assembly functions #68301

Closed DemiMarie closed 2 weeks ago

DemiMarie commented 3 weeks ago

Go version

1.22.5 (this is from pkg.go.dev)

Output of go env in your module/workspace:

N/A (this is from viewing the docs online on pkg.go.dev)

What did you do?

Looked at the docs for unsafe.Pointer

What did you see happen?

Point 4 in the list of allowed uses for unsafe.Pointer states:

Conversion of a Pointer to a uintptr when calling syscall.Syscall.

but the subsequent explanation implies that any function written in assembly can be used, including syscall.Syscall as a special case.

What did you expect to see?

Consistent documentation

gabyhelp commented 3 weeks ago

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

ianlancetaylor commented 3 weeks ago

A typical function written in assembler should know which parameters are pointers and which are not. syscall.Syscall is a special case because we don't want to have to write every possible variant. Still, I tweaked it to "functions like syscall.Syscall" in https://go.dev/cl/596936. Thanks.

gopherbot commented 3 weeks ago

Change https://go.dev/cl/596936 mentions this issue: unsafe: say "functions like syscall.Syscall", not only Syscall