author | greg |
Tue, 29 Jan 2008 11:17:26 +0100 | |
changeset 92 | b4e25e5030d4 |
parent 79 | ae06c2da83f7 |
child 110 | a05e8b30c024 |
permissions | -rw-r--r-- |
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
1 |
#include <stdio.h> |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
2 |
#include <sys/timeb.h> |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
3 |
#include <time.h> |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
4 |
#include <windows.h> |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
5 |
|
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
6 |
void timer_notify() |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
7 |
{ |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
8 |
struct _timeb timebuffer; |
75 | 9 |
printf("."); |
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
10 |
|
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
11 |
_ftime( &timebuffer ); |
75 | 12 |
__CURRENT_TIME.tv_sec = timebuffer.time; |
13 |
__CURRENT_TIME.tv_nsec = timebuffer.millitm * 1000000; |
|
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
14 |
__run(); |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
15 |
} |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
16 |
|
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
17 |
int main(int argc,char **argv) |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
18 |
{ |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
19 |
HANDLE hTimer = NULL; |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
20 |
LARGE_INTEGER liDueTime; |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
21 |
|
75 | 22 |
liDueTime.QuadPart = -10000 * maxval(common_ticktime__,1); |
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
23 |
|
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
24 |
// Create a waitable timer. |
75 | 25 |
hTimer = CreateWaitableTimer(NULL, FALSE, "WaitableTimer"); |
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
26 |
if (NULL == hTimer) |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
27 |
{ |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
28 |
printf("CreateWaitableTimer failed (%d)\n", GetLastError()); |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
29 |
return 1; |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
30 |
} |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
31 |
|
57 | 32 |
if( __init(argc,argv) == 0 ){ |
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
33 |
|
75 | 34 |
printf("Tick Time : %d ms\n", common_ticktime__); |
57 | 35 |
// Set a timer |
36 |
if (!SetWaitableTimer(hTimer, &liDueTime, common_ticktime__, NULL, NULL, 0)) |
|
37 |
{ |
|
38 |
printf("SetWaitableTimer failed (%d)\n", GetLastError()); |
|
39 |
return 2; |
|
40 |
} |
|
41 |
||
42 |
while(1){ |
|
43 |
// Wait for the timer. |
|
44 |
if (WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0) |
|
45 |
{ |
|
46 |
printf("WaitForSingleObject failed (%d)\n", GetLastError()); |
|
47 |
break; |
|
48 |
} |
|
79 | 49 |
if (kbhit()) |
50 |
{ |
|
51 |
printf("Finishing\n"); |
|
52 |
break; |
|
53 |
} |
|
57 | 54 |
timer_notify(); |
55 |
} |
|
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
56 |
} |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
57 |
__cleanup(); |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
58 |
|
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
59 |
return 0; |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
60 |
} |