1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 /* 7 ** A collection of things thought to be obsolete 8 */ 9 10 #if defined(PROBSLET_H) 11 #else 12 #define PROBSLET_H 13 14 #include "prio.h" 15 #include "private/pprio.h" /* for PROsfd */ 16 17 PR_BEGIN_EXTERN_C 18 19 /* 20 ** Yield the current thread. The proper function to use in place of 21 ** PR_Yield() is PR_Sleep() with an argument of PR_INTERVAL_NO_WAIT. 22 */ 23 NSPR_API(PRStatus) PR_Yield(void); 24 25 /************************************************************************/ 26 /************* The following definitions are for select *****************/ 27 /************************************************************************/ 28 29 /* 30 ** The following is obsolete and will be deleted in the next release! 31 ** These are provided for compatibility, but are GUARANTEED to be slow. 32 ** 33 ** Override PR_MAX_SELECT_DESC if you need more space in the select set. 34 */ 35 #ifndef PR_MAX_SELECT_DESC 36 #define PR_MAX_SELECT_DESC 1024 37 #endif 38 typedef struct PR_fd_set { 39 PRUint32 hsize; 40 PRFileDesc *harray[PR_MAX_SELECT_DESC]; 41 PRUint32 nsize; 42 PROsfd narray[PR_MAX_SELECT_DESC]; 43 } PR_fd_set; 44 45 /* 46 ************************************************************************* 47 ** FUNCTION: PR_Select 48 ** DESCRIPTION: 49 ** 50 ** The call returns as soon as I/O is ready on one or more of the underlying 51 ** file/socket descriptors or an exceptional condition is pending. A count of the 52 ** number of ready descriptors is returned unless a timeout occurs in which case 53 ** zero is returned. On return, PR_Select replaces the given descriptor sets with 54 ** subsets consisting of those descriptors that are ready for the requested condition. 55 ** The total number of ready descriptors in all the sets is the return value. 56 ** 57 ** INPUTS: 58 ** PRInt32 num 59 ** This argument is unused but is provided for select(unix) interface 60 ** compatability. All input PR_fd_set arguments are self-describing 61 ** with its own maximum number of elements in the set. 62 ** 63 ** PR_fd_set *readfds 64 ** A set describing the io descriptors for which ready for reading 65 ** condition is of interest. 66 ** 67 ** PR_fd_set *writefds 68 ** A set describing the io descriptors for which ready for writing 69 ** condition is of interest. 70 ** 71 ** PR_fd_set *exceptfds 72 ** A set describing the io descriptors for which exception pending 73 ** condition is of interest. 74 ** 75 ** Any of the above readfds, writefds or exceptfds may be given as NULL 76 ** pointers if no descriptors are of interest for that particular condition. 77 ** 78 ** PRIntervalTime timeout 79 ** Amount of time the call will block waiting for I/O to become ready. 80 ** If this time expires without any I/O becoming ready, the result will 81 ** be zero. 82 ** 83 ** OUTPUTS: 84 ** PR_fd_set *readfds 85 ** A set describing the io descriptors which are ready for reading. 86 ** 87 ** PR_fd_set *writefds 88 ** A set describing the io descriptors which are ready for writing. 89 ** 90 ** PR_fd_set *exceptfds 91 ** A set describing the io descriptors which have pending exception. 92 ** 93 ** RETURN:PRInt32 94 ** Number of io descriptors with asked for conditions or zero if the function 95 ** timed out or -1 on failure. The reason for the failure is obtained by 96 ** calling PR_GetError(). 97 ** XXX can we implement this on windoze and mac? 98 ************************************************************************** 99 */ 100 NSPR_API(PRInt32) PR_Select( 101 PRInt32 num, PR_fd_set *readfds, PR_fd_set *writefds, 102 PR_fd_set *exceptfds, PRIntervalTime timeout); 103 104 /* 105 ** The following are not thread safe for two threads operating on them at the 106 ** same time. 107 ** 108 ** The following routines are provided for manipulating io descriptor sets. 109 ** PR_FD_ZERO(&fdset) initializes a descriptor set fdset to the null set. 110 ** PR_FD_SET(fd, &fdset) includes a particular file descriptor fd in fdset. 111 ** PR_FD_CLR(fd, &fdset) removes a file descriptor fd from fdset. 112 ** PR_FD_ISSET(fd, &fdset) is nonzero if file descriptor fd is a member of 113 ** fdset, zero otherwise. 114 ** 115 ** PR_FD_NSET(osfd, &fdset) includes a particular native file descriptor osfd 116 ** in fdset. 117 ** PR_FD_NCLR(osfd, &fdset) removes a native file descriptor osfd from fdset. 118 ** PR_FD_NISSET(osfd, &fdset) is nonzero if native file descriptor osfd is a member of 119 ** fdset, zero otherwise. 120 */ 121 122 NSPR_API(void) PR_FD_ZERO(PR_fd_set *set); 123 NSPR_API(void) PR_FD_SET(PRFileDesc *fd, PR_fd_set *set); 124 NSPR_API(void) PR_FD_CLR(PRFileDesc *fd, PR_fd_set *set); 125 NSPR_API(PRInt32) PR_FD_ISSET(PRFileDesc *fd, PR_fd_set *set); 126 NSPR_API(void) PR_FD_NSET(PROsfd osfd, PR_fd_set *set); 127 NSPR_API(void) PR_FD_NCLR(PROsfd osfd, PR_fd_set *set); 128 NSPR_API(PRInt32) PR_FD_NISSET(PROsfd osfd, PR_fd_set *set); 129 130 /* 131 ** The next two entry points should not be in the API, but they are 132 ** declared here for historical reasons. 133 */ 134 135 NSPR_API(PRInt32) PR_GetSysfdTableMax(void); 136 137 NSPR_API(PRInt32) PR_SetSysfdTableSize(PRIntn table_size); 138 139 #ifndef NO_NSPR_10_SUPPORT 140 #include <sys/stat.h> 141 142 NSPR_API(PRInt32) PR_Stat(const char *path, struct stat *buf); 143 #endif /* NO_NSPR_10_SUPPORT */ 144 145 PR_END_EXTERN_C 146 147 #endif /* defined(PROBSLET_H) */ 148 149 /* probslet.h */ 150