settime: round, instead of truncate, to the nearest second.

This commit is contained in:
pk 2004-07-05 09:24:31 +00:00
parent 134c600216
commit 3936924e40
2 changed files with 10 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: intersil7170.c,v 1.2 2001/11/13 13:14:38 lukem Exp $ */
/* $NetBSD: intersil7170.c,v 1.3 2004/07/05 09:24:31 pk Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: intersil7170.c,v 1.2 2001/11/13 13:14:38 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: intersil7170.c,v 1.3 2004/07/05 09:24:31 pk Exp $");
#include <sys/param.h>
#include <sys/malloc.h>
@ -159,9 +159,11 @@ intersil7170_settime(handle, tv)
struct clock_ymdhms dt;
u_int8_t cmd;
int year;
long sec;
int s;
clock_secs_to_ymdhms(tv->tv_sec, &dt);
sec = tv->tv_sec + ((tv->tv_usec < 500000) ? 0 : 1);
clock_secs_to_ymdhms(sec, &dt);
year = dt.dt_year - sil->sil_year0;
if (year > 99 && intersil7170_auto_century_adjust != 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: mk48txx.c,v 1.14 2004/03/01 23:46:44 kleink Exp $ */
/* $NetBSD: mk48txx.c,v 1.15 2004/07/05 09:24:31 pk Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mk48txx.c,v 1.14 2004/03/01 23:46:44 kleink Exp $");
__KERNEL_RCSID(0, "$NetBSD: mk48txx.c,v 1.15 2004/07/05 09:24:31 pk Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -176,12 +176,14 @@ mk48txx_settime(handle, tv)
struct clock_ymdhms dt;
u_int8_t csr;
int year;
long sec;
sc = handle->cookie;
clkoff = sc->sc_clkoffset;
/* Note: we ignore `tv_usec' */
clock_secs_to_ymdhms(tv->tv_sec, &dt);
sec = tv->tv_sec + ((tv->tv_usec < 500000) ? 0 : 1);
clock_secs_to_ymdhms(sec, &dt);
year = dt.dt_year - sc->sc_year0;
if (year > 99 &&