Add a callout_func_t typedef for functions used with callout_*().
This typedef is the same as timeout_t except that it is in the callout namespace and header. Use this typedef in various places of the callout implementation that were either using the raw type or timeout_t. While here, add <sys/callout.h> to the manpage. Reviewed by: kib, imp MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D22751
This commit is contained in:
parent
80e05761c1
commit
4c2c5f1a8a
@ -29,7 +29,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd July 27, 2016
|
.Dd December 10, 2019
|
||||||
.Dt TIMEOUT 9
|
.Dt TIMEOUT 9
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -62,8 +62,10 @@
|
|||||||
.Nd execute a function after a specified length of time
|
.Nd execute a function after a specified length of time
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.In sys/types.h
|
.In sys/types.h
|
||||||
|
.In sys/callout.h
|
||||||
.In sys/systm.h
|
.In sys/systm.h
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
|
typedef void callout_func_t (void *);
|
||||||
typedef void timeout_t (void *);
|
typedef void timeout_t (void *);
|
||||||
.Ed
|
.Ed
|
||||||
.Ft int
|
.Ft int
|
||||||
@ -71,7 +73,7 @@ typedef void timeout_t (void *);
|
|||||||
.Ft void
|
.Ft void
|
||||||
.Fn callout_deactivate "struct callout *c"
|
.Fn callout_deactivate "struct callout *c"
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn callout_async_drain "struct callout *c" "timeout_t *drain"
|
.Fn callout_async_drain "struct callout *c" "callout_func_t *drain"
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn callout_drain "struct callout *c"
|
.Fn callout_drain "struct callout *c"
|
||||||
.Ft void
|
.Ft void
|
||||||
@ -90,19 +92,24 @@ struct callout_handle handle = CALLOUT_HANDLE_INITIALIZER(&handle);
|
|||||||
.Ft int
|
.Ft int
|
||||||
.Fn callout_pending "struct callout *c"
|
.Fn callout_pending "struct callout *c"
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn callout_reset "struct callout *c" "int ticks" "timeout_t *func" "void *arg"
|
.Fo callout_reset
|
||||||
|
.Fa "struct callout *c"
|
||||||
|
.Fa "int ticks"
|
||||||
|
.Fa "callout_func_t *func"
|
||||||
|
.Fa "void *arg"
|
||||||
|
.Fc
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fo callout_reset_curcpu
|
.Fo callout_reset_curcpu
|
||||||
.Fa "struct callout *c"
|
.Fa "struct callout *c"
|
||||||
.Fa "int ticks"
|
.Fa "int ticks"
|
||||||
.Fa "timeout_t *func"
|
.Fa "callout_func_t *func"
|
||||||
.Fa "void *arg"
|
.Fa "void *arg"
|
||||||
.Fc
|
.Fc
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fo callout_reset_on
|
.Fo callout_reset_on
|
||||||
.Fa "struct callout *c"
|
.Fa "struct callout *c"
|
||||||
.Fa "int ticks"
|
.Fa "int ticks"
|
||||||
.Fa "timeout_t *func"
|
.Fa "callout_func_t *func"
|
||||||
.Fa "void *arg"
|
.Fa "void *arg"
|
||||||
.Fa "int cpu"
|
.Fa "int cpu"
|
||||||
.Fc
|
.Fc
|
||||||
@ -111,7 +118,7 @@ struct callout_handle handle = CALLOUT_HANDLE_INITIALIZER(&handle);
|
|||||||
.Fa "struct callout *c"
|
.Fa "struct callout *c"
|
||||||
.Fa "sbintime_t sbt"
|
.Fa "sbintime_t sbt"
|
||||||
.Fa "sbintime_t pr"
|
.Fa "sbintime_t pr"
|
||||||
.Fa "timeout_t *func"
|
.Fa "callout_func_t *func"
|
||||||
.Fa "void *arg"
|
.Fa "void *arg"
|
||||||
.Fa "int flags"
|
.Fa "int flags"
|
||||||
.Fc
|
.Fc
|
||||||
@ -120,7 +127,7 @@ struct callout_handle handle = CALLOUT_HANDLE_INITIALIZER(&handle);
|
|||||||
.Fa "struct callout *c"
|
.Fa "struct callout *c"
|
||||||
.Fa "sbintime_t sbt"
|
.Fa "sbintime_t sbt"
|
||||||
.Fa "sbintime_t pr"
|
.Fa "sbintime_t pr"
|
||||||
.Fa "timeout_t *func"
|
.Fa "callout_func_t *func"
|
||||||
.Fa "void *arg"
|
.Fa "void *arg"
|
||||||
.Fa "int flags"
|
.Fa "int flags"
|
||||||
.Fc
|
.Fc
|
||||||
@ -129,7 +136,7 @@ struct callout_handle handle = CALLOUT_HANDLE_INITIALIZER(&handle);
|
|||||||
.Fa "struct callout *c"
|
.Fa "struct callout *c"
|
||||||
.Fa "sbintime_t sbt"
|
.Fa "sbintime_t sbt"
|
||||||
.Fa "sbintime_t pr"
|
.Fa "sbintime_t pr"
|
||||||
.Fa "timeout_t *func"
|
.Fa "callout_func_t *func"
|
||||||
.Fa "void *arg"
|
.Fa "void *arg"
|
||||||
.Fa "int cpu"
|
.Fa "int cpu"
|
||||||
.Fa "int flags"
|
.Fa "int flags"
|
||||||
|
@ -145,11 +145,11 @@ static u_int __read_mostly callwheelmask;
|
|||||||
*/
|
*/
|
||||||
struct cc_exec {
|
struct cc_exec {
|
||||||
struct callout *cc_curr;
|
struct callout *cc_curr;
|
||||||
void (*cc_drain)(void *);
|
callout_func_t *cc_drain;
|
||||||
void *cc_last_func;
|
void *cc_last_func;
|
||||||
void *cc_last_arg;
|
void *cc_last_arg;
|
||||||
#ifdef SMP
|
#ifdef SMP
|
||||||
void (*ce_migration_func)(void *);
|
callout_func_t *ce_migration_func;
|
||||||
void *ce_migration_arg;
|
void *ce_migration_arg;
|
||||||
sbintime_t ce_migration_time;
|
sbintime_t ce_migration_time;
|
||||||
sbintime_t ce_migration_prec;
|
sbintime_t ce_migration_prec;
|
||||||
@ -656,7 +656,7 @@ softclock_call_cc(struct callout *c, struct callout_cpu *cc,
|
|||||||
int direct)
|
int direct)
|
||||||
{
|
{
|
||||||
struct rm_priotracker tracker;
|
struct rm_priotracker tracker;
|
||||||
void (*c_func)(void *);
|
callout_func_t *c_func, *drain;
|
||||||
void *c_arg;
|
void *c_arg;
|
||||||
struct lock_class *class;
|
struct lock_class *class;
|
||||||
struct lock_object *c_lock;
|
struct lock_object *c_lock;
|
||||||
@ -664,7 +664,7 @@ softclock_call_cc(struct callout *c, struct callout_cpu *cc,
|
|||||||
int c_iflags;
|
int c_iflags;
|
||||||
#ifdef SMP
|
#ifdef SMP
|
||||||
struct callout_cpu *new_cc;
|
struct callout_cpu *new_cc;
|
||||||
void (*new_func)(void *);
|
callout_func_t *new_func;
|
||||||
void *new_arg;
|
void *new_arg;
|
||||||
int flags, new_cpu;
|
int flags, new_cpu;
|
||||||
sbintime_t new_prec, new_time;
|
sbintime_t new_prec, new_time;
|
||||||
@ -673,7 +673,7 @@ softclock_call_cc(struct callout *c, struct callout_cpu *cc,
|
|||||||
sbintime_t sbt1, sbt2;
|
sbintime_t sbt1, sbt2;
|
||||||
struct timespec ts2;
|
struct timespec ts2;
|
||||||
static sbintime_t maxdt = 2 * SBT_1MS; /* 2 msec */
|
static sbintime_t maxdt = 2 * SBT_1MS; /* 2 msec */
|
||||||
static timeout_t *lastfunc;
|
static callout_func_t *lastfunc;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
KASSERT((c->c_iflags & CALLOUT_PENDING) == CALLOUT_PENDING,
|
KASSERT((c->c_iflags & CALLOUT_PENDING) == CALLOUT_PENDING,
|
||||||
@ -768,8 +768,6 @@ skip:
|
|||||||
KASSERT(cc_exec_curr(cc, direct) == c, ("mishandled cc_curr"));
|
KASSERT(cc_exec_curr(cc, direct) == c, ("mishandled cc_curr"));
|
||||||
cc_exec_curr(cc, direct) = NULL;
|
cc_exec_curr(cc, direct) = NULL;
|
||||||
if (cc_exec_drain(cc, direct)) {
|
if (cc_exec_drain(cc, direct)) {
|
||||||
void (*drain)(void *);
|
|
||||||
|
|
||||||
drain = cc_exec_drain(cc, direct);
|
drain = cc_exec_drain(cc, direct);
|
||||||
cc_exec_drain(cc, direct) = NULL;
|
cc_exec_drain(cc, direct) = NULL;
|
||||||
CC_UNLOCK(cc);
|
CC_UNLOCK(cc);
|
||||||
@ -1031,7 +1029,7 @@ callout_when(sbintime_t sbt, sbintime_t precision, int flags,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
callout_reset_sbt_on(struct callout *c, sbintime_t sbt, sbintime_t prec,
|
callout_reset_sbt_on(struct callout *c, sbintime_t sbt, sbintime_t prec,
|
||||||
void (*ftn)(void *), void *arg, int cpu, int flags)
|
callout_func_t *ftn, void *arg, int cpu, int flags)
|
||||||
{
|
{
|
||||||
sbintime_t to_sbt, precision;
|
sbintime_t to_sbt, precision;
|
||||||
struct callout_cpu *cc;
|
struct callout_cpu *cc;
|
||||||
@ -1190,7 +1188,7 @@ callout_schedule(struct callout *c, int to_ticks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_callout_stop_safe(struct callout *c, int flags, void (*drain)(void *))
|
_callout_stop_safe(struct callout *c, int flags, callout_func_t *drain)
|
||||||
{
|
{
|
||||||
struct callout_cpu *cc, *old_cc;
|
struct callout_cpu *cc, *old_cc;
|
||||||
struct lock_class *class;
|
struct lock_class *class;
|
||||||
|
@ -48,6 +48,8 @@ LIST_HEAD(callout_list, callout);
|
|||||||
SLIST_HEAD(callout_slist, callout);
|
SLIST_HEAD(callout_slist, callout);
|
||||||
TAILQ_HEAD(callout_tailq, callout);
|
TAILQ_HEAD(callout_tailq, callout);
|
||||||
|
|
||||||
|
typedef void callout_func_t(void *);
|
||||||
|
|
||||||
struct callout {
|
struct callout {
|
||||||
union {
|
union {
|
||||||
LIST_ENTRY(callout) le;
|
LIST_ENTRY(callout) le;
|
||||||
@ -57,7 +59,7 @@ struct callout {
|
|||||||
sbintime_t c_time; /* ticks to the event */
|
sbintime_t c_time; /* ticks to the event */
|
||||||
sbintime_t c_precision; /* delta allowed wrt opt */
|
sbintime_t c_precision; /* delta allowed wrt opt */
|
||||||
void *c_arg; /* function argument */
|
void *c_arg; /* function argument */
|
||||||
void (*c_func)(void *); /* function to call */
|
callout_func_t *c_func; /* function to call */
|
||||||
struct lock_object *c_lock; /* lock to handle */
|
struct lock_object *c_lock; /* lock to handle */
|
||||||
short c_flags; /* User State */
|
short c_flags; /* User State */
|
||||||
short c_iflags; /* Internal State */
|
short c_iflags; /* Internal State */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user