aboutsummaryrefslogtreecommitdiff
path: root/contrib/bug216610/go/main.go
blob: 65121f68db9ba3743ec58d87d4d00f60f96b2170 (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
// Program fib uses the psx package once, and then prints the first
// ten Fibonacci numbers.
package main

import (
	"fmt"
	"log"
	"syscall"

	"fib/fibber"

	"kernel.org/pub/linux/libs/security/libcap/psx"
)

func main() {
	pid, _, err := psx.Syscall3(syscall.SYS_GETPID, 0, 0, 0)
	if err != 0 {
		log.Fatalf("failed to get PID via psx: %v", err)
	}
	fmt.Print("psx syscall result: PID=")
	fmt.Println(pid)
	s := fibber.NewState()
	fmt.Print("fib: ", s.A, ", ", s.B)
	for i := 0; i < 8; i++ {
		s.Next()
		fmt.Print(", ", s.B)
	}
	fmt.Println(", ...")
}