summaryrefslogtreecommitdiff
path: root/usr/rsc/fib/gcc.c
blob: a8983903141811e6f0cc337fc3c14e5e4c273fd1 (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
// 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);
}