summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/mkgodefs.sh
blob: b6e97213e0ccd09279728762efa5163d33b3ac95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
# Copyright 2011 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

set -e

cat <<EOF
// Go definitions for C variables and types.
// AUTOMATICALLY GENERATED BY THE FOLLOWING COMMAND. DO NOT EDIT.
// CC="$CC" CFLAGS="$CFLAGS" ./mkgodefs.sh $@

package runtime
import "unsafe"
var _ unsafe.Pointer

EOF

for i in "$@"; do
	$CC $CFLAGS -q $i
done | awk '
/^func/ { next }
/^const/ { next }
/^\/\/.*type/ { next }

/^(const|func|type|var) / {
	if(seen[$2]++) {
        	skip = /{[^}]*$/;
		next;
	}
}

skip {
	skip = !/^}/
	next;
}

{print}
'