1 // Copyright 2021 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.
10 struct HWND__{int unused;}; typedef struct HWND__ *HWND;
19 func test42018(t *testing.T) {
20 // Test that Windows handles are marked go:notinheap, by growing the
21 // stack and checking for pointer adjustments. Trick from
22 // test/fixedbugs/issue40954.go.
24 handle := C.HANDLE(unsafe.Pointer(uintptr(unsafe.Pointer(&i))))
25 recurseHANDLE(100, handle, uintptr(unsafe.Pointer(&i)))
26 hwnd := C.HWND(unsafe.Pointer(uintptr(unsafe.Pointer(&i))))
27 recurseHWND(400, hwnd, uintptr(unsafe.Pointer(&i)))
30 func recurseHANDLE(n int, p C.HANDLE, v uintptr) {
32 recurseHANDLE(n-1, p, v)
34 if uintptr(unsafe.Pointer(p)) != v {
35 panic("adjusted notinheap pointer")
39 func recurseHWND(n int, p C.HWND, v uintptr) {
41 recurseHWND(n-1, p, v)
43 if uintptr(unsafe.Pointer(p)) != v {
44 panic("adjusted notinheap pointer")