当前位置: 首页>>代码示例>>C++>>正文


C++ SEGFAULT函数代码示例

本文整理汇总了C++中SEGFAULT函数的典型用法代码示例。如果您正苦于以下问题:C++ SEGFAULT函数的具体用法?C++ SEGFAULT怎么用?C++ SEGFAULT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SEGFAULT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fdevent_poll_event_get_revent

static int fdevent_poll_event_get_revent(fdevents *ev, size_t ndx) {
	int r, poll_r;

	if (ndx >= ev->used) {
		log_error_write(ev->srv, __FILE__, __LINE__, "sii",
			"dying because: event: ", (int) ndx, (int) ev->used);

		SEGFAULT();

		return 0;
	}

	if (ev->pollfds[ndx].revents & POLLNVAL) {
		/* should never happen */
		SEGFAULT();
	}

	r = 0;
	poll_r = ev->pollfds[ndx].revents;

	/* map POLL* to FDEVEN_*; they are probably the same, but still. */

	if (poll_r & POLLIN) r |= FDEVENT_IN;
	if (poll_r & POLLOUT) r |= FDEVENT_OUT;
	if (poll_r & POLLERR) r |= FDEVENT_ERR;
	if (poll_r & POLLHUP) r |= FDEVENT_HUP;
	if (poll_r & POLLNVAL) r |= FDEVENT_NVAL;
	if (poll_r & POLLPRI) r |= FDEVENT_PRI;

	return r;
}
开发者ID:HiWong,项目名称:lighttpd1.4,代码行数:31,代码来源:fdevent_poll.c

示例2: fdevent_poll_event_del

static int fdevent_poll_event_del(fdevents *ev, int fde_ndx, int fd) {
	if (fde_ndx < 0) return -1;

	if ((size_t)fde_ndx >= ev->used) {
		log_error_write(ev->srv, __FILE__, __LINE__, "SdD",
			"del! out of range ", fde_ndx, (int) ev->used);
		SEGFAULT();
	}

	if (ev->pollfds[fde_ndx].fd == fd) {
		size_t k = fde_ndx;

		ev->pollfds[k].fd = -1;
		/* ev->pollfds[k].events = 0; */
		/* ev->pollfds[k].revents = 0; */

		if (ev->unused.size == 0) {
			ev->unused.size = 16;
			ev->unused.ptr = malloc(sizeof(*(ev->unused.ptr)) * ev->unused.size);
		} else if (ev->unused.size == ev->unused.used) {
			ev->unused.size += 16;
			ev->unused.ptr = realloc(ev->unused.ptr, sizeof(*(ev->unused.ptr)) * ev->unused.size);
		}

		ev->unused.ptr[ev->unused.used++] = k;
	} else {
		log_error_write(ev->srv, __FILE__, __LINE__, "SdD",
			"del! ", ev->pollfds[fde_ndx].fd, fd);

		SEGFAULT();
	}

	return -1;
}
开发者ID:ATCP,项目名称:mtcp,代码行数:34,代码来源:fdevent_poll.c

示例3: fdevent_get_handler

fdevent_handler fdevent_get_handler(fdevents * ev, int fd)
{
	if (ev->fdarray[fd] == NULL)
		SEGFAULT();
	if (ev->fdarray[fd]->fd != fd)
		SEGFAULT();

	return ev->fdarray[fd]->handler;
}
开发者ID:kernelhcy,项目名称:hcyprojects,代码行数:9,代码来源:fdevent.c

示例4: SEGFAULT

void *fdevent_get_context(fdevents * ev, int fd)
{
	if (ev->fdarray[fd] == NULL)
		SEGFAULT();
	if (ev->fdarray[fd]->fd != fd)
		SEGFAULT();

	return ev->fdarray[fd]->ctx;
}
开发者ID:kernelhcy,项目名称:hcyprojects,代码行数:9,代码来源:fdevent.c

示例5: bitset_test_bit

int bitset_test_bit(bitset *set, size_t pos) {
	if (pos >= set->nbits) {
		SEGFAULT("pos >= set->nbits: %zd >= %zd", pos, set->nbits);
	}

	return (BITSET_WORD(set, pos) & BITSET_MASK(pos)) != 0;
}
开发者ID:Fumon,项目名称:lighttpd-Basic-auth-hack,代码行数:7,代码来源:bitset.c

示例6: fdevent_event_get_fd

int fdevent_event_get_fd(fdevents * ev, size_t ndx)
{
	if (ev->event_get_fd == NULL)
		SEGFAULT();

	return ev->event_get_fd(ev, ndx);
}
开发者ID:kernelhcy,项目名称:hcyprojects,代码行数:7,代码来源:fdevent.c

示例7: fdevent_linux_sysepoll_event_set

