Last change
on this file since 105 was
81,
checked in by rosiere, 17 years ago
|
- Finish Environment (and test)
- Continue predictor_unit
- Add external tools
- svn keyword "Id" set
|
-
Property svn:keywords set to
Id
|
File size:
787 bytes
|
Line | |
---|
1 | #include <setjmp.h> |
---|
2 | #include <stdio.h> |
---|
3 | #include <stdlib.h> |
---|
4 | #include <math.h> |
---|
5 | jmp_buf env; |
---|
6 | |
---|
7 | int exec_setjmp (int val_max, int base) |
---|
8 | { |
---|
9 | int res = -2; |
---|
10 | int val = setjmp(env); // 1 call = 0, first return of longjmp -> 1, après renvoye X^N |
---|
11 | |
---|
12 | if (val < val_max) |
---|
13 | { |
---|
14 | print(val); |
---|
15 | res ++; |
---|
16 | longjmp (env,base*val); |
---|
17 | } |
---|
18 | |
---|
19 | return res; |
---|
20 | } |
---|
21 | |
---|
22 | int test_setjmp () |
---|
23 | { |
---|
24 | quit(exec_setjmp (366,2)); |
---|
25 | |
---|
26 | return (1); |
---|
27 | |
---|
28 | /* |
---|
29 | int base = 2; |
---|
30 | int val,res,it; |
---|
31 | |
---|
32 | srand(0); |
---|
33 | |
---|
34 | for (it = 0; it < 10; it ++) |
---|
35 | { |
---|
36 | val = (rand()%1500); |
---|
37 | |
---|
38 | res = exec_setjmp (val,base); |
---|
39 | |
---|
40 | print(res); |
---|
41 | |
---|
42 | //printf("test_setjmp : log2(%d)=%d (%d)\n",val,res,(unsigned int)log2((double)val)); |
---|
43 | |
---|
44 | if ((unsigned int)log2(val) != res) |
---|
45 | return 0; |
---|
46 | } |
---|
47 | return 1; |
---|
48 | */ |
---|
49 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.