chromium/third_party/libevent/event.c

/*
 * Copyright (c) 2000-2004 Niels Provos <[email protected]>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#endif
#include <sys/types.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else 
#include <sys/_libevent_time.h>
#endif
#include <sys/queue.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include <errno.h>
#include <signal.h>
#include <string.h>
#include <assert.h>
#include <time.h>

#include "event.h"
#include "event-internal.h"
#include "evutil.h"
#include "log.h"

#ifdef HAVE_EVENT_PORTS
extern const struct eventop evportops;
#endif
#ifdef HAVE_SELECT
extern const struct eventop selectops;
#endif
#ifdef HAVE_POLL
extern const struct eventop pollops;
#endif
#ifdef HAVE_EPOLL
extern const struct eventop epollops;
#endif
#ifdef HAVE_WORKING_KQUEUE
extern const struct eventop kqops;
#endif
#ifdef HAVE_DEVPOLL
extern const struct eventop devpollops;
#endif
#ifdef WIN32
extern const struct eventop win32ops;
#endif

/* In order of preference */
static const struct eventop *eventops[] =;

/* Global state */
struct event_base *current_base =;
extern struct event_base *evsignal_base;
static int use_monotonic =;

/* Prototypes */
static void	event_queue_insert(struct event_base *, struct event *, int);
static void	event_queue_remove(struct event_base *, struct event *, int);
static int	event_haveevents(struct event_base *);

static void	event_process_active(struct event_base *);

static int	timeout_next(struct event_base *, struct timeval **);
static void	timeout_process(struct event_base *);
static void	timeout_correct(struct event_base *, struct timeval *);

static int
gettime(struct event_base *base, struct timeval *tp)
{}

struct event_base *
event_init(void)
{}

struct event_base *
event_base_new(void)
{}

void
event_base_free(struct event_base *base)
{}

/* reinitialized the event base after a fork */
int
event_reinit(struct event_base *base)
{}

int
event_priority_init(int npriorities)
{}

int
event_base_priority_init(struct event_base *base, int npriorities)
{}

int
event_haveevents(struct event_base *base)
{}

/*
 * Active events are stored in priority queues.  Lower priorities are always
 * process before higher priorities.  Low priority events can starve high
 * priority ones.
 */

static void
event_process_active(struct event_base *base)
{}

/*
 * Wait continously for events.  We exit only if no events are left.
 */

int
event_dispatch(void)
{}

int
event_base_dispatch(struct event_base *event_base)
{}

const char *
event_base_get_method(struct event_base *base)
{}

static void
event_loopexit_cb(int fd, short what, void *arg)
{}

/* not thread safe */
int
event_loopexit(const struct timeval *tv)
{}

int
event_base_loopexit(struct event_base *event_base, const struct timeval *tv)
{}

/* not thread safe */
int
event_loopbreak(void)
{}

int
event_base_loopbreak(struct event_base *event_base)
{}



/* not thread safe */

int
event_loop(int flags)
{}

int
event_base_loop(struct event_base *base, int flags)
{}

/* Sets up an event for processing once */

struct event_once {};

/* One-time callback, it deletes itself */

static void
event_once_cb(int fd, short events, void *arg)
{}

/* not threadsafe, event scheduled once. */
int
event_once(int fd, short events,
    void (*callback)(int, short, void *), void *arg, const struct timeval *tv)
{}

/* Schedules an event once */
int
event_base_once(struct event_base *base, int fd, short events,
    void (*callback)(int, short, void *), void *arg, const struct timeval *tv)
{}

void
event_set(struct event *ev, int fd, short events,
	  void (*callback)(int, short, void *), void *arg)
{}

int
event_base_set(struct event_base *base, struct event *ev)
{}

/*
 * Set's the priority of an event - if an event is already scheduled
 * changing the priority is going to fail.
 */

int
event_priority_set(struct event *ev, int pri)
{}

/*
 * Checks if a specific event is pending or scheduled.
 */

int
event_pending(struct event *ev, short event, struct timeval *tv)
{}

int
event_add(struct event *ev, const struct timeval *tv)
{}

int
event_del(struct event *ev)
{}

void
event_active(struct event *ev, int res, short ncalls)
{}

static int
timeout_next(struct event_base *base, struct timeval **tv_p)
{}

/*
 * Determines if the time is running backwards by comparing the current
 * time against the last time we checked.  Not needed when using clock
 * monotonic.
 */

static void
timeout_correct(struct event_base *base, struct timeval *tv)
{}

void
timeout_process(struct event_base *base)
{}

void
event_queue_remove(struct event_base *base, struct event *ev, int queue)
{}

void
event_queue_insert(struct event_base *base, struct event *ev, int queue)
{}

/* Functions for debugging */

const char *
event_get_version(void)
{}

/* 
 * No thread-safe interface needed - the information should be the same
 * for all threads.
 */

const char *
event_get_method(void)
{}