*
* @APPLE_LICENSE_HEADER_START@
*
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.1 (the
+ * "License"). You may not use this file except in compliance with the
+ * License. Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
*
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/* NOTE THIS implementation is for non ppc architectures only */
if (uap->tp) {
- microtime(&atv);
+ clock_get_calendar_microtime(&atv.tv_sec, &atv.tv_usec);
if (error = copyout((caddr_t)&atv, (caddr_t)uap->tp,
sizeof (atv)))
return(error);
struct timeval *tv;
{
long delta = tv->tv_sec - time.tv_sec;
- mach_timespec_t now;
-
- now.tv_sec = tv->tv_sec;
- now.tv_nsec = tv->tv_usec * NSEC_PER_USEC;
- clock_set_calendar_value(now);
+ clock_set_calendar_microtime(tv->tv_sec, tv->tv_usec);
boottime.tv_sec += delta;
#if NFSCLIENT || NFSSERVER
lease_updatetime(delta);
#endif
}
-#define tickadj (40 * NSEC_PER_USEC) /* "standard" skew, ns / 10 ms */
-#define bigadj (1 * NSEC_PER_SEC) /* use 10x skew above bigadj ns */
-
struct adjtime_args {
struct timeval *delta;
struct timeval *olddelta;
register_t *retval;
{
struct timeval atv;
- int64_t total;
- uint32_t delta;
int error;
if (error = suser(p->p_ucred, &p->p_acflag))
/*
* Compute the total correction and the rate at which to apply it.
*/
- total = (int64_t)atv.tv_sec * NSEC_PER_SEC + atv.tv_usec * NSEC_PER_USEC;
- if (total > bigadj || total < -bigadj)
- delta = 10 * tickadj;
- else
- delta = tickadj;
-
- total = clock_set_calendar_adjtime(total, delta);
+ clock_adjtime(&atv.tv_sec, &atv.tv_usec);
if (uap->olddelta) {
- atv.tv_sec = total / NSEC_PER_SEC;
- atv.tv_usec = (total / NSEC_PER_USEC) % USEC_PER_SEC;
(void) copyout((caddr_t)&atv,
(caddr_t)uap->olddelta, sizeof (struct timeval));
}
inittodr(base)
time_t base;
{
+ struct timeval tv;
+
/*
* Assertion:
* The calendar has already been
* The value returned by microtime()
* is gotten from the calendar.
*/
- microtime(&time);
+ microtime(&tv);
- /*
- * This variable still exists to keep
- * 'w' happy. It should only be considered
- * an approximation.
- */
- boottime.tv_sec = time.tv_sec;
+ time = tv;
+ boottime.tv_sec = tv.tv_sec;
boottime.tv_usec = 0;
/*
* If the RTC does not have acceptable value, i.e. time before
* the UNIX epoch, set it to the UNIX epoch
*/
- if (time.tv_sec < 0) {
+ if (tv.tv_sec < 0) {
printf ("WARNING: preposterous time in Real Time Clock");
time.tv_sec = 0; /* the UNIX epoch */
time.tv_usec = 0;
}
}
- thread_call_func_delayed(realitexpire, pid, tvtoabstime(&p->p_rtime));
-
psignal(p, SIGALRM);
+ thread_call_func_delayed(realitexpire, pid, tvtoabstime(&p->p_rtime));
+
(void) thread_funnel_set(kernel_flock, FALSE);
}
microtime(
struct timeval *tvp)
{
- mach_timespec_t now = clock_get_calendar_value();
-
- tvp->tv_sec = now.tv_sec;
- tvp->tv_usec = now.tv_nsec / NSEC_PER_USEC;
+ clock_get_calendar_microtime(&tvp->tv_sec, &tvp->tv_usec);
}
void
microuptime(
struct timeval *tvp)
{
- mach_timespec_t now = clock_get_system_value();
-
- tvp->tv_sec = now.tv_sec;
- tvp->tv_usec = now.tv_nsec / NSEC_PER_USEC;
+ clock_get_system_microtime(&tvp->tv_sec, &tvp->tv_usec);
}
/*
nanotime(
struct timespec *tsp)
{
- mach_timespec_t now = clock_get_calendar_value();
-
- tsp->tv_sec = now.tv_sec;
- tsp->tv_nsec = now.tv_nsec;
+ clock_get_calendar_nanotime((uint32_t *)&tsp->tv_sec, &tsp->tv_nsec);
}
void
nanouptime(
struct timespec *tsp)
{
- mach_timespec_t now = clock_get_system_value();
-
- tsp->tv_sec = now.tv_sec;
- tsp->tv_nsec = now.tv_nsec;
+ clock_get_system_nanotime((uint32_t *)&tsp->tv_sec, &tsp->tv_nsec);
}
uint64_t