summaryrefslogtreecommitdiff
path: root/src/cmd/6c/swt.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-08-24 16:15:21 -0700
committerRuss Cox <rsc@golang.org>2009-08-24 16:15:21 -0700
commit848e9261c030e32aec6f3f8b13d6aa1a458f2f18 (patch)
treea65fa19b965ad5b4c2a0bacc21bb06f03a8bdd95 /src/cmd/6c/swt.c
parenta04e55452a8b999d380bdfb3ea72603d42fd076e (diff)
downloadgolang-848e9261c030e32aec6f3f8b13d6aa1a458f2f18.tar.gz
first attempt at real FFI support.
in a .6 file, an export line //ffi T localfib remotefib remote.so means the dynamic linker should initialize localfib, always a pointer, to the address of remotefib, either text (T) or data (D) after loading remote.so. the C compiler will generate an export section when given the pragmas #pragma package fib #pragma ffi T localfib remotefib remote.so needing #pragma package is a bit of a kludge and hopefully could go away later. this is just the 6 tool chain support. other architectures will happen once 6 settles down. code using this to do FFI is in a later CL. R=r DELTA=161 (141 added, 14 deleted, 6 changed) OCL=33783 CL=33795
Diffstat (limited to 'src/cmd/6c/swt.c')
-rw-r--r--src/cmd/6c/swt.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/cmd/6c/swt.c b/src/cmd/6c/swt.c
index b3f31b04d..9b2381ae9 100644
--- a/src/cmd/6c/swt.c
+++ b/src/cmd/6c/swt.c
@@ -232,6 +232,19 @@ outcode(void)
Binit(&b, f, OWRITE);
Bprint(&b, "%s\n", thestring);
+ if(nffi > 0) {
+ int i;
+
+ if(package == nil) {
+ yyerror("#pragma ffi without #pragma package");
+ package = "_ffi_";
+ }
+ Bprint(&b, "\n$$ // ffi\n", thestring);
+ Bprint(&b, "package %s\n", package);
+ for(i=0; i<nffi; i++)
+ Bprint(&b, "//ffi %c %s %s %s\n", ffi[i].type, ffi[i].local, ffi[i].remote, ffi[i].path);
+ Bprint(&b, "$$\n\n$$\n\n");
+ }
Bprint(&b, "!\n");
outhist(&b);