rvselectinternal.h
来自「基于h323协议的软phone」· C头文件 代码 · 共 256 行
H
256 行
/***********************************************************************
Filename : rvselectinternal.h
Description: internal address module definitions
These definitions shouldn't be used outside of the
address module directly
************************************************************************
Copyright (c) 2001 RADVISION Inc. and RADVISION Ltd.
************************************************************************
NOTICE:
This document contains information that is confidential and proprietary
to RADVISION Inc. and RADVISION Ltd.. No part of this document may be
reproduced in any form whatsoever without written prior approval by
RADVISION Inc. or RADVISION Ltd..
RADVISION Inc. and RADVISION Ltd. reserve the right to revise this
publication and make changes without obligation to notify any person of
such revisions or changes.
***********************************************************************/
#ifndef _RV_SELECT_INTERNAL_H
#define _RV_SELECT_INTERNAL_H
#ifdef __cplusplus
extern "C" {
#endif
/********************************************************************
type definitions written in this file should not
be accessed directly from outside the core. They
may vary greatly between core versions!
********************************************************************/
#include "rvccore.h"
#define RV_SOCKET_PREEMPTION_NONE 0 /* No preemption mechanism at all */
#define RV_SOCKET_PREEMPTION_PIPE 1 /* Use a pipe as a preemption mechanism */
#define RV_SOCKET_PREEMPTION_SOCKET 2 /* Use a socket as a preemption mechanism */
/* Check by interface which premption we need to use to stop blocking */
#if defined(RV_SINGLE_THREAD)
/* No preemption when running single threaded */
#define RV_SELECT_PREEPEMTION_TYPE RV_SOCKET_PREEMPTION_NONE
#elif (RV_OS_TYPE == RV_OS_TYPE_WIN32)
/* No need for preemption in Win32 */
#define RV_SELECT_PREEPEMTION_TYPE RV_SOCKET_PREEMPTION_NONE
#elif (RV_OS_TYPE == RV_OS_TYPE_WINCE) || (RV_OS_TYPE == RV_OS_TYPE_NUCLEUS) || \
((RV_OS_TYPE == RV_OS_TYPE_PSOS) && (RV_OS_VERSION == RV_OS_PSOS_2_0)) || \
(RV_OS_TYPE == RV_OS_TYPE_OSE) || (RV_OS_TYPE == RV_OS_TYPE_VXWORKS)
/* These operating systems don't support pipe() commands, so we have to use sockets instead */
#define RV_SELECT_PREEPEMTION_TYPE RV_SOCKET_PREEMPTION_SOCKET
#else
/* We can use a pipe() command */
#define RV_SELECT_PREEPEMTION_TYPE RV_SOCKET_PREEMPTION_PIPE
#endif
#if ((RV_SELECT_TYPE == RV_SELECT_WIN32_WSA) || (RV_SELECT_TYPE == RV_SELECT_WIN32_COMPLETION))
#include <winsock2.h>
/* We use Windows specific values so we don't have to convert them */
#define RV_SELECT_READ FD_READ
#define RV_SELECT_WRITE FD_WRITE
#define RV_SELECT_ACCEPT FD_ACCEPT
#define RV_SELECT_CONNECT FD_CONNECT
#define RV_SELECT_CLOSE FD_CLOSE
#elif ((RV_SELECT_TYPE == RV_SELECT_SELECT) || (RV_SELECT_TYPE == RV_SELECT_POLL) || \
(RV_SELECT_TYPE == RV_SELECT_DEVPOLL))
#if (RV_OS_TYPE == RV_OS_TYPE_WINCE)
#include <winsock.h>
#elif (RV_OS_TYPE == RV_OS_TYPE_VXWORKS)
#include <time.h>
#include <types.h>
#include <selectLib.h>
#elif (RV_OS_TYPE == RV_OS_TYPE_PSOS)
#include <time.h>
#include <types.h>
#include <pna.h>
#elif (RV_OS_TYPE == RV_OS_TYPE_OSE)
#include <sys/time.h>
#include <sys/types.h>
#include <inet.h>
#elif (RV_OS_TYPE == RV_OS_TYPE_NUCLEUS)
#include <inc/nu_net.h>
/* redefine types and commands for Nucleus */
#define fd_set FD_SET
#define FD_ZERO NU_FD_Init
/*#define FD_SET NU_FD_Set*/
#define FD_ISSET NU_FD_Check
#define FD_CLR NU_FD_Reset
#elif (RV_OS_TYPE == RV_OS_TYPE_SOLARIS) || \
(RV_OS_TYPE == RV_OS_TYPE_LINUX) || \
(RV_OS_TYPE == RV_OS_TYPE_EMBLINUX) || \
(RV_OS_TYPE == RV_OS_TYPE_TRU64) || \
(RV_OS_TYPE == RV_OS_TYPE_UNIXWARE)
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/select.h>
#elif (RV_OS_TYPE == RV_OS_TYPE_HPUX)
#include <sys/time.h>
#endif
#define RV_SELECT_READ RvUint16Const(0x01)
#define RV_SELECT_WRITE RvUint16Const(0x02)
#define RV_SELECT_ACCEPT RvUint16Const(0x04)
#define RV_SELECT_CONNECT RvUint16Const(0x08)
#define RV_SELECT_CLOSE RvUint16Const(0x10)
#endif /* RV_SELECT_TYPEs */
#if (RV_SELECT_TYPE == RV_SELECT_POLL)
#include <sys/poll.h>
#elif (RV_SELECT_TYPE == RV_SELECT_DEVPOLL)
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <sys/devpoll.h>
#endif
struct RvSelectFdInternal
{
RvSocket fd; /* File descriptor for this event */
RvSelectCb callback; /* Callback function - should be type casted when used */
RvSelectEvents events; /* Events we're waiting on - needed for translation */
#if (RV_SELECT_TYPE == RV_SELECT_POLL)
RvInt fdArrayIndex; /* Index in fdArray of the select engine used by this fd */
#endif
#if (RV_SELECT_TYPE == RV_SELECT_DEVPOLL)
short devpollEvents; /* /dev/poll events we're using. Done here to reduce the
number of writes to /dev/poll */
#endif
RvSelectFd* nextInBucket; /* Next file descriptor in the same bucket */
};
/********************************************************************************************
* RvSelectEngineInternal
* Fd Events engine declaration. This struct's members should not be modified or accessed
* directly by users of the core.
********************************************************************************************/
struct RvSelectEngineInternal
{
#if (RV_SELECT_TYPE == RV_SELECT_WIN32_WSA)
HWND hNetEventsWnd; /* Network events window. All events are received by it */
RvBool exitMessageLoop; /* RV_TRUE if we want to exit the current message loop */
HANDLE threadHandle; /* Thread handle of this fd engine */
DWORD threadId; /* Thread ID handling this events engine */
#elif (RV_SELECT_TYPE == RV_SELECT_WIN32_COMPLETION)
HANDLE completionPort; /* Handle of the completion port we use for this engine */
#elif (RV_SELECT_TYPE == RV_SELECT_SELECT)
RvUint32 maxFd; /* Maximum number of fd's supported */
RvUint32 maxFdInSelect; /* Maximum fd set in the fdset's of the select() */
fd_set rdSet; /* Read fd's we're currently waiting for */
fd_set wrSet; /* Write fd's we're currently waiting for */
fd_set tmpRdSet; /* Read fd's given to select() */
fd_set tmpWrSet; /* Write fd's given to select() */
RvBool waiting; /* RV_TRUE if we're blocked in a select() call */
#elif (RV_SELECT_TYPE == RV_SELECT_POLL)
RvUint32 maxFd; /* Maximum number of fd's supported */
RvUint32 maxFdInPoll; /* Number of file descriptors being polled */
struct pollfd* fdArray; /* File descriptors we're polling */
RvBool waiting; /* RV_TRUE if we're blocked in a poll() call */
#elif (RV_SELECT_TYPE == RV_SELECT_DEVPOLL)
RvUint32 maxFd; /* Maximum number of fd's supported */
RvUint32 maxFdInDevPoll; /* Number of FDs currently used */
int fdDevPoll; /* /dev/poll's file descriptor */
struct pollfd* fdArray; /* File descriptors we're polling */
RvBool waiting; /* RV_TRUE if we're blocked in a /dev/poll ioctl() call */
#endif
/* Bucket-hash parameters */
RvUint32 maxHashSize; /* Size of the bucket hash to use */
RvSelectFd** hash; /* Bucket hash to use for the file descriptors */
RvLock hashLock; /* Lock to use for bucket hash access synchronization */
#if (RV_SELECT_PREEPEMTION_TYPE == RV_SOCKET_PREEMPTION_SOCKET) || \
(RV_SELECT_PREEPEMTION_TYPE == RV_SOCKET_PREEMPTION_PIPE)
RvSelectFd preemptionFd; /* Information about the pipe's read file descriptor */
#endif
#if (RV_SELECT_PREEPEMTION_TYPE == RV_SOCKET_PREEMPTION_SOCKET)
RvSocket preemptionSocket; /* Socket used to preempt a select() call of the thread */
RvAddress localAddress; /* Address we're listening on for preemption */
#elif (RV_SELECT_PREEPEMTION_TYPE == RV_SOCKET_PREEMPTION_PIPE)
int preemptionPipeFd[2]; /* Pipe used to preempt a select() call of the thread */
#endif
RvLock lock; /* General lock. Used for updating the list of file descriptors we're
currently interested in */
};
#ifdef __cplusplus
}
#endif
#endif /* _RV_SELECT_INTERNAL_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?