ev_timers.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 1995-1999 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* ev_timers.c - implement timers for the eventlib
* vix 09sep95 [initial]
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: ev_timers.c,v 1.33 2002/07/08 05:50:09 marka Exp $";
#endif
/* Import. */
#include "port_before.h"
#include "fd_setsize.h"
#include <errno.h>
#include <isc/assertions.h>
#include <isc/eventlib.h>
#include "eventlib_p.h"
#include "port_after.h"
/* Constants. */
#define MILLION 1000000
#define BILLION 1000000000
/* Forward. */
static int due_sooner(void *, void *);
static void set_index(void *, int);
static void free_timer(void *, void *);
static void print_timer(void *, void *);
/* Private type. */
typedef struct {
void * uap;
struct timespec lastTouched;
} idle_timer;
/* Public. */
struct timespec
struct timespec x;
return (x);
}
struct timespec
struct timespec x;
x.tv_sec++;
}
return (x);
}
struct timespec
struct timespec x;
else {
x.tv_sec--;
}
return (x);
}
int
if (x == 0L)
return (x < 0L ? (-1) : x > 0L ? (1) : (0));
}
struct timespec
evNowTime() {
return (evConsTime(0, 0));
return (evTimeSpec(now));
}
struct timespec
return (ctx->lastEventTime);
}
struct timespec
return (ts);
}
struct timeval
return (tv);
}
int
void *uap,
) {
"evSetTimer(ctx %p, func %p, uap %p, due %ld.%09ld, inter %ld.%09ld)\n",
/* due={0,0} is a magic cookie meaning "now." */
/* Allocate and fill. */
return (-1);
/* Remember the ID if the caller provided us a place for it. */
if (opaqueID)
}
return (0);
}
int
/*
* Setting the interval to zero ensures that evDrop() will
* clean up the timer.
*/
return (0);
}
return (-1);
}
return (0);
}
int
void *uap,
) {
int result=0;
case -1:
break;
case 0:
result = 0;
break;
case 1:
break;
}
}
return (result);
}
int
void *uap,
) {
idle_timer *tt;
/* Allocate and fill. */
return (-1);
}
return (0);
}
int
}
int
void *uap,
) {
max_idle));
}
int
return (0);
}
/* Public to the rest of eventlib. */
}
void
}
/* Private. */
static int
due_sooner(void *a, void *b) {
a_timer = a;
b_timer = b;
}
static void
}
static void
FREE(t);
}
static void
" func %p, uap %p, due %ld.%09ld, inter %ld.%09ld\n",
}
static void
void *uap,
) {
/*
* Setting the interval to zero will cause the timer to
* be cleaned up in evDrop().
*/
} else {
/* evDrop() will reschedule the timer. */
}
}