version 1.2, 2001/03/29 13:27:43
|
version 1.3, 2001/04/03 21:14:33
|
Line 14
|
Line 14
|
|
|
boolean timed_io; |
boolean timed_io; |
boolean accept_weird_scr; |
boolean accept_weird_scr; |
int global_delta; |
t_msec global_delta; |
|
|
#ifdef DEBUG_TIMEPOLL |
#ifdef DEBUG_TIMEPOLL |
timepoll logtp [max_timepoll]; |
timepoll logtp [max_timepoll]; |
Line 22 long logtpc;
|
Line 22 long logtpc;
|
timepoll *ltp; |
timepoll *ltp; |
#endif |
#endif |
|
|
int msec_now (void) |
t_msec msec_now (void) |
{ |
{ |
|
#define MSEC_EXPONENT 21 |
static long last; |
static long last; |
static int local_delta; |
static int local_delta; |
struct timeval tv; |
struct timeval tv; |
Line 33 int msec_now (void)
|
Line 34 int msec_now (void)
|
ltp->tv.tv_sec = tv.tv_sec; |
ltp->tv.tv_sec = tv.tv_sec; |
ltp->tv.tv_usec = tv.tv_usec; |
ltp->tv.tv_usec = tv.tv_usec; |
#endif |
#endif |
if ((tv.tv_sec & (~0x001FFFFFL)) != last) { |
if ((tv.tv_sec & (~((1L << MSEC_EXPONENT) - 1))) != last) { |
last = tv.tv_sec & (~0x001FFFFFL); |
last = tv.tv_sec & (~((1L << MSEC_EXPONENT) - 1)); |
local_delta += 1000 * 0x00200000L; |
local_delta += 1000 * (1L << MSEC_EXPONENT); |
} |
} |
now = (tv.tv_sec & 0x001FFFFFL) * 1000 + tv.tv_usec / 1000 + local_delta; |
now = (tv.tv_sec & ((1L << MSEC_EXPONENT) - 1)) * 1000 |
|
+ tv.tv_usec / 1000 + local_delta; |
warn (LDEB,"msec_now",EGLO,3,0,now); |
warn (LDEB,"msec_now",EGLO,3,0,now); |
#ifdef DEBUG_TIMEPOLL |
#ifdef DEBUG_TIMEPOLL |
ltp->cnt_msecnow += 1; |
ltp->cnt_msecnow += 1; |
Line 48 int msec_now (void)
|
Line 50 int msec_now (void)
|
|
|
void cref2msec (conversion_base *b, |
void cref2msec (conversion_base *b, |
clockref c, |
clockref c, |
int *m) |
t_msec *m) |
{ |
{ |
#define CREF2MSEC_LIMIT (90 * 1024 * 16) /* 16 sec */ |
#define CREF2MSEC_LIMIT (90 * 1024 * 16) /* 16 sec */ |
unsigned long d; |
unsigned long d; |
d = c.base - b->base; |
d = c.base - b->base; |
if (d >= (2 * CREF2MSEC_LIMIT)) { |
if (d >= (2 * CREF2MSEC_LIMIT)) { |
if (d >= (3 * CREF2MSEC_LIMIT)) { |
if (d >= (3 * CREF2MSEC_LIMIT)) { |
|
warn (LDEB,"cref2msec",EGLO,4,1,d); |
b->base = c.base - CREF2MSEC_LIMIT; |
b->base = c.base - CREF2MSEC_LIMIT; |
b->msec = b->base / 90; |
b->msec = b->base / 90; |
} else { |
} else { |
|
warn (LDEB,"cref2msec",EGLO,4,2,d); |
b->base += CREF2MSEC_LIMIT; |
b->base += CREF2MSEC_LIMIT; |
b->msec += CREF2MSEC_LIMIT / 90; |
b->msec += CREF2MSEC_LIMIT / 90; |
} |
} |
Line 67 void cref2msec (conversion_base *b,
|
Line 71 void cref2msec (conversion_base *b,
|
} |
} |
|
|
void msec2cref (conversion_base *b, |
void msec2cref (conversion_base *b, |
int m, |
t_msec m, |
clockref *c) |
clockref *c) |
{ |
{ |
#define MSEC2CREF_LIMIT (1024 * 10) /* 10 sec */ |
#define MSEC2CREF_LIMIT (1024 * 10) /* 10 sec */ |
Line 75 void msec2cref (conversion_base *b,
|
Line 79 void msec2cref (conversion_base *b,
|
d = m - b->msec; |
d = m - b->msec; |
if (d >= (2 * MSEC2CREF_LIMIT)) { |
if (d >= (2 * MSEC2CREF_LIMIT)) { |
if (d >= (3 * MSEC2CREF_LIMIT)) { |
if (d >= (3 * MSEC2CREF_LIMIT)) { |
|
warn (LDEB,"msec2cref",EGLO,5,1,d); |
b->msec = m - MSEC2CREF_LIMIT; |
b->msec = m - MSEC2CREF_LIMIT; |
b->base = b->msec * 45; |
b->base = b->msec * 45; |
} else { |
} else { |
|
warn (LDEB,"msec2cref",EGLO,5,2,d); |
b->msec += MSEC2CREF_LIMIT; |
b->msec += MSEC2CREF_LIMIT; |
b->base += MSEC2CREF_LIMIT * 45; |
b->base += MSEC2CREF_LIMIT * 45; |
} |
} |