github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/tools/checkescape/test2/test2.go (about)

     1  // Copyright 2019 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 test2 is a test package that imports test1.
    16  package test2
    17  
    18  import (
    19  	"github.com/SagerNet/gvisor/tools/checkescape/test1"
    20  )
    21  
    22  // +checkescape:all
    23  //go:nosplit
    24  func interfaceFunctionCrossPkg() {
    25  	var i test1.Interface
    26  	test1.InterfaceFunction(i)
    27  }
    28  
    29  // +checkesacape:all
    30  //go:nosplit
    31  func typeFunctionCrossPkg() {
    32  	var t test1.Type
    33  	test1.TypeFunction(&t)
    34  }
    35  
    36  // +mustescape:builtin
    37  //go:noinline
    38  func builtinMapCrossPkg(x int) map[string]bool {
    39  	return test1.BuiltinMap(x)
    40  }
    41  
    42  // +mustescape:builtin
    43  //go:noinline
    44  func builtinClosureCrossPkg(x int) func() {
    45  	return test1.BuiltinClosure(x)
    46  }
    47  
    48  // +mustescape:builtin
    49  //go:noinline
    50  func builtinMakeSliceCrossPkg(x int) []byte {
    51  	return test1.BuiltinMakeSlice(x)
    52  }
    53  
    54  // +mustescape:builtin
    55  //go:noinline
    56  func builtinAppendCrossPkg() []byte {
    57  	return test1.BuiltinAppend(nil)
    58  }
    59  
    60  // +mustescape:builtin
    61  //go:noinline
    62  func builtinChanCrossPkg() chan int {
    63  	return test1.BuiltinChan()
    64  }
    65  
    66  // +mustescape:heap
    67  //go:noinline
    68  func heapCrossPkg() *test1.Type {
    69  	return test1.Heap()
    70  }
    71  
    72  // +mustescape:interface
    73  //go:noinline
    74  func dispatchCrossPkg(i test1.Interface) {
    75  	test1.Dispatch(i)
    76  }
    77  
    78  // +mustescape:dynamic
    79  //go:noinline
    80  func dynamicCrossPkg(f func()) {
    81  	test1.Dynamic(f)
    82  }
    83  
    84  // +mustescape:stack
    85  //go:noinline
    86  //go:nosplit
    87  func splitCrosssPkt() {
    88  	test1.Split()
    89  }