gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/tools/checklocks/test/alignment.go (about)

     1  // Copyright 2020 The gVisor Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package test
    16  
    17  type alignedStruct32 struct {
    18  	v int32
    19  }
    20  
    21  type alignedStruct64 struct {
    22  	v int64
    23  }
    24  
    25  type alignedStructGood struct {
    26  	v0 alignedStruct32
    27  	v1 alignedStruct32
    28  	v2 alignedStruct64
    29  }
    30  
    31  type alignedStructGoodArray0 struct {
    32  	v0 [3]alignedStruct32
    33  	v1 [3]alignedStruct32
    34  	v2 alignedStruct64
    35  }
    36  
    37  type alignedStructGoodArray1 [16]alignedStructGood
    38  
    39  type alignedStructBad struct {
    40  	v0 alignedStruct32
    41  	v1 alignedStruct64
    42  	v2 alignedStruct32
    43  }
    44  
    45  type alignedStructBadArray0 struct {
    46  	v0 [3]alignedStruct32
    47  	v1 [2]alignedStruct64
    48  	v2 [1]alignedStruct32
    49  }
    50  
    51  type alignedStructBadArray1 [16]alignedStructBad