| 1 |
// Program fib uses the psx package once, and then prints the first |
| 2 |
// ten Fibonacci numbers. |
| 3 |
package main |
| 4 |
|
| 5 |
import ( |
| 6 |
"fmt" |
| 7 |
"log" |
| 8 |
"syscall" |
| 9 |
|
| 10 |
"fib/fibber" |
| 11 |
|
| 12 |
"kernel.org/pub/linux/libs/security/libcap/psx" |
| 13 |
) |
| 14 |
|
| 15 |
func main() { |
| 16 |
pid, _, err := psx.Syscall3(syscall.SYS_GETPID, 0, 0, 0) |
| 17 |
if err != 0 { |
| 18 |
log.Fatalf("failed to get PID via psx: %v", err) |
| 19 |
} |
| 20 |
fmt.Print("psx syscall result: PID=") |
| 21 |
fmt.Println(pid) |
| 22 |
s := fibber.NewState() |
| 23 |
fmt.Print("fib: ", s.A, ", ", s.B) |
| 24 |
for i := 0; i < 8; i++ { |
| 25 |
s.Next() |
| 26 |
fmt.Print(", ", s.B) |
| 27 |
} |
| 28 |
fmt.Println(", ...") |
| 29 |
} |