forked from sysprog21/fibdrv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
us_debug.c
33 lines (28 loc) · 745 Bytes
/
us_debug.c
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
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include "bn.h"
#define FIB_DEV "/dev/fibonacci"
#define offset 2000
#define mode 0
int main()
{
void (*fib_algorithm[3])(bn *, unsigned int) = {bn_fib_v1, bn_fdoubling_v0,
bn_fdoubling_v1};
for (int i = 0; i <= offset; i++) {
bn *fib = bn_alloc(1);
fib_algorithm[mode](fib, i);
char *buf = bn_to_string(fib);
printf("Reading from " FIB_DEV
" at offset %d, returned the sequence "
"%s.\n",
i, buf);
bn_free(fib);
free(buf);
}
return 0;
}