Sync usage with man page.
[netbsd-mini2440.git] / dist / ntp / libntp / tsftomsu.c
blobe564c8135c42628faee2ce62b14c4589839e54a4
1 /* $NetBSD$ */
3 /*
4 * tsftomsu - convert from a time stamp fraction to milliseconds
5 */
6 #include "ntp_fp.h"
7 #include "ntp_stdlib.h"
9 int
10 tsftomsu(
11 u_long tsf,
12 int round
15 register long val_ui, val_uf;
16 register long tmp_ui, tmp_uf;
17 register int i;
20 * Essentially, multiply by 10 three times in l_fp form.
21 * The integral part is the milliseconds.
23 val_ui = 0;
24 val_uf = tsf;
25 for (i = 3; i > 0; i--) {
26 M_LSHIFT(val_ui, val_uf);
27 tmp_ui = val_ui;
28 tmp_uf = val_uf;
29 M_LSHIFT(val_ui, val_uf);
30 M_LSHIFT(val_ui, val_uf);
31 M_ADD(val_ui, val_uf, tmp_ui, tmp_uf);
35 * Round the value if need be, then return it.
37 if (round && (val_uf & 0x80000000))
38 val_ui++;
39 return (int)val_ui;