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