author | lbessard |
Tue, 02 Oct 2007 18:05:36 +0200 | |
changeset 60 | e9667bec7f00 |
parent 57 | 3b53f9a509d9 |
child 75 | 9ad18a387a96 |
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; |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
9 |
|
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
10 |
_ftime( &timebuffer ); |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
11 |
CURRENT_TIME.tv_sec = timebuffer.time; |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
12 |
CURRENT_TIME.tv_nsec = timebuffer.millitm * 1000000 |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
13 |
__run(); |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
14 |
} |
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 |
int main(int argc,char **argv) |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
17 |
{ |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
18 |
HANDLE hTimer = NULL; |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
19 |
LARGE_INTEGER liDueTime; |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
20 |
|
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
21 |
liDueTime.QuadPart = -10000 * maxval(common_ticktime__,1);; |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
22 |
|
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
23 |
// Create a waitable timer. |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
24 |
hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer"); |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
25 |
if (NULL == hTimer) |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
26 |
{ |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
27 |
printf("CreateWaitableTimer failed (%d)\n", GetLastError()); |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
28 |
return 1; |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
29 |
} |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
30 |
|
57 | 31 |
if( __init(argc,argv) == 0 ){ |
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
32 |
|
57 | 33 |
// Set a timer |
34 |
if (!SetWaitableTimer(hTimer, &liDueTime, common_ticktime__, NULL, NULL, 0)) |
|
35 |
{ |
|
36 |
printf("SetWaitableTimer failed (%d)\n", GetLastError()); |
|
37 |
return 2; |
|
38 |
} |
|
39 |
||
40 |
while(1){ |
|
41 |
// Wait for the timer. |
|
42 |
if (WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0) |
|
43 |
{ |
|
44 |
printf("WaitForSingleObject failed (%d)\n", GetLastError()); |
|
45 |
break; |
|
46 |
} |
|
47 |
timer_notify(); |
|
48 |
} |
|
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
49 |
} |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
50 |
__cleanup(); |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
51 |
|
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
52 |
return 0; |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
53 |
} |