diff options
author | Russ Cox <rsc@golang.org> | 2009-08-24 17:30:00 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-08-24 17:30:00 -0700 |
commit | b5581bb7ceb7984d71d4a1fe845deb77cf8a697b (patch) | |
tree | d050621c48935fe92a55747351ede747cb1c210f /usr/rsc/fib/gcc.c | |
parent | 83b749573cef6ceeac24202b3bc14d2860828490 (diff) | |
download | golang-b5581bb7ceb7984d71d4a1fe845deb77cf8a697b.tar.gz |
start of FFI support, and a demo.
R=r
DELTA=494 (492 added, 0 deleted, 2 changed)
OCL=33784
CL=33810
Diffstat (limited to 'usr/rsc/fib/gcc.c')
-rw-r--r-- | usr/rsc/fib/gcc.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/usr/rsc/fib/gcc.c b/usr/rsc/fib/gcc.c new file mode 100644 index 000000000..a89839031 --- /dev/null +++ b/usr/rsc/fib/gcc.c @@ -0,0 +1,34 @@ +// Copyright 2009 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. + +#include <stdint.h> + +typedef int32_t int32; + +static int32 +fib1(int32 n) +{ + int32 a, b, t; + + a = 0; + b = 1; + for(; n>0; n--) { + t = a; + a = b; + b += t; + } + return a; +} + +void +fib(void *v) +{ + struct { // 6g func(n int) int + int32 n; + int32 pad; + int32 ret; + } *args = v; + + args->ret = fib1(args->n); +} |