From 848e9261c030e32aec6f3f8b13d6aa1a458f2f18 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 24 Aug 2009 16:15:21 -0700 Subject: 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 --- src/cmd/6c/swt.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/cmd/6c') 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