blob: 627bdb2f001d8b605de05ab917b8ec63f1cce223 (
plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/*
* Ivy, C interface
*
* Copyright (C) 1997-2000
* Centre d'Études de la Navigation Aérienne
*
* Timers for select-based main loop
*
* Authors: François-Régis Colin <fcolin@cena.dgac.fr>
*
* $Id$
*
* Please refer to file version.h for the
* copyright notice regarding this software
*/
#ifndef IVYTIMER_H
#define IVYTIMER_H
#ifdef __cplusplus
extern "C" {
#endif
/* Module de gestion des timers autour d'un select */
typedef struct _timer *TimerId;
typedef void (*TimerCb)( TimerId id , void *user_data, unsigned long delta );
/* API le temps est en millisecondes */
#define TIMER_LOOP -1 /* timer en boucle infinie */
TimerId TimerRepeatAfter( int count, long timeout, TimerCb cb, void *user_data );
void TimerModify( TimerId id, long timeout );
void TimerRemove( TimerId id );
// implemetation of gettimeofday for windows
#ifdef WIN32
#include "time.h"
struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
int gettimeofday(struct timeval *tv, struct timezone *tz);
/**
* timersub(3) from <sys/time.h>
*/
static inline void timersub(struct timeval* a, struct timeval* b,
struct timeval* res)
{
res->tv_sec = a->tv_sec - b->tv_sec;
res->tv_usec = a->tv_usec - b->tv_usec;
if (res->tv_usec < 0)
{
res->tv_usec += 1000000;
res->tv_sec--;
}
}
#endif
/* Interface avec select */
struct timeval *TimerGetSmallestTimeout();
void TimerScan();
#ifdef __cplusplus
}
#endif
#endif
|