1/* 2 * ntp_fp.h - definitions for NTP fixed/floating-point arithmetic 3 */ 4 5#ifndef NTP_FP_H 6#define NTP_FP_H 7 8#include <sys/types.h> 9#include <sys/socket.h> |
10#include "ntp_rfc2553.h" |
11#include <netinet/in.h> 12 13#include "ntp_types.h" 14 15/* 16 * NTP uses two fixed point formats. The first (l_fp) is the "long" 17 * format and is 64 bits long with the decimal between bits 31 and 32. 18 * This is used for time stamps in the NTP packet header (in network --- 315 unchanged lines hidden (view full) --- 334 } \ 335 } while (0) 336#define DTOLFP(d, v) M_DTOLFP((d), (v)->l_ui, (v)->l_uf) 337#define LFPTOD(v, d) M_LFPTOD((v)->l_ui, (v)->l_uf, (d)) 338 339/* 340 * Prototypes 341 */ |
342extern char * dofptoa P((u_fp, int, short, int)); 343extern char * dolfptoa P((u_long, u_long, int, short, int)); |
344 345extern int atolfp P((const char *, l_fp *)); 346extern int buftvtots P((const char *, l_fp *)); |
347extern char * fptoa P((s_fp, short)); 348extern char * fptoms P((s_fp, short)); |
349extern int hextolfp P((const char *, l_fp *)); 350extern void gpstolfp P((int, int, unsigned long, l_fp *)); 351extern int mstolfp P((const char *, l_fp *)); 352extern char * prettydate P((l_fp *)); 353extern char * gmprettydate P((l_fp *)); 354extern char * uglydate P((l_fp *)); 355extern void mfp_mul P((int32 *, u_int32 *, int32, u_int32, int32, u_int32)); 356 357extern void get_systime P((l_fp *)); 358extern int step_systime P((double)); 359extern int adj_systime P((double)); 360 361#define lfptoa(_fpv, _ndec) mfptoa((_fpv)->l_ui, (_fpv)->l_uf, (_ndec)) 362#define lfptoms(_fpv, _ndec) mfptoms((_fpv)->l_ui, (_fpv)->l_uf, (_ndec)) 363 |
364#define stoa(_sin) socktoa((_sin)) 365#define stohost(_sin) socktohost((_sin)) |
366 |
367#define ntoa(_sin) stoa(_sin) 368#define ntohost(_sin) stohost(_sin) 369 |
370#define ufptoa(_fpv, _ndec) dofptoa((_fpv), 0, (_ndec), 0) 371#define ufptoms(_fpv, _ndec) dofptoa((_fpv), 0, (_ndec), 1) 372#define ulfptoa(_fpv, _ndec) dolfptoa((_fpv)->l_ui, (_fpv)->l_uf, 0, (_ndec), 0) 373#define ulfptoms(_fpv, _ndec) dolfptoa((_fpv)->l_ui, (_fpv)->l_uf, 0, (_ndec), 1) 374#define umfptoa(_fpi, _fpf, _ndec) dolfptoa((_fpi), (_fpf), 0, (_ndec), 0) 375 376#endif /* NTP_FP_H */ |