khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 1 | // Copyright 2020 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | // Package unsafeheader contains header declarations for the Go runtime's |
| 6 | // slice and string implementations. |
| 7 | // |
| 8 | // This package allows x/sys to use types equivalent to |
| 9 | // reflect.SliceHeader and reflect.StringHeader without introducing |
| 10 | // a dependency on the (relatively heavy) "reflect" package. |
| 11 | package unsafeheader |
| 12 | |
| 13 | import ( |
| 14 | "unsafe" |
| 15 | ) |
| 16 | |
| 17 | // Slice is the runtime representation of a slice. |
| 18 | // It cannot be used safely or portably and its representation may change in a later release. |
| 19 | type Slice struct { |
| 20 | Data unsafe.Pointer |
| 21 | Len int |
| 22 | Cap int |
| 23 | } |
| 24 | |
| 25 | // String is the runtime representation of a string. |
| 26 | // It cannot be used safely or portably and its representation may change in a later release. |
| 27 | type String struct { |
| 28 | Data unsafe.Pointer |
| 29 | Len int |
| 30 | } |