mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-28 04:46:44 -04:00
The regression test included in this change verifies that the type is, in fact, equivalent, while allowing the actual header definitions to avoid importing the (relatively heavy) "reflect" package itself. This change is loosely based on Keyan Pishdadian's draft in CL 230557. For golang/go#37805 Change-Id: I998c69cdeb852154cd66ab5fdaa542a6f19666a2 Reviewed-on: https://go-review.googlesource.com/c/sys/+/231177 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
31 lines
919 B
Go
31 lines
919 B
Go
// Copyright 2020 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 unsafeheader contains header declarations for the Go runtime's
|
|
// slice and struct implementations.
|
|
//
|
|
// This package allows x/sys to use types equivalent to
|
|
// reflect.SliceHeader and reflect.StructHeader without introducing
|
|
// a dependency on the (relatively heavy) "reflect" package.
|
|
package unsafeheader
|
|
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
// Slice is the runtime representation of a slice.
|
|
// It cannot be used safely or portably and its representation may change in a later release.
|
|
type Slice struct {
|
|
Data unsafe.Pointer
|
|
Len int
|
|
Cap int
|
|
}
|
|
|
|
// StringHeader is the runtime representation of a string.
|
|
// It cannot be used safely or portably and its representation may change in a later release.
|
|
type String struct {
|
|
Data unsafe.Pointer
|
|
Len int
|
|
}
|