1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
---|
2 | /* ***** BEGIN LICENSE BLOCK *****
|
---|
3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
---|
4 | *
|
---|
5 | * The contents of this file are subject to the Mozilla Public License Version
|
---|
6 | * 1.1 (the "License"); you may not use this file except in compliance with
|
---|
7 | * the License. You may obtain a copy of the License at
|
---|
8 | * http://www.mozilla.org/MPL/
|
---|
9 | *
|
---|
10 | * Software distributed under the License is distributed on an "AS IS" basis,
|
---|
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
---|
12 | * for the specific language governing rights and limitations under the
|
---|
13 | * License.
|
---|
14 | *
|
---|
15 | * The Original Code is the Netscape Portable Runtime (NSPR).
|
---|
16 | *
|
---|
17 | * The Initial Developer of the Original Code is
|
---|
18 | * Netscape Communications Corporation.
|
---|
19 | * Portions created by the Initial Developer are Copyright (C) 1998-2000
|
---|
20 | * the Initial Developer. All Rights Reserved.
|
---|
21 | *
|
---|
22 | * Contributor(s):
|
---|
23 | *
|
---|
24 | * Alternatively, the contents of this file may be used under the terms of
|
---|
25 | * either the GNU General Public License Version 2 or later (the "GPL"), or
|
---|
26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
---|
27 | * in which case the provisions of the GPL or the LGPL are applicable instead
|
---|
28 | * of those above. If you wish to allow use of your version of this file only
|
---|
29 | * under the terms of either the GPL or the LGPL, and not to allow others to
|
---|
30 | * use your version of this file under the terms of the MPL, indicate your
|
---|
31 | * decision by deleting the provisions above and replace them with the notice
|
---|
32 | * and other provisions required by the GPL or the LGPL. If you do not delete
|
---|
33 | * the provisions above, a recipient may use your version of this file under
|
---|
34 | * the terms of any one of the MPL, the GPL or the LGPL.
|
---|
35 | *
|
---|
36 | * ***** END LICENSE BLOCK ***** */
|
---|
37 |
|
---|
38 | /*
|
---|
39 | ** A collection of things thought to be obsolete
|
---|
40 | */
|
---|
41 |
|
---|
42 | #if defined(PROBSLET_H)
|
---|
43 | #else
|
---|
44 | #define PROBSLET_H
|
---|
45 |
|
---|
46 | #include "prio.h"
|
---|
47 |
|
---|
48 | PR_BEGIN_EXTERN_C
|
---|
49 |
|
---|
50 | /*
|
---|
51 | ** Yield the current thread. The proper function to use in place of
|
---|
52 | ** PR_Yield() is PR_Sleep() with an argument of PR_INTERVAL_NO_WAIT.
|
---|
53 | */
|
---|
54 | NSPR_API(PRStatus) PR_Yield(void);
|
---|
55 |
|
---|
56 | /************************************************************************/
|
---|
57 | /************* The following definitions are for select *****************/
|
---|
58 | /************************************************************************/
|
---|
59 |
|
---|
60 | /*
|
---|
61 | ** The following is obsolete and will be deleted in the next release!
|
---|
62 | ** These are provided for compatibility, but are GUARANTEED to be slow.
|
---|
63 | **
|
---|
64 | ** Override PR_MAX_SELECT_DESC if you need more space in the select set.
|
---|
65 | */
|
---|
66 | #ifndef PR_MAX_SELECT_DESC
|
---|
67 | #define PR_MAX_SELECT_DESC 1024
|
---|
68 | #endif
|
---|
69 | typedef struct PR_fd_set {
|
---|
70 | PRUint32 hsize;
|
---|
71 | PRFileDesc *harray[PR_MAX_SELECT_DESC];
|
---|
72 | PRUint32 nsize;
|
---|
73 | PRInt32 narray[PR_MAX_SELECT_DESC];
|
---|
74 | } PR_fd_set;
|
---|
75 |
|
---|
76 | /*
|
---|
77 | *************************************************************************
|
---|
78 | ** FUNCTION: PR_Select
|
---|
79 | ** DESCRIPTION:
|
---|
80 | **
|
---|
81 | ** The call returns as soon as I/O is ready on one or more of the underlying
|
---|
82 | ** file/socket descriptors or an exceptional condition is pending. A count of the
|
---|
83 | ** number of ready descriptors is returned unless a timeout occurs in which case
|
---|
84 | ** zero is returned. On return, PR_Select replaces the given descriptor sets with
|
---|
85 | ** subsets consisting of those descriptors that are ready for the requested condition.
|
---|
86 | ** The total number of ready descriptors in all the sets is the return value.
|
---|
87 | **
|
---|
88 | ** INPUTS:
|
---|
89 | ** PRInt32 num
|
---|
90 | ** This argument is unused but is provided for select(unix) interface
|
---|
91 | ** compatability. All input PR_fd_set arguments are self-describing
|
---|
92 | ** with its own maximum number of elements in the set.
|
---|
93 | **
|
---|
94 | ** PR_fd_set *readfds
|
---|
95 | ** A set describing the io descriptors for which ready for reading
|
---|
96 | ** condition is of interest.
|
---|
97 | **
|
---|
98 | ** PR_fd_set *writefds
|
---|
99 | ** A set describing the io descriptors for which ready for writing
|
---|
100 | ** condition is of interest.
|
---|
101 | **
|
---|
102 | ** PR_fd_set *exceptfds
|
---|
103 | ** A set describing the io descriptors for which exception pending
|
---|
104 | ** condition is of interest.
|
---|
105 | **
|
---|
106 | ** Any of the above readfds, writefds or exceptfds may be given as NULL
|
---|
107 | ** pointers if no descriptors are of interest for that particular condition.
|
---|
108 | **
|
---|
109 | ** PRIntervalTime timeout
|
---|
110 | ** Amount of time the call will block waiting for I/O to become ready.
|
---|
111 | ** If this time expires without any I/O becoming ready, the result will
|
---|
112 | ** be zero.
|
---|
113 | **
|
---|
114 | ** OUTPUTS:
|
---|
115 | ** PR_fd_set *readfds
|
---|
116 | ** A set describing the io descriptors which are ready for reading.
|
---|
117 | **
|
---|
118 | ** PR_fd_set *writefds
|
---|
119 | ** A set describing the io descriptors which are ready for writing.
|
---|
120 | **
|
---|
121 | ** PR_fd_set *exceptfds
|
---|
122 | ** A set describing the io descriptors which have pending exception.
|
---|
123 | **
|
---|
124 | ** RETURN:PRInt32
|
---|
125 | ** Number of io descriptors with asked for conditions or zero if the function
|
---|
126 | ** timed out or -1 on failure. The reason for the failure is obtained by
|
---|
127 | ** calling PR_GetError().
|
---|
128 | ** XXX can we implement this on windoze and mac?
|
---|
129 | **************************************************************************
|
---|
130 | */
|
---|
131 | NSPR_API(PRInt32) PR_Select(
|
---|
132 | PRInt32 num, PR_fd_set *readfds, PR_fd_set *writefds,
|
---|
133 | PR_fd_set *exceptfds, PRIntervalTime timeout);
|
---|
134 |
|
---|
135 | /*
|
---|
136 | ** The following are not thread safe for two threads operating on them at the
|
---|
137 | ** same time.
|
---|
138 | **
|
---|
139 | ** The following routines are provided for manipulating io descriptor sets.
|
---|
140 | ** PR_FD_ZERO(&fdset) initializes a descriptor set fdset to the null set.
|
---|
141 | ** PR_FD_SET(fd, &fdset) includes a particular file descriptor fd in fdset.
|
---|
142 | ** PR_FD_CLR(fd, &fdset) removes a file descriptor fd from fdset.
|
---|
143 | ** PR_FD_ISSET(fd, &fdset) is nonzero if file descriptor fd is a member of
|
---|
144 | ** fdset, zero otherwise.
|
---|
145 | **
|
---|
146 | ** PR_FD_NSET(osfd, &fdset) includes a particular native file descriptor osfd
|
---|
147 | ** in fdset.
|
---|
148 | ** PR_FD_NCLR(osfd, &fdset) removes a native file descriptor osfd from fdset.
|
---|
149 | ** PR_FD_NISSET(osfd, &fdset) is nonzero if native file descriptor osfd is a member of
|
---|
150 | ** fdset, zero otherwise.
|
---|
151 | */
|
---|
152 |
|
---|
153 | NSPR_API(void) PR_FD_ZERO(PR_fd_set *set);
|
---|
154 | NSPR_API(void) PR_FD_SET(PRFileDesc *fd, PR_fd_set *set);
|
---|
155 | NSPR_API(void) PR_FD_CLR(PRFileDesc *fd, PR_fd_set *set);
|
---|
156 | NSPR_API(PRInt32) PR_FD_ISSET(PRFileDesc *fd, PR_fd_set *set);
|
---|
157 | NSPR_API(void) PR_FD_NSET(PRInt32 osfd, PR_fd_set *set);
|
---|
158 | NSPR_API(void) PR_FD_NCLR(PRInt32 osfd, PR_fd_set *set);
|
---|
159 | NSPR_API(PRInt32) PR_FD_NISSET(PRInt32 osfd, PR_fd_set *set);
|
---|
160 |
|
---|
161 | #ifndef NO_NSPR_10_SUPPORT
|
---|
162 | #ifdef XP_MAC
|
---|
163 | #include <stat.h>
|
---|
164 | #else
|
---|
165 | #include <sys/stat.h>
|
---|
166 | #endif
|
---|
167 |
|
---|
168 | NSPR_API(PRInt32) PR_Stat(const char *path, struct stat *buf);
|
---|
169 | #endif /* NO_NSPR_10_SUPPORT */
|
---|
170 |
|
---|
171 | PR_END_EXTERN_C
|
---|
172 |
|
---|
173 | #endif /* defined(PROBSLET_H) */
|
---|
174 |
|
---|
175 | /* probslet.h */
|
---|