diff options
author | Russ Cox <rsc@golang.org> | 2014-09-08 00:08:51 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-09-08 00:08:51 -0400 |
commit | c007ce824d9a4fccb148f9204e04c23ed2984b71 (patch) | |
tree | 7dcac257114ef5c446be5b7b68c27dea230b7c09 /src/unsafe | |
parent | 220a6de47eced55956eb8af8d643d4f5b67fd634 (diff) | |
download | go-c007ce824d9a4fccb148f9204e04c23ed2984b71.tar.gz go-c007ce824d9a4fccb148f9204e04c23ed2984b71.zip |
build: move package sources from src/pkg to src
Preparation was in CL 134570043.
This CL contains only the effect of 'hg mv src/pkg/* src'.
For more about the move, see golang.org/s/go14nopkg.
Diffstat (limited to 'src/unsafe')
-rw-r--r-- | src/unsafe/unsafe.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/unsafe/unsafe.go b/src/unsafe/unsafe.go new file mode 100644 index 0000000000..83b2e14052 --- /dev/null +++ b/src/unsafe/unsafe.go @@ -0,0 +1,37 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +/* + Package unsafe contains operations that step around the type safety of Go programs. +*/ +package unsafe + +// ArbitraryType is here for the purposes of documentation only and is not actually +// part of the unsafe package. It represents the type of an arbitrary Go expression. +type ArbitraryType int + +// Pointer represents a pointer to an arbitrary type. There are four special operations +// available for type Pointer that are not available for other types. +// 1) A pointer value of any type can be converted to a Pointer. +// 2) A Pointer can be converted to a pointer value of any type. +// 3) A uintptr can be converted to a Pointer. +// 4) A Pointer can be converted to a uintptr. +// Pointer therefore allows a program to defeat the type system and read and write +// arbitrary memory. It should be used with extreme care. +type Pointer *ArbitraryType + +// Sizeof returns the size in bytes occupied by the value v. The size is that of the +// "top level" of the value only. For instance, if v is a slice, it returns the size of +// the slice descriptor, not the size of the memory referenced by the slice. +func Sizeof(v ArbitraryType) uintptr + +// Offsetof returns the offset within the struct of the field represented by v, +// 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. +func Offsetof(v ArbitraryType) uintptr + +// Alignof returns the alignment of the value v. It is the maximum value m such +// that the address of a variable with the type of v will always be zero mod m. +// If v is of the form structValue.field, it returns the alignment of field f within struct object obj. +func Alignof(v ArbitraryType) uintptr |