/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2015, Joyent Inc. All rights reserved.
*/
/*ARGSUSED*/
static int
{
return (EINVAL);
}
static int
{
return (0);
}
static int
{
return (0);
}
/*ARGSUSED*/
static int
{
/*
* CLOCK_HIGHRES timers of sufficiently high resolution can deny
* service; only allow privileged users to create such timers.
* Sites that do not wish to have this restriction should
* give users the "proc_clock_highres" privilege.
*/
if (secpolicy_clock_highres(CRED()) != 0) {
return (EPERM);
}
return (0);
}
static void
{
do {
}
static int
const struct itimerspec *when)
{
int pset;
/*
* If our existing timer is a one-shot and our new timer is a
* one-shot, we'll save ourselves a world of grief and just
* reprogram the cyclic.
*/
if (!(flags & TIMER_ABSTIME))
return (0);
}
*cycp = CYCLIC_NONE;
}
return (0);
}
if (!(flags & TIMER_ABSTIME))
/*
* Now we will check for overflow (that is, we will check to see
* that the start time plus the interval time doesn't exceed
* INT64_MAX). The astute code reviewer will observe that this
* one-time check doesn't guarantee that a future expiration
* will not wrap. We wish to prove, then, that if a future
* expiration does wrap, the earliest the problem can be encountered
* is (INT64_MAX / 2) nanoseconds (191 years) after boot. Formally:
*
* Given: s + i < m s > 0 i > 0
* s + ni > m n > 1
*
* (where "s" is the start time, "i" is the interval, "n" is the
* number of times the cyclic has fired and "m" is INT64_MAX)
*
* Prove:
* (a) s + (n - 1)i > (m / 2)
* (b) s + (n - 1)i < m
*
* That is, prove that we must have fired at least once 191 years
* after boot. The proof is very straightforward; since the left
* side of (a) is minimized when i is small, it is sufficient to show
* that the statement is true for i's smallest possible value
* (((m - s) / n) + epsilon). The same goes for (b); showing that the
* statement is true for i's largest possible value (m - s + epsilon)
* is sufficient to prove the statement.
*
* The actual arithmetic manipulation is left up to reader.
*/
return (EOVERFLOW);
}
if (cyctime.cyt_interval == 0) {
/*
* If this is a one-shot, then we set the interval to be
* inifinite. If this timer is never touched, this cyclic will
* simply consume space in the cyclic subsystem. As soon as
* timer_settime() or timer_delete() is called, the cyclic is
* removed (so it's not possible to run the machine out
* of resources by creating one-shots).
*/
}
/*
* Now that we have the cyclic created, we need to bind it to our
* bound CPU and processor set (if any).
*/
mutex_enter(&p->p_lock);
cpu = t->t_bound_cpu;
pset = t->t_bind_pset;
mutex_exit(&p->p_lock);
return (0);
}
static int
{
/*
* CLOCK_HIGHRES doesn't update it_itime.
*/
/*
* We're using atomic_cas_64() here only to assure that we slurp the
* entire timestamp atomically.
*/
return (0);
/*
* We haven't gone off yet...
*/
} else {
if (interval == 0) {
/*
* This is a one-shot which should have already
* fired; set it_value to 0.
*/
return (0);
}
/*
* Calculate how far we are into this interval.
*/
/*
* Now check to see if we've dealt with the last interval
* yet.
*/
/*
* The last interval hasn't fired; set it_value to 0.
*/
return (0);
}
/*
* The last interval _has_ fired; we can return the amount
* of time left in this interval.
*/
}
return (0);
}
static int
{
/*
* This timer was never fully created; we must have failed
* in the clock_highres_timer_create() routine.
*/
return (0);
}
return (0);
}
static void
{
int pset;
if (cyc == CYCLIC_NONE)
return;
mutex_enter(&p->p_lock);
/*
* Okay, now we can safely look at the bindings.
*/
cpu = t->t_bound_cpu;
pset = t->t_bind_pset;
/*
* Now we drop p_lock. We haven't dropped cpu_lock; we're guaranteed
* that this timer was bound to remain valid (and the combination
* remains self-consistent).
*/
mutex_exit(&p->p_lock);
}
void
{
}