aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/xntpd/lib/gettstamp.c
blob: 19bcb0c638ff514d6de7627aa76e8cb7572d2aab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* gettstamp.c,v 3.1 1993/07/06 01:08:20 jbj Exp
 * gettstamp - return the system time in timestamp format
 */
#include <stdio.h>
#include <sys/time.h>

#include "ntp_fp.h"
#include "ntp_unixtime.h"
#include "ntp_stdlib.h"

void
gettstamp(ts)
	l_fp *ts;
{
	struct timeval tv;

	/*
	 * Quickly get the time of day and convert it
	 */
	(void) GETTIMEOFDAY(&tv, (struct timezone *)NULL);
	if (tv.tv_usec >= 1000000) {	/* bum solaris */
		tv.tv_usec -= 1000000;
		tv.tv_sec++;
	}
	TVTOTS(&tv, ts);
	ts->l_uf += TS_ROUNDBIT;	/* guaranteed not to overflow */
	ts->l_ui += JAN_1970;
	ts->l_uf &= TS_MASK;
}