Debian Codegraph @

src/cmd/link/testdata/dynimportvar/main.go

raw
1 // Copyright 2023 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 // Test that we can access dynamically imported variables.
6 // We ues mach_task_self_ from darwin's system library.
7 // Check that loading the variable from C and Go gets the
8 // same result.
9
10 //go:build darwin
11
12 package main
13
14 /*
15 #include <mach/mach_init.h>
16
17 unsigned int Mach_task_self(void) {
18 return mach_task_self();
19 }
20 */
21 import "C"
22
23 import "cmd/link/testdata/dynimportvar/asm"
24
25 func main() {
26 c := uint32(C.Mach_task_self())
27 a := asm.Mach_task_self()
28 if a != c {
29 println("got", a, "want", c)
30 panic("FAIL")
31 }
32 }