1 // Copyright 2024 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 structs
6 7 // HostLayout marks a struct as using host memory layout. A struct with a
8 // field of type HostLayout will be laid out in memory according to host
9 // expectations, generally following the host's C ABI.
10 //
11 // HostLayout does not affect layout within any other struct-typed fields
12 // of the containing struct, nor does it affect layout of structs
13 // containing the struct marked as host layout.
14 //
15 // By convention, HostLayout should be used as the type of a field
16 // named "_", placed at the beginning of the struct type definition.
17 type HostLayout struct {
18 _ hostLayout // prevent accidental conversion with plain struct{}
19 }
20 21 // We use an unexported type within the exported type to give the marker
22 // type itself, rather than merely its name, a recognizable identity in
23 // the type system. The main consequence of this is that a user can give
24 // the type a new name and it will still have the same properties, e.g.,
25 //
26 // type HL structs.HostLayout
27 //
28 // It also prevents unintentional conversion of struct{} to a named marker type.
29 type hostLayout struct {
30 }
31