summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/mkgodefs.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/mkgodefs.sh')
-rwxr-xr-xsrc/pkg/runtime/mkgodefs.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/pkg/runtime/mkgodefs.sh b/src/pkg/runtime/mkgodefs.sh
new file mode 100755
index 000000000..b6e97213e
--- /dev/null
+++ b/src/pkg/runtime/mkgodefs.sh
@@ -0,0 +1,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}
+'