aboutsummaryrefslogtreecommitdiff
path: root/src/unsafe
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2018-10-11 13:13:03 +1100
committerRob Pike <r@golang.org>2018-10-11 02:32:20 +0000
commitdaf6f254336844ad8cf538640d81f0193988b62a (patch)
treee24a9714f3557838c8062690fadebe323d1767ff /src/unsafe
parent27965c14364a9812794cd4933b539f04a9d7c6c9 (diff)
downloadgo-daf6f254336844ad8cf538640d81f0193988b62a.tar.gz
go-daf6f254336844ad8cf538640d81f0193988b62a.zip
unsafe: document that Alignof, Offsetof, and Sizeof return a constant
Nothing is changing but the documentation, which did not mention this property of these functions. Fixes #27587. Change-Id: I75bcee4a1dd9ec8cd82826c9a6e02ba7d599f719 Reviewed-on: https://go-review.googlesource.com/c/141377 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/unsafe')
-rw-r--r--src/unsafe/unsafe.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/unsafe/unsafe.go b/src/unsafe/unsafe.go
index 00961cffa3..e16c4aeacb 100644
--- a/src/unsafe/unsafe.go
+++ b/src/unsafe/unsafe.go
@@ -178,11 +178,13 @@ type Pointer *ArbitraryType
// The size does not include any memory possibly referenced by x.
// For instance, if x is a slice, Sizeof returns the size of the slice
// descriptor, not the size of the memory referenced by the slice.
+// The return value of Sizeof is a Go constant.
func Sizeof(x ArbitraryType) uintptr
// Offsetof returns the offset within the struct of the field represented by x,
// which must be of the form structValue.field. In other words, it returns the
// number of bytes between the start of the struct and the start of the field.
+// The return value of Offsetof is a Go constant.
func Offsetof(x ArbitraryType) uintptr
// Alignof takes an expression x of any type and returns the required alignment
@@ -193,4 +195,5 @@ func Offsetof(x ArbitraryType) uintptr
// within that struct, then Alignof(s.f) will return the required alignment
// of a field of that type within a struct. This case is the same as the
// value returned by reflect.TypeOf(s.f).FieldAlign().
+// The return value of Alignof is a Go constant.
func Alignof(x ArbitraryType) uintptr