Lines Matching +full:fixed +full:- +full:1 +full:- +full:8 +full:v
2 * ntp_fp.h - definitions for NTP fixed/floating-point arithmetic
11 * NTP uses two fixed point formats. The first (l_fp) is the "long"
21 * 0 1 2 3
22 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
23 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 * The second fixed point format is 32 bits, with the decimal between
57 * 0 1 2 3
58 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
59 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
91 HTONL_MFP((h)->l_ui, (h)->l_uf, (n)->l_ui, (n)->l_uf)
94 NTOHL_MFP((n)->l_ui, (n)->l_uf, (h)->l_ui, (h)->l_uf)
99 (nts)->l_ui = 0; \
100 (nts)->l_uf = htonl(uf); \
104 * Conversions between the two fixed point types
107 (((x_i) <= -0x00010000) ? 0x80000000 : \
109 #define LFPTOFP(v) MFPTOFP((v)->l_i, (v)->l_uf) argument
111 #define UFPTOLFP(x, v) ((v)->l_ui = (u_fp)(x)>>16, (v)->l_uf = (x)<<16) argument
112 #define FPTOLFP(x, v) (UFPTOLFP((x), (v)), (x) < 0 ? (v)->l_ui -= 0x10000 : 0) argument
114 #define MAXLFP(v) ((v)->l_ui = 0x7fffffffu, (v)->l_uf = 0xffffffffu) argument
115 #define MINLFP(v) ((v)->l_ui = 0x80000000u, (v)->l_uf = 0u) argument
118 * Primitive operations on long fixed point values. If these are
121 * These are the (kind of inefficient) run-anywhere versions.
123 #define M_NEG(v_i, v_f) /* v = -v */ \
125 (v_f) = ~(v_f) + 1u; \
129 #define M_NEGM(r_i, r_f, a_i, a_f) /* r = -a */ \
131 (r_f) = ~(a_f) + 1u; \
156 #define M_SUB(r_i, r_f, a_i, a_f) /* r -= a */ \
159 (r_f) -= (a_f); \
160 (r_i) -= (a_i) + ((u_int32)(r_f) > sub_t); \
163 #define M_RSHIFTU(v_i, v_f) /* v >>= 1, v is unsigned */ \
165 (v_f) = ((u_int32)(v_f) >> 1) | ((u_int32)(v_i) << 31); \
166 (v_i) = ((u_int32)(v_i) >> 1); \
169 #define M_RSHIFT(v_i, v_f) /* v >>= 1, v is signed */ \
171 (v_f) = ((u_int32)(v_f) >> 1) | ((u_int32)(v_i) << 31); \
172 (v_i) = ((u_int32)(v_i) >> 1) | ((u_int32)(v_i) & 0x80000000); \
175 #define M_LSHIFT(v_i, v_f) /* v <<= 1 */ \
177 (v_i) = ((u_int32)(v_i) << 1) | ((u_int32)(v_f) >> 31); \
178 (v_f) = ((u_int32)(v_f) << 1); \
181 #define M_LSHIFT3(v_o, v_i, v_f) /* v <<= 1, with overflow */ \
183 (v_o) = ((u_int32)(v_o) << 1) | ((u_int32)(v_i) >> 31); \
184 (v_i) = ((u_int32)(v_i) << 1) | ((u_int32)(v_f) >> 31); \
185 (v_f) = ((u_int32)(v_f) << 1); \
191 #define M_SUBUF(r_i, r_f, uf) /* r -= uf, uf is u_int32 fraction */ \
200 M_SUB((r_i), (r_f), 0, (u_int32)(-add_f)); \
203 #define M_ISNEG(v_i) /* v < 0 */ \
228 #define L_ADD(r, a) M_ADD((r)->l_ui, (r)->l_uf, (a)->l_ui, (a)->l_uf)
229 #define L_SUB(r, a) M_SUB((r)->l_ui, (r)->l_uf, (a)->l_ui, (a)->l_uf)
230 #define L_NEG(v) M_NEG((v)->l_ui, (v)->l_uf) argument
231 #define L_ADDUF(r, uf) M_ADDUF((r)->l_ui, (r)->l_uf, (uf))
232 #define L_SUBUF(r, uf) M_SUBUF((r)->l_ui, (r)->l_uf, (uf))
233 #define L_ADDF(r, f) M_ADDF((r)->l_ui, (r)->l_uf, (f))
234 #define L_RSHIFT(v) M_RSHIFT((v)->l_i, (v)->l_uf) argument
235 #define L_RSHIFTU(v) M_RSHIFTU((v)->l_ui, (v)->l_uf) argument
236 #define L_LSHIFT(v) M_LSHIFT((v)->l_ui, (v)->l_uf) argument
237 #define L_CLR(v) ((v)->l_ui = (v)->l_uf = 0) argument
239 #define L_ISNEG(v) M_ISNEG((v)->l_ui) argument
240 #define L_ISZERO(v) (((v)->l_ui | (v)->l_uf) == 0) argument
241 #define L_ISGT(a, b) M_ISGT((a)->l_i, (a)->l_uf, (b)->l_i, (b)->l_uf)
242 #define L_ISGTU(a, b) M_ISGTU((a)->l_ui, (a)->l_uf, (b)->l_ui, (b)->l_uf)
243 #define L_ISHIS(a, b) M_ISHIS((a)->l_ui, (a)->l_uf, (b)->l_ui, (b)->l_uf)
244 #define L_ISGEQ(a, b) M_ISGEQ((a)->l_ui, (a)->l_uf, (b)->l_ui, (b)->l_uf)
245 #define L_ISEQU(a, b) M_ISEQU((a)->l_ui, (a)->l_uf, (b)->l_ui, (b)->l_uf)
286 d_tmp = -d_tmp; \
290 q_tmp = ~q_tmp + 1; \
305 q_tmp = ~q_tmp + 1; \
307 d_tmp = ldexp((double)q_tmp, -32); \
309 d_tmp = -d_tmp; \
320 (r_ui) = (u_int32)(-d_tmp); \
321 (r_uf) = (u_int32)(-(d_tmp + (double)(r_ui)) * FRAC); \
325 (r_uf) = (u_int32)((d_tmp - (double)(r_ui)) * FRAC); \
334 (d) = -((double)l_thi + (double)l_tlo / FRAC); \
341 #define DTOLFP(d, v) M_DTOLFP((d), (v)->l_ui, (v)->l_uf) argument
342 #define LFPTOD(v, d) M_LFPTOD((v)->l_ui, (v)->l_uf, (d)) argument
371 #define lfptoa(fpv, ndec) mfptoa((fpv)->l_ui, (fpv)->l_uf, (ndec))
372 #define lfptoms(fpv, ndec) mfptoms((fpv)->l_ui, (fpv)->l_uf, (ndec))
380 #define ufptoms(fpv, ndec) dofptoa((fpv), 0, (ndec), 1)
381 #define ulfptoa(fpv, ndec) dolfptoa((fpv)->l_ui, (fpv)->l_uf, 0, (ndec), 0)
382 #define ulfptoms(fpv, ndec) dolfptoa((fpv)->l_ui, (fpv)->l_uf, 0, (ndec), 1)
393 * Multi-thread locking for get_systime()