andre@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: andre@0: /* andre@0: ** A collection of things thought to be obsolete andre@0: */ andre@0: andre@0: #if defined(PROBSLET_H) andre@0: #else andre@0: #define PROBSLET_H andre@0: andre@0: #include "prio.h" andre@0: #include "private/pprio.h" /* for PROsfd */ andre@0: andre@0: PR_BEGIN_EXTERN_C andre@0: andre@0: /* andre@0: ** Yield the current thread. The proper function to use in place of andre@0: ** PR_Yield() is PR_Sleep() with an argument of PR_INTERVAL_NO_WAIT. andre@0: */ andre@0: NSPR_API(PRStatus) PR_Yield(void); andre@0: andre@0: /************************************************************************/ andre@0: /************* The following definitions are for select *****************/ andre@0: /************************************************************************/ andre@0: andre@0: /* andre@0: ** The following is obsolete and will be deleted in the next release! andre@0: ** These are provided for compatibility, but are GUARANTEED to be slow. andre@0: ** andre@0: ** Override PR_MAX_SELECT_DESC if you need more space in the select set. andre@0: */ andre@0: #ifndef PR_MAX_SELECT_DESC andre@0: #define PR_MAX_SELECT_DESC 1024 andre@0: #endif andre@0: typedef struct PR_fd_set { andre@0: PRUint32 hsize; andre@0: PRFileDesc *harray[PR_MAX_SELECT_DESC]; andre@0: PRUint32 nsize; andre@0: PROsfd narray[PR_MAX_SELECT_DESC]; andre@0: } PR_fd_set; andre@0: andre@0: /* andre@0: ************************************************************************* andre@0: ** FUNCTION: PR_Select andre@0: ** DESCRIPTION: andre@0: ** andre@0: ** The call returns as soon as I/O is ready on one or more of the underlying andre@0: ** file/socket descriptors or an exceptional condition is pending. A count of the andre@0: ** number of ready descriptors is returned unless a timeout occurs in which case andre@0: ** zero is returned. On return, PR_Select replaces the given descriptor sets with andre@0: ** subsets consisting of those descriptors that are ready for the requested condition. andre@0: ** The total number of ready descriptors in all the sets is the return value. andre@0: ** andre@0: ** INPUTS: andre@0: ** PRInt32 num andre@0: ** This argument is unused but is provided for select(unix) interface andre@0: ** compatability. All input PR_fd_set arguments are self-describing andre@0: ** with its own maximum number of elements in the set. andre@0: ** andre@0: ** PR_fd_set *readfds andre@0: ** A set describing the io descriptors for which ready for reading andre@0: ** condition is of interest. andre@0: ** andre@0: ** PR_fd_set *writefds andre@0: ** A set describing the io descriptors for which ready for writing andre@0: ** condition is of interest. andre@0: ** andre@0: ** PR_fd_set *exceptfds andre@0: ** A set describing the io descriptors for which exception pending andre@0: ** condition is of interest. andre@0: ** andre@0: ** Any of the above readfds, writefds or exceptfds may be given as NULL andre@0: ** pointers if no descriptors are of interest for that particular condition. andre@0: ** andre@0: ** PRIntervalTime timeout andre@0: ** Amount of time the call will block waiting for I/O to become ready. andre@0: ** If this time expires without any I/O becoming ready, the result will andre@0: ** be zero. andre@0: ** andre@0: ** OUTPUTS: andre@0: ** PR_fd_set *readfds andre@0: ** A set describing the io descriptors which are ready for reading. andre@0: ** andre@0: ** PR_fd_set *writefds andre@0: ** A set describing the io descriptors which are ready for writing. andre@0: ** andre@0: ** PR_fd_set *exceptfds andre@0: ** A set describing the io descriptors which have pending exception. andre@0: ** andre@0: ** RETURN:PRInt32 andre@0: ** Number of io descriptors with asked for conditions or zero if the function andre@0: ** timed out or -1 on failure. The reason for the failure is obtained by andre@0: ** calling PR_GetError(). andre@0: ** XXX can we implement this on windoze and mac? andre@0: ************************************************************************** andre@0: */ andre@0: NSPR_API(PRInt32) PR_Select( andre@0: PRInt32 num, PR_fd_set *readfds, PR_fd_set *writefds, andre@0: PR_fd_set *exceptfds, PRIntervalTime timeout); andre@0: andre@0: /* andre@0: ** The following are not thread safe for two threads operating on them at the andre@0: ** same time. andre@0: ** andre@0: ** The following routines are provided for manipulating io descriptor sets. andre@0: ** PR_FD_ZERO(&fdset) initializes a descriptor set fdset to the null set. andre@0: ** PR_FD_SET(fd, &fdset) includes a particular file descriptor fd in fdset. andre@0: ** PR_FD_CLR(fd, &fdset) removes a file descriptor fd from fdset. andre@0: ** PR_FD_ISSET(fd, &fdset) is nonzero if file descriptor fd is a member of andre@0: ** fdset, zero otherwise. andre@0: ** andre@0: ** PR_FD_NSET(osfd, &fdset) includes a particular native file descriptor osfd andre@0: ** in fdset. andre@0: ** PR_FD_NCLR(osfd, &fdset) removes a native file descriptor osfd from fdset. andre@0: ** PR_FD_NISSET(osfd, &fdset) is nonzero if native file descriptor osfd is a member of andre@0: ** fdset, zero otherwise. andre@0: */ andre@0: andre@0: NSPR_API(void) PR_FD_ZERO(PR_fd_set *set); andre@0: NSPR_API(void) PR_FD_SET(PRFileDesc *fd, PR_fd_set *set); andre@0: NSPR_API(void) PR_FD_CLR(PRFileDesc *fd, PR_fd_set *set); andre@0: NSPR_API(PRInt32) PR_FD_ISSET(PRFileDesc *fd, PR_fd_set *set); andre@0: NSPR_API(void) PR_FD_NSET(PROsfd osfd, PR_fd_set *set); andre@0: NSPR_API(void) PR_FD_NCLR(PROsfd osfd, PR_fd_set *set); andre@0: NSPR_API(PRInt32) PR_FD_NISSET(PROsfd osfd, PR_fd_set *set); andre@0: andre@0: /* andre@0: ** The next two entry points should not be in the API, but they are andre@0: ** declared here for historical reasons. andre@0: */ andre@0: andre@0: NSPR_API(PRInt32) PR_GetSysfdTableMax(void); andre@0: andre@0: NSPR_API(PRInt32) PR_SetSysfdTableSize(PRIntn table_size); andre@0: andre@0: #ifndef NO_NSPR_10_SUPPORT andre@0: #include andre@0: andre@0: NSPR_API(PRInt32) PR_Stat(const char *path, struct stat *buf); andre@0: #endif /* NO_NSPR_10_SUPPORT */ andre@0: andre@0: PR_END_EXTERN_C andre@0: andre@0: #endif /* defined(PROBSLET_H) */ andre@0: andre@0: /* probslet.h */