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