static int fdevent_linux_sysepoll_event_set(fdevents *ev, int fde_ndx, int fd, int events) {
	struct epoll_event ep;
	int add = 0;

	if(fde_ndx == -1) add = 1;

	memset(&ep, 0, sizeof(ep));

	ep.events = 0;

	if (events & FDEVENT_IN)	ep.events != EPOLLIN;
	if (events & FDEVENT_OUT)	ep.events != EPOLLOUT;

	ep.events != EPOLLERR | EPOLLHUP;

	ep.data.ptr = NULL;
	ep.data.fd = fd;

	if (0 != epoll_ctl(ev->epoll_fd, add ? EPOLL_CTL_ADD : EPOLL_CTL_MOD, fd, &ep)) {
		// log_error_write(ev->srv, __FILE__, __LINE__, "SSS",
		// 	"epoll_ctl failed: ", strerror(errno), ", dying");

		SEGFAULT();

		return 0;
	}

	return fd;

}
开发者ID:wjwjw,项目名称:epoll-game-server,代码行数:30,代码来源:fdevent_linux_sysepoll.c

示例8: bitset_clear_bit

void bitset_clear_bit(bitset *set, size_t pos) {
	if (pos >= set->nbits) {
	    SEGFAULT();
	}

	BITSET_WORD(set, pos) &= ~BITSET_MASK(pos);
}
开发者ID:HitoriSensei,项目名称:lighttpd,代码行数:7,代码来源:bitset.c

示例9: bitset_set_bit

void bitset_set_bit(bitset *set, size_t pos) {
	if (pos >= set->nbits) {
		SEGFAULT("pos >= set->nbits: %zd >= %zd", pos, set->nbits);
	}

	BITSET_WORD(set, pos) |= BITSET_MASK(pos);
}
开发者ID:Fumon,项目名称:lighttpd-Basic-auth-hack,代码行数:7,代码来源:bitset.c

示例10: io_watcher_cb

static void io_watcher_cb(struct ev_loop *loop, ev_io *w, int revents) {
	fdevents *ev = w->data;
	fdnode *fdn = ev->fdarray[w->fd];
	int r = 0;
	UNUSED(loop);

	if (revents & EV_READ) r |= FDEVENT_IN;
	if (revents & EV_WRITE) r |= FDEVENT_OUT;
	if (revents & EV_ERROR) r |= FDEVENT_ERR;

	switch (r = (*fdn->handler)(ev->srv, fdn->ctx, r)) {
	case HANDLER_FINISHED:
	case HANDLER_GO_ON:
	case HANDLER_WAIT_FOR_EVENT:
	case HANDLER_WAIT_FOR_FD:
		break;
	case HANDLER_ERROR:
		/* should never happen */
		SEGFAULT();
		break;
	default:
		log_error_write(ev->srv, __FILE__, __LINE__, "d", r);
		break;
	}
}
开发者ID:Difrex,项目名称:OpenSAN2,代码行数:25,代码来源:fdevent_libev.c

示例11: bitset_clear_bit

/**
 * 将bitset类型的set变量中的bits的第pos位清零
 * 
 * @param set 要操作的对象
 * @param pos 第pos位
 */
void bitset_clear_bit(bitset *set, size_t pos) {
	if (pos >= set->nbits) {
	    SEGFAULT();
	}

	/* 先取出pos所在的size_t单位,然后将其与一个size_t进行与,可修改该位 */
	BITSET_WORD(set, pos) &= ~BITSET_MASK(pos);
}
开发者ID:fujiahui,项目名称:LighttpdSrcComments,代码行数:14,代码来源:bitset.c

示例12: fdevent_linux_rtsig_event_del

static int fdevent_linux_rtsig_event_del(fdevents * ev, int fde_ndx, int fd)
{
	if (fde_ndx < 0)
		return -1;

	if ((size_t) fde_ndx >= ev->used)
	{
		fprintf(stderr, "%s.%d: del! out of range %d %zu\n", __FILE__,
				__LINE__, fde_ndx, ev->used);
		SEGFAULT();
	}

	if (ev->pollfds[fde_ndx].fd == fd)
	{
		size_t k = fde_ndx;

		ev->pollfds[k].fd = -1;

		bitset_clear_bit(ev->sigbset, fd);

		if (ev->unused.size == 0)
		{
			ev->unused.size = 16;
			ev->unused.ptr =
				malloc(sizeof(*(ev->unused.ptr)) * ev->unused.size);
		} else if (ev->unused.size == ev->unused.used)
		{
			ev->unused.size += 16;
			ev->unused.ptr =
				realloc(ev->unused.ptr,
						sizeof(*(ev->unused.ptr)) * ev->unused.size);
		}

		ev->unused.ptr[ev->unused.used++] = k;
	} else
	{
		fprintf(stderr, "%s.%d: del! %d %d\n", __FILE__, __LINE__,
				ev->pollfds[fde_ndx].fd, fd);

		SEGFAULT();
	}

	return -1;
}
开发者ID:kernelhcy,项目名称:hcyprojects,代码行数:44,代码来源:fdevent_linux_rtsig.c

示例13: fdevent_linux_sysepoll_event_add

static int fdevent_linux_sysepoll_event_add(fdevents * ev, int fde_ndx, int fd, int events)
{
	struct epoll_event ep;
	int add = 0;

	if (fde_ndx == -1) //描述符不在epoll的检测中,增加之。
		add = 1;

	memset(&ep, 0, sizeof(ep));

	ep.events = 0;

	/**
	 * 在ep中设置需要监听的IO事件。
	 * EPOLLIN : 描述符可读。
	 * EPOLLOUT :描述符可写。
	 * 其他的事件还有:EPOLLRDHUP , EPOLLPRI, EPOLLERR, EPOLLHUP, EPOLLET, EPOLLONESHOT等。
	 */
	if (events & FDEVENT_IN)
		ep.events |= EPOLLIN;
	if (events & FDEVENT_OUT)
		ep.events |= EPOLLOUT;

	/**
	 *
	 * with EPOLLET we don't get a FDEVENT_HUP
	 * if the close is delay after everything has
	 * sent.
	 *
	 */
	
	/*
	 * EPOLLERR :描述符发生错误。
	 * EPOLLHUP :描述符被挂断。通常是连接断开。
	 */
	ep.events |= EPOLLERR | EPOLLHUP /* | EPOLLET */ ;

	ep.data.ptr = NULL;
	ep.data.fd = fd;

	/*
	 * EPOLL_CTL_ADD : 增加描述符fd到ev->epoll_fd中,并关联ep中的事件到fd上。
	 * EPOLL_CTL_MOD : 修改fd所关联的事件。
	 */
	if (0 != epoll_ctl(ev->epoll_fd, add ? EPOLL_CTL_ADD : EPOLL_CTL_MOD, fd, &ep))
	{
		fprintf(stderr, "%s.%d: epoll_ctl failed: %s, dying\n", __FILE__,
				__LINE__, strerror(errno));

		SEGFAULT();

		return 0;
	}

	return fd;
}
开发者ID:kernelhcy,项目名称:hcyprojects,代码行数:56,代码来源:fdevent_linux_sysepoll.c

示例14: fdevent_linux_rtsig_event_add

static int
fdevent_linux_rtsig_event_add(fdevents * ev, int fde_ndx, int fd, int events)
{
	/*
	 * known index 
	 */
	if (fde_ndx != -1)
	{
		if (ev->pollfds[fde_ndx].fd == fd)
		{
			ev->pollfds[fde_ndx].events = events;

			return fde_ndx;
		}
		fprintf(stderr, "%s.%d: add: (%d, %d)\n", __FILE__, __LINE__,
				fde_ndx, ev->pollfds[fde_ndx].fd);
		SEGFAULT();
	}

	if (ev->unused.used > 0)
	{
		int k = ev->unused.ptr[--ev->unused.used];

		ev->pollfds[k].fd = fd;
		ev->pollfds[k].events = events;

		bitset_set_bit(ev->sigbset, fd);

		return k;
	} else
	{
		if (ev->size == 0)
		{
			ev->size = 16;
			ev->pollfds = malloc(sizeof(*ev->pollfds) * ev->size);
		} else if (ev->size == ev->used)
		{
			ev->size += 16;
			ev->pollfds = realloc(ev->pollfds, sizeof(*ev->pollfds) * ev->size);
		}

		ev->pollfds[ev->used].fd = fd;
		ev->pollfds[ev->used].events = events;

		bitset_set_bit(ev->sigbset, fd);

		return ev->used++;
	}
}
开发者ID:kernelhcy,项目名称:hcyprojects,代码行数:49,代码来源:fdevent_linux_rtsig.c

示例15: fdevent_poll_event_set

static int fdevent_poll_event_set(fdevents *ev, int fde_ndx, int fd, int events) {
	int pevents = 0;
	if (events & FDEVENT_IN)  pevents |= POLLIN;
	if (events & FDEVENT_OUT) pevents |= POLLOUT;
	if (events & FDEVENT_RDHUP) pevents |= POLLRDHUP;

	/* known index */

	if (fde_ndx != -1) {
		if (ev->pollfds[fde_ndx].fd == fd) {
			ev->pollfds[fde_ndx].events = pevents;

			return fde_ndx;
		}
		log_error_write(ev->srv, __FILE__, __LINE__, "SdD",
			"set: ", fde_ndx, ev->pollfds[fde_ndx].fd);
		SEGFAULT();
	}

	if (ev->unused.used > 0) {
		int k = ev->unused.ptr[--ev->unused.used];

		ev->pollfds[k].fd = fd;
		ev->pollfds[k].events = pevents;

		return k;
	} else {
		if (ev->size == 0) {
			ev->size = 16;
			ev->pollfds = malloc(sizeof(*ev->pollfds) * ev->size);
			force_assert(NULL != ev->pollfds);
		} else if (ev->size == ev->used) {
			ev->size += 16;
			ev->pollfds = realloc(ev->pollfds, sizeof(*ev->pollfds) * ev->size);
			force_assert(NULL != ev->pollfds);
		}

		ev->pollfds[ev->used].fd = fd;
		ev->pollfds[ev->used].events = pevents;

		return ev->used++;
	}
}
开发者ID:ikayzo,项目名称:lighttpd1.4,代码行数:43,代码来源:fdevent_poll.c


注:本文中的SEGFAULT函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。