Annotation of embedaddon/ntp/libntp/tsftomsu.c, revision 1.1.1.1
1.1 misho 1: /*
2: * tsftomsu - convert from a time stamp fraction to milliseconds
3: */
4: #include "ntp_fp.h"
5: #include "ntp_stdlib.h"
6:
7: int
8: tsftomsu(
9: u_long tsf,
10: int round
11: )
12: {
13: register long val_ui, val_uf;
14: register long tmp_ui, tmp_uf;
15: register int i;
16:
17: /*
18: * Essentially, multiply by 10 three times in l_fp form.
19: * The integral part is the milliseconds.
20: */
21: val_ui = 0;
22: val_uf = tsf;
23: for (i = 3; i > 0; i--) {
24: M_LSHIFT(val_ui, val_uf);
25: tmp_ui = val_ui;
26: tmp_uf = val_uf;
27: M_LSHIFT(val_ui, val_uf);
28: M_LSHIFT(val_ui, val_uf);
29: M_ADD(val_ui, val_uf, tmp_ui, tmp_uf);
30: }
31:
32: /*
33: * Round the value if need be, then return it.
34: */
35: if (round && (val_uf & 0x80000000))
36: val_ui++;
37: return (int)val_ui;
38: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>