亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ev_timers.c

?? package of develop dns
?? C
字號:
/* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") * 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 ISC DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC 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. *//* 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.2.2.1.4.5 2004/03/17 02:39:13 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 *);static void idle_timeout(evContext, void *, struct timespec, struct timespec);/* Private type. */typedef struct {	evTimerFunc	func;	void *		uap;	struct timespec	lastTouched;	struct timespec	max_idle;	evTimer *	timer;} idle_timer;/* Public. */struct timespecevConsTime(time_t sec, long nsec) {	struct timespec x;	x.tv_sec = sec;	x.tv_nsec = nsec;	return (x);}struct timespecevAddTime(struct timespec addend1, struct timespec addend2) {	struct timespec x;	x.tv_sec = addend1.tv_sec + addend2.tv_sec;	x.tv_nsec = addend1.tv_nsec + addend2.tv_nsec;	if (x.tv_nsec >= BILLION) {		x.tv_sec++;		x.tv_nsec -= BILLION;	}	return (x);}struct timespecevSubTime(struct timespec minuend, struct timespec subtrahend) {	struct timespec x;	x.tv_sec = minuend.tv_sec - subtrahend.tv_sec;	if (minuend.tv_nsec >= subtrahend.tv_nsec)		x.tv_nsec = minuend.tv_nsec - subtrahend.tv_nsec;	else {		x.tv_nsec = BILLION - subtrahend.tv_nsec + minuend.tv_nsec;		x.tv_sec--;	}	return (x);}intevCmpTime(struct timespec a, struct timespec b) {	long x = a.tv_sec - b.tv_sec;	if (x == 0L)		x = a.tv_nsec - b.tv_nsec;	return (x < 0L ? (-1) : x > 0L ? (1) : (0));}struct timespecevNowTime() {	struct timeval now;#ifdef CLOCK_REALTIME	struct timespec tsnow;	int m = CLOCK_REALTIME;#ifdef CLOCK_MONOTONIC	if (__evOptMonoTime)		m = CLOCK_MONOTONIC;#endif	if (clock_gettime(m, &tsnow) == 0)		return (tsnow);#endif	if (gettimeofday(&now, NULL) < 0)		return (evConsTime(0, 0));	return (evTimeSpec(now));}struct timespecevUTCTime() {	struct timeval now;#ifdef CLOCK_REALTIME	struct timespec tsnow;	if (clock_gettime(CLOCK_REALTIME, &tsnow) == 0)		return (tsnow);#endif	if (gettimeofday(&now, NULL) < 0)		return (evConsTime(0, 0));	return (evTimeSpec(now));}struct timespecevLastEventTime(evContext opaqueCtx) {	evContext_p *ctx = opaqueCtx.opaque;	return (ctx->lastEventTime);}struct timespecevTimeSpec(struct timeval tv) {	struct timespec ts;	ts.tv_sec = tv.tv_sec;	ts.tv_nsec = tv.tv_usec * 1000;	return (ts);}struct timevalevTimeVal(struct timespec ts) {	struct timeval tv;	tv.tv_sec = ts.tv_sec;	tv.tv_usec = ts.tv_nsec / 1000;	return (tv);}intevSetTimer(evContext opaqueCtx,	   evTimerFunc func,	   void *uap,	   struct timespec due,	   struct timespec inter,	   evTimerID *opaqueID) {	evContext_p *ctx = opaqueCtx.opaque;	evTimer *id;	evPrintf(ctx, 1,"evSetTimer(ctx %p, func %p, uap %p, due %ld.%09ld, inter %ld.%09ld)\n",		 ctx, func, uap,		 (long)due.tv_sec, due.tv_nsec,		 (long)inter.tv_sec, inter.tv_nsec);#ifdef __hpux	/*	 * tv_sec and tv_nsec are unsigned.	 */	if (due.tv_nsec >= BILLION)		EV_ERR(EINVAL);	if (inter.tv_nsec >= BILLION)		EV_ERR(EINVAL);#else	if (due.tv_sec < 0 || due.tv_nsec < 0 || due.tv_nsec >= BILLION)		EV_ERR(EINVAL);	if (inter.tv_sec < 0 || inter.tv_nsec < 0 || inter.tv_nsec >= BILLION)		EV_ERR(EINVAL);#endif	/* due={0,0} is a magic cookie meaning "now." */	if (due.tv_sec == (time_t)0 && due.tv_nsec == 0L)		due = evNowTime();	/* Allocate and fill. */	OKNEW(id);	id->func = func;	id->uap = uap;	id->due = due;	id->inter = inter;	if (heap_insert(ctx->timers, id) < 0)		return (-1);	/* Remember the ID if the caller provided us a place for it. */	if (opaqueID)		opaqueID->opaque = id;	if (ctx->debug > 7) {		evPrintf(ctx, 7, "timers after evSetTimer:\n");		(void) heap_for_each(ctx->timers, print_timer, (void *)ctx);	}	return (0);}intevClearTimer(evContext opaqueCtx, evTimerID id) {	evContext_p *ctx = opaqueCtx.opaque;	evTimer *del = id.opaque;	if (ctx->cur != NULL &&	    ctx->cur->type == Timer &&	    ctx->cur->u.timer.this == del) {		evPrintf(ctx, 8, "deferring delete of timer (executing)\n");		/*		 * Setting the interval to zero ensures that evDrop() will		 * clean up the timer.		 */		del->inter = evConsTime(0, 0);		return (0);	}	if (heap_element(ctx->timers, del->index) != del)		EV_ERR(ENOENT);	if (heap_delete(ctx->timers, del->index) < 0)		return (-1);	FREE(del);	if (ctx->debug > 7) {		evPrintf(ctx, 7, "timers after evClearTimer:\n");		(void) heap_for_each(ctx->timers, print_timer, (void *)ctx);	}	return (0);}intevConfigTimer(evContext opaqueCtx,	     evTimerID id,	     const char *param,	     int value) {	evContext_p *ctx = opaqueCtx.opaque;	evTimer *timer = id.opaque;	int result=0;	UNUSED(value);	if (heap_element(ctx->timers, timer->index) != timer)		EV_ERR(ENOENT);	if (strcmp(param, "rate") == 0)		timer->mode |= EV_TMR_RATE;	else if (strcmp(param, "interval") == 0)		timer->mode &= ~EV_TMR_RATE;	else		EV_ERR(EINVAL);	return (result);}intevResetTimer(evContext opaqueCtx,	     evTimerID id,	     evTimerFunc func,	     void *uap,	     struct timespec due,	     struct timespec inter) {	evContext_p *ctx = opaqueCtx.opaque;	evTimer *timer = id.opaque;	struct timespec old_due;	int result=0;	if (heap_element(ctx->timers, timer->index) != timer)		EV_ERR(ENOENT);#ifdef __hpux	/*	 * tv_sec and tv_nsec are unsigned.	 */	if (due.tv_nsec >= BILLION)		EV_ERR(EINVAL);	if (inter.tv_nsec >= BILLION)		EV_ERR(EINVAL);#else	if (due.tv_sec < 0 || due.tv_nsec < 0 || due.tv_nsec >= BILLION)		EV_ERR(EINVAL);	if (inter.tv_sec < 0 || inter.tv_nsec < 0 || inter.tv_nsec >= BILLION)		EV_ERR(EINVAL);#endif	old_due = timer->due;	timer->func = func;	timer->uap = uap;	timer->due = due;	timer->inter = inter;	switch (evCmpTime(due, old_due)) {	case -1:		result = heap_increased(ctx->timers, timer->index);		break;	case 0:		result = 0;		break;	case 1:		result = heap_decreased(ctx->timers, timer->index);		break;	}	if (ctx->debug > 7) {		evPrintf(ctx, 7, "timers after evResetTimer:\n");		(void) heap_for_each(ctx->timers, print_timer, (void *)ctx);	}	return (result);}intevSetIdleTimer(evContext opaqueCtx,		evTimerFunc func,		void *uap,		struct timespec max_idle,		evTimerID *opaqueID) {	evContext_p *ctx = opaqueCtx.opaque;	idle_timer *tt;	/* Allocate and fill. */	OKNEW(tt);	tt->func = func;	tt->uap = uap;	tt->lastTouched = ctx->lastEventTime;	tt->max_idle = max_idle;	if (evSetTimer(opaqueCtx, idle_timeout, tt,		       evAddTime(ctx->lastEventTime, max_idle),		       max_idle, opaqueID) < 0) {		FREE(tt);		return (-1);	}	tt->timer = opaqueID->opaque;	return (0);}intevClearIdleTimer(evContext opaqueCtx, evTimerID id) {	evTimer *del = id.opaque;	idle_timer *tt = del->uap;	FREE(tt);	return (evClearTimer(opaqueCtx, id));}intevResetIdleTimer(evContext opaqueCtx,		 evTimerID opaqueID,		 evTimerFunc func,		 void *uap,		 struct timespec max_idle) {	evContext_p *ctx = opaqueCtx.opaque;	evTimer *timer = opaqueID.opaque;	idle_timer *tt = timer->uap;	tt->func = func;	tt->uap = uap;	tt->lastTouched = ctx->lastEventTime;	tt->max_idle = max_idle;	return (evResetTimer(opaqueCtx, opaqueID, idle_timeout, tt,			     evAddTime(ctx->lastEventTime, max_idle),			     max_idle));}intevTouchIdleTimer(evContext opaqueCtx, evTimerID id) {	evContext_p *ctx = opaqueCtx.opaque;	evTimer *t = id.opaque;	idle_timer *tt = t->uap;	tt->lastTouched = ctx->lastEventTime;	return (0);}/* Public to the rest of eventlib. */heap_contextevCreateTimers(const evContext_p *ctx) {	UNUSED(ctx);	return (heap_new(due_sooner, set_index, 2048));}voidevDestroyTimers(const evContext_p *ctx) {	(void) heap_for_each(ctx->timers, free_timer, NULL);	(void) heap_free(ctx->timers);}/* Private. */static intdue_sooner(void *a, void *b) {	evTimer *a_timer, *b_timer;	a_timer = a;	b_timer = b;	return (evCmpTime(a_timer->due, b_timer->due) < 0);}static voidset_index(void *what, int index) {	evTimer *timer;	timer = what;	timer->index = index;}static voidfree_timer(void *what, void *uap) {	evTimer *t = what;	UNUSED(uap);	FREE(t);}static voidprint_timer(void *what, void *uap) {	evTimer *cur = what;	evContext_p *ctx = uap;	cur = what;	evPrintf(ctx, 7,	    "  func %p, uap %p, due %ld.%09ld, inter %ld.%09ld\n",		 cur->func, cur->uap,		 (long)cur->due.tv_sec, cur->due.tv_nsec,		 (long)cur->inter.tv_sec, cur->inter.tv_nsec);}static voididle_timeout(evContext opaqueCtx,	     void *uap,	     struct timespec due,	     struct timespec inter) {	evContext_p *ctx = opaqueCtx.opaque;	idle_timer *this = uap;	struct timespec idle;	UNUSED(due);	UNUSED(inter);		idle = evSubTime(ctx->lastEventTime, this->lastTouched);	if (evCmpTime(idle, this->max_idle) >= 0) {		(this->func)(opaqueCtx, this->uap, this->timer->due,			     this->max_idle);		/*		 * Setting the interval to zero will cause the timer to		 * be cleaned up in evDrop().		 */		this->timer->inter = evConsTime(0, 0);		FREE(this);	} else {		/* evDrop() will reschedule the timer. */		this->timer->inter = evSubTime(this->max_idle, idle);	}}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
美国欧美日韩国产在线播放| 欧美一区二区网站| 欧美日韩国产精品成人| 国产午夜精品福利| 午夜激情综合网| 成人aaaa免费全部观看| 日韩欧美卡一卡二| 亚洲图片一区二区| 94色蜜桃网一区二区三区| 337p粉嫩大胆噜噜噜噜噜91av| 亚洲人成影院在线观看| 国产精品自拍一区| 日韩女同互慰一区二区| 午夜精品免费在线观看| 99久久免费精品| 国产日韩av一区二区| 麻豆精品视频在线观看视频| 色欧美88888久久久久久影院| 日本一区二区综合亚洲| 国产精品中文字幕欧美| 日韩精品一区二区三区swag| 日韩不卡免费视频| 欧美高清一级片在线| 亚洲制服丝袜av| 91成人在线免费观看| 一区二区三区在线视频免费观看| 国产成人精品免费一区二区| 欧美岛国在线观看| 老司机精品视频在线| 日韩一区二区三区三四区视频在线观看 | 91久久精品日日躁夜夜躁欧美| 久久久久九九视频| 国产精品一二三| 国产色产综合色产在线视频| 国产成人欧美日韩在线电影| 久久久久久99精品| 白白色亚洲国产精品| 国产精品色呦呦| 成人av免费网站| 亚洲欧美日韩在线| 91成人在线观看喷潮| 亚洲高清免费观看高清完整版在线观看| 99精品在线免费| 亚洲精品免费播放| 欧美精品1区2区3区| 久热成人在线视频| 国产欧美日韩卡一| 99麻豆久久久国产精品免费| 亚洲欧美电影一区二区| 欧美日韩国产综合草草| 免费一级欧美片在线观看| 日韩免费性生活视频播放| 国产精品一区二区在线观看不卡| 日本一区二区成人在线| 91视频com| 免费日本视频一区| 精品乱人伦一区二区三区| 懂色av一区二区夜夜嗨| 一区二区三区在线观看国产| 3atv在线一区二区三区| 国产一区在线精品| 亚洲精品免费视频| 欧美v日韩v国产v| caoporn国产精品| 视频在线观看一区| 欧美国产综合一区二区| 91国模大尺度私拍在线视频| 久久99国产精品尤物| 国产精品久久久久久福利一牛影视 | 国产一区二区三区免费看| 国产精品久久精品日日| 91精品在线一区二区| 懂色中文一区二区在线播放| 午夜国产不卡在线观看视频| 欧美高清一级片在线观看| 91精品视频网| 91丨porny丨国产入口| 免费看欧美女人艹b| 亚洲免费在线电影| 国产三级一区二区| 欧美日韩国产另类一区| 菠萝蜜视频在线观看一区| 免费看欧美美女黄的网站| 亚洲欧美日韩中文字幕一区二区三区| 日韩免费高清av| 欧美在线啊v一区| 国产高清久久久| 日本欧美一区二区三区乱码| 亚洲三级久久久| 久久精品视频在线看| 欧美丰满一区二区免费视频 | 免费观看成人av| 亚洲一级二级三级在线免费观看| 国产欧美日韩在线视频| 欧美一区二区三区小说| 91行情网站电视在线观看高清版| 国产一区视频导航| 久久精品国产澳门| 日韩制服丝袜av| 亚洲免费av观看| **欧美大码日韩| 国产清纯在线一区二区www| 日韩一区二区在线看| 欧美精品久久天天躁| 欧洲在线/亚洲| 97se亚洲国产综合自在线不卡 | 国产精品丝袜一区| 欧美zozozo| 26uuu另类欧美亚洲曰本| 6080yy午夜一二三区久久| 色又黄又爽网站www久久| 91在线观看高清| 99国产一区二区三精品乱码| 波多野结衣一区二区三区 | 在线这里只有精品| 91麻豆精东视频| 色女孩综合影院| 欧美亚洲高清一区| 欧美日韩久久不卡| 欧美一区二区视频观看视频| 欧美日韩午夜影院| 欧美日韩亚洲综合| 在线播放日韩导航| 91精品婷婷国产综合久久| 91精品国产91久久综合桃花| 欧美日韩国产首页| 日韩丝袜美女视频| 久久免费看少妇高潮| 国产精品日产欧美久久久久| 亚洲欧美国产毛片在线| 亚洲自拍欧美精品| 日韩电影在线免费观看| 看片的网站亚洲| 高清shemale亚洲人妖| 93久久精品日日躁夜夜躁欧美| 在线观看免费一区| 91精品国产综合久久久久| 欧美videos中文字幕| 国产目拍亚洲精品99久久精品| 亚洲人成网站影音先锋播放| 无码av免费一区二区三区试看| 麻豆精品一区二区av白丝在线| 国产成人h网站| 欧美在线免费观看亚洲| 精品美女一区二区| 国产精品电影一区二区三区| 亚洲成人激情综合网| 久久国产福利国产秒拍| 99视频精品免费视频| 欧美久久婷婷综合色| 国产三级三级三级精品8ⅰ区| 亚洲精品免费在线| 韩国欧美国产1区| 95精品视频在线| 日韩三级免费观看| 亚洲老司机在线| 国内久久婷婷综合| 欧美日韩视频第一区| 中文字幕巨乱亚洲| 日本午夜精品一区二区三区电影| 国产成人综合在线| 欧美日韩亚洲综合一区 | 国产99久久久国产精品免费看| 在线看国产一区二区| 久久久国产精华| 日本亚洲最大的色成网站www| av电影在线不卡| 久久无码av三级| 日韩电影免费在线| 91国产福利在线| 久久久综合网站| 免费高清在线一区| 欧美日韩午夜在线视频| 成人欧美一区二区三区在线播放| 九九九精品视频| 精品视频一区三区九区| 中文字幕欧美日本乱码一线二线| 日韩av电影一区| 欧美视频中文字幕| 国产精品电影一区二区三区| 国产毛片精品一区| 日韩亚洲国产中文字幕欧美| 亚洲欧美在线视频| 国产91在线看| 久久精品欧美一区二区三区麻豆 | 亚洲一区二区在线免费观看视频 | 最新成人av在线| 成人精品gif动图一区| 日韩免费视频一区| 免播放器亚洲一区| 欧美精品xxxxbbbb| 亚洲五月六月丁香激情| 色天天综合色天天久久| 亚洲精品久久久蜜桃| 成+人+亚洲+综合天堂| 国产精品萝li| 99国产精品久久| 亚洲你懂的在线视频| 欧美中文字幕一区二区三区亚洲| 一区二区在线电影|