📄 primpl.h
字号:
extern PRInt32 _PR_MD_RMDIR(const char *name);#define _PR_MD_RMDIR _MD_RMDIR/* Socket I/O related */extern void _PR_MD_INIT_IO(void);#define _PR_MD_INIT_IO _MD_INIT_IOextern PRInt32 _PR_MD_CLOSE_SOCKET(PRInt32 osfd);#define _PR_MD_CLOSE_SOCKET _MD_CLOSE_SOCKETextern PRInt32 _PR_MD_CONNECT( PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout);#define _PR_MD_CONNECT _MD_CONNECTextern PRInt32 _PR_MD_ACCEPT( PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout);#define _PR_MD_ACCEPT _MD_ACCEPTextern PRInt32 _PR_MD_BIND(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen);#define _PR_MD_BIND _MD_BINDextern PRInt32 _PR_MD_LISTEN(PRFileDesc *fd, PRIntn backlog);#define _PR_MD_LISTEN _MD_LISTENextern PRInt32 _PR_MD_SHUTDOWN(PRFileDesc *fd, PRIntn how);#define _PR_MD_SHUTDOWN _MD_SHUTDOWNextern PRInt32 _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout);#define _PR_MD_RECV _MD_RECVextern PRInt32 _PR_MD_SEND( PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout);#define _PR_MD_SEND _MD_SENDextern PRInt32 _PR_MD_ACCEPT_READ(PRFileDesc *sd, PRInt32 *newSock, PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout);#define _PR_MD_ACCEPT_READ _MD_ACCEPT_READ#ifdef WIN32extern PRInt32 _PR_MD_FAST_ACCEPT(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout, PRBool fast, _PR_AcceptTimeoutCallback callback, void *callbackArg);extern PRInt32 _PR_MD_FAST_ACCEPT_READ(PRFileDesc *sd, PRInt32 *newSock, PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout, PRBool fast, _PR_AcceptTimeoutCallback callback, void *callbackArg);extern void _PR_MD_UPDATE_ACCEPT_CONTEXT(PRInt32 s, PRInt32 ls);#define _PR_MD_UPDATE_ACCEPT_CONTEXT _MD_UPDATE_ACCEPT_CONTEXT#endif /* WIN32 */extern PRInt32 _PR_MD_SENDFILE( PRFileDesc *sock, PRSendFileData *sfd, PRInt32 flags, PRIntervalTime timeout);#define _PR_MD_SENDFILE _MD_SENDFILEextern PRStatus _PR_MD_GETSOCKNAME( PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen);#define _PR_MD_GETSOCKNAME _MD_GETSOCKNAMEextern PRStatus _PR_MD_GETPEERNAME( PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen);#define _PR_MD_GETPEERNAME _MD_GETPEERNAMEextern PRStatus _PR_MD_GETSOCKOPT( PRFileDesc *fd, PRInt32 level, PRInt32 optname, char* optval, PRInt32* optlen);#define _PR_MD_GETSOCKOPT _MD_GETSOCKOPTextern PRStatus _PR_MD_SETSOCKOPT( PRFileDesc *fd, PRInt32 level, PRInt32 optname, const char* optval, PRInt32 optlen);#define _PR_MD_SETSOCKOPT _MD_SETSOCKOPTextern PRStatus PR_CALLBACK _PR_SocketGetSocketOption( PRFileDesc *fd, PRSocketOptionData *data);extern PRStatus PR_CALLBACK _PR_SocketSetSocketOption( PRFileDesc *fd, const PRSocketOptionData *data);extern PRInt32 _PR_MD_RECVFROM( PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout);#define _PR_MD_RECVFROM _MD_RECVFROMextern PRInt32 _PR_MD_SENDTO( PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout);#define _PR_MD_SENDTO _MD_SENDTOextern PRInt32 _PR_MD_SOCKETPAIR(int af, int type, int flags, PRInt32 *osfd);#define _PR_MD_SOCKETPAIR _MD_SOCKETPAIRextern PRInt32 _PR_MD_SOCKET(int af, int type, int flags);#define _PR_MD_SOCKET _MD_SOCKETextern PRInt32 _PR_MD_SOCKETAVAILABLE(PRFileDesc *fd);#define _PR_MD_SOCKETAVAILABLE _MD_SOCKETAVAILABLEextern PRInt32 _PR_MD_PIPEAVAILABLE(PRFileDesc *fd);#define _PR_MD_PIPEAVAILABLE _MD_PIPEAVAILABLEextern PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout);#define _PR_MD_PR_POLL _MD_PR_POLL/* * Initialize fd->secret->inheritable for a newly created fd. * If 'imported' is false, the osfd (i.e., fd->secret->md.osfd) * was created by NSPR and hence has the OS-dependent default * inheritable attribute. If 'imported' is true, the osfd was * not created by NSPR and hence a system call is required to * query its inheritable attribute. Since we may never need to * know the inheritable attribute of a fd, a platform may choose * to initialize fd->secret->inheritable of an imported fd to * _PR_TRI_UNKNOWN and only pay the cost of the system call * (in _PR_MD_QUERY_FD_INHERITABLE) when necessary. */extern void _PR_MD_INIT_FD_INHERITABLE(PRFileDesc *fd, PRBool imported);#define _PR_MD_INIT_FD_INHERITABLE _MD_INIT_FD_INHERITABLEextern PRStatus _PR_MD_SET_FD_INHERITABLE(PRFileDesc *fd, PRBool inheritable);#define _PR_MD_SET_FD_INHERITABLE _MD_SET_FD_INHERITABLE#define _PR_PROCESS_TIMEOUT_INTERRUPT_ERRORS(me) \ if (_PR_PENDING_INTERRUPT(me)) { \ me->flags &= ~_PR_INTERRUPT; \ PR_SetError( PR_PENDING_INTERRUPT_ERROR, 0); \ } else { \ PR_SetError(PR_IO_TIMEOUT_ERROR, 0); \ } extern void *_PR_MD_GET_SP(PRThread *thread);#define _PR_MD_GET_SP _MD_GET_SP#endif /* defined(_PR_PTHREADS) *//************************************************************************//*************************************************************************** The remainder of the definitions are shared by pthreads and the classic** NSPR code. These too may be conditionalized.*************************************************************************//************************************************************************/extern PROffset32 _PR_MD_LSEEK(PRFileDesc *fd, PROffset32 offset, PRSeekWhence whence);#define _PR_MD_LSEEK _MD_LSEEKextern PROffset64 _PR_MD_LSEEK64(PRFileDesc *fd, PROffset64 offset, PRSeekWhence whence);#define _PR_MD_LSEEK64 _MD_LSEEK64extern PRInt32 _PR_MD_GETFILEINFO(const char *fn, PRFileInfo *info);#define _PR_MD_GETFILEINFO _MD_GETFILEINFOextern PRInt32 _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info);#define _PR_MD_GETFILEINFO64 _MD_GETFILEINFO64extern PRInt32 _PR_MD_GETOPENFILEINFO(const PRFileDesc *fd, PRFileInfo *info);#define _PR_MD_GETOPENFILEINFO _MD_GETOPENFILEINFOextern PRInt32 _PR_MD_GETOPENFILEINFO64(const PRFileDesc *fd, PRFileInfo64 *info);#define _PR_MD_GETOPENFILEINFO64 _MD_GETOPENFILEINFO64/*****************************************************************************//************************** File descriptor caching **************************//*****************************************************************************/extern void _PR_InitFdCache(void);extern void _PR_CleanupFdCache(void);extern PRFileDesc *_PR_Getfd(void);extern void _PR_Putfd(PRFileDesc *fd);/* * These flags are used by NSPR temporarily in the poll * descriptor's out_flags field to record the mapping of * NSPR's poll flags to the system poll flags. * * If _PR_POLL_READ_SYS_WRITE bit is set, it means the * PR_POLL_READ flag specified by the topmost layer is * mapped to the WRITE flag at the system layer. Similarly * for the other three _PR_POLL_XXX_SYS_YYY flags. It is * assumed that the PR_POLL_EXCEPT flag doesn't get mapped * to other flags. */#define _PR_POLL_READ_SYS_READ 0x1#define _PR_POLL_READ_SYS_WRITE 0x2#define _PR_POLL_WRITE_SYS_READ 0x4#define _PR_POLL_WRITE_SYS_WRITE 0x8/*** These methods are coerced into file descriptor methods table** when the intended service is inappropriate for the particular** type of file descriptor.*/extern PRIntn _PR_InvalidInt(void);extern PRInt16 _PR_InvalidInt16(void);extern PRInt64 _PR_InvalidInt64(void);extern PRStatus _PR_InvalidStatus(void);extern PRFileDesc *_PR_InvalidDesc(void);extern PRIOMethods _pr_faulty_methods;/*** The PR_NETADDR_SIZE macro can only be called on a PRNetAddr union** whose 'family' field is set. It returns the size of the union** member corresponding to the specified address family.*/extern PRUintn _PR_NetAddrSize(const PRNetAddr* addr);#if defined(_PR_INET6)#define PR_NETADDR_SIZE(_addr) _PR_NetAddrSize(_addr)#elif defined(_PR_HAVE_MD_SOCKADDR_IN6)/*** Under the following conditions:** 1. _PR_INET6 is not defined;** 2. _PR_INET6_PROBE is defined;** 3. struct sockaddr_in6 has nonstandard fields at the end** (e.g., on Solaris 8),** (_addr)->ipv6 is smaller than struct sockaddr_in6, and** hence we can't pass sizeof((_addr)->ipv6) to socket** functions such as connect because they would fail with** EINVAL.**** To pass the correct socket address length to socket** functions, define the macro _PR_HAVE_MD_SOCKADDR_IN6 and** define struct _md_sockaddr_in6 to be isomorphic to** struct sockaddr_in6.*/#if defined(XP_UNIX)#define PR_NETADDR_SIZE(_addr) \ ((_addr)->raw.family == PR_AF_INET \ ? sizeof((_addr)->inet) \ : ((_addr)->raw.family == PR_AF_INET6 \ ? sizeof(struct _md_sockaddr_in6) \ : sizeof((_addr)->local)))#else#define PR_NETADDR_SIZE(_addr) \ ((_addr)->raw.family == PR_AF_INET \ ? sizeof((_addr)->inet) \ : sizeof(struct _md_sockaddr_in6)#endif /* defined(XP_UNIX) */#else#if defined(XP_UNIX)#define PR_NETADDR_SIZE(_addr) \ ((_addr)->raw.family == PR_AF_INET \ ? sizeof((_addr)->inet) \ : ((_addr)->raw.family == PR_AF_INET6 \ ? sizeof((_addr)->ipv6) \ : sizeof((_addr)->local)))#else#define PR_NETADDR_SIZE(_addr) \ ((_addr)->raw.family == PR_AF_INET \ ? sizeof((_addr)->inet) \ : sizeof((_addr)->ipv6))#endif /* defined(XP_UNIX) */#endif /* defined(_PR_INET6) */extern PRStatus _PR_MapOptionName( PRSockOption optname, PRInt32 *level, PRInt32 *name);extern void _PR_InitThreads( PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs);struct PRLock {#if defined(_PR_PTHREADS) pthread_mutex_t mutex; /* the underlying lock */ _PT_Notified notified; /* array of conditions notified */ PRBool locked; /* whether the mutex is locked */ pthread_t owner; /* if locked, current lock owner */#elif defined(_PR_BTHREADS) sem_id semaphoreID; /* the underlying lock */ int32 benaphoreCount; /* number of people in lock */ thread_id owner; /* current lock owner */#else /* not pthreads or Be threads */ PRCList links; /* linkage for PRThread.lockList */ struct PRThread *owner; /* current lock owner */ PRCList waitQ; /* list of threads waiting for lock */ PRThreadPriority priority; /* priority of lock */ PRThreadPriority boostPriority; /* boosted priority of lock owner */ _MDLock ilock; /* Internal Lock to protect user-level fields */#endif};extern void _PR_InitLocks(void);struct PRCondVar { PRLock *lock; /* associated lock that protects the condition */#if defined(_PR_PTHREADS) pthread_cond_t cv; /* underlying pthreads condition */ PRInt32 notify_pending; /* CV has destroy pending notification */#elif defined(_PR_BTHREADS) sem_id isem; /* Semaphore used to lock threadQ */ int32 benaphoreCount; /* Number of people in lock */#else /* not pthreads or Be threads */ PRCList condQ; /* Condition variable wait Q */ _MDLock ilock; /* Internal Lock to protect condQ */ _MDCVar md;#endif};/************************************************************************/struct PRMonitor { const char* name; /* monitor name for debugging */#if defined(_PR_PTHREADS) PRLock lock; /* the lock structure */ pthread_t owner; /* the owner of the lock or invalid */ PRCondVar *cvar; /* condition variable queue */#else /* defined(_PR_PTHREADS) */ PRCondVar *cvar; /* associated lock and condition variable queue */#endif /* defined(_PR_PTHREADS) */ PRUint32 entryCount; /* # of times re-entered */};/************************************************************************/struct PRSemaphore {#if defined(_PR_BTHREADS) sem_id sem; int32 benaphoreCount;#else PRCondVar *cvar; /* associated lock and condition variable queue */ PRUintn count; /* the value of the counting semaphore */ PRUint32 waiters; /* threads waiting on the semaphore */#if defined(_PR_PTHREADS)#else /* defined(_PR_PTHREADS) */ _MDSemaphore md;#endif /* defined(_PR_PTHREADS) */#endif /* defined(_PR_BTHREADS) */};NSPR_API(void) _PR_InitSem(void);/*************************************************************************/struct PRSem {#ifdef _PR_HAVE_POSIX_SEMAPHORES sem_t *sem;#elif defined(_PR_HAVE_SYSV_SEMAPHORES) int semid;#elif defined(WIN32) HANDLE sem;#else PRInt8 notused;#endif};/*************************************************************************/struct PRStackStr { /* head MUST be at offset 0; assembly language code relies on this */#if defined(AIX) volatile PRStackElem prstk_head;#else PRStackElem prstk_head;#endif PRLock *prstk_lock; char *prstk_name;};/************************************************************************//* XXX this needs to be exported (sigh) */struct PRThreadStack { PRCList links;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -