Upload Tizen:Base source
[toolchains/nspr.git] / mozilla / nsprpub / pr / include / obsolete / probslet.h
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 #include "private/pprio.h"  /* for PROsfd */
48
49 PR_BEGIN_EXTERN_C
50
51 /*
52 ** Yield the current thread.  The proper function to use in place of
53 ** PR_Yield() is PR_Sleep() with an argument of PR_INTERVAL_NO_WAIT.
54 */
55 NSPR_API(PRStatus) PR_Yield(void);
56
57 /************************************************************************/
58 /************* The following definitions are for select *****************/
59 /************************************************************************/
60
61 /*
62 ** The following is obsolete and will be deleted in the next release!
63 ** These are provided for compatibility, but are GUARANTEED to be slow.
64 **
65 ** Override PR_MAX_SELECT_DESC if you need more space in the select set.
66 */
67 #ifndef PR_MAX_SELECT_DESC
68 #define PR_MAX_SELECT_DESC 1024
69 #endif
70 typedef struct PR_fd_set {
71     PRUint32      hsize;
72     PRFileDesc   *harray[PR_MAX_SELECT_DESC];
73     PRUint32      nsize;
74     PROsfd        narray[PR_MAX_SELECT_DESC];
75 } PR_fd_set;
76
77 /*
78 *************************************************************************
79 ** FUNCTION:    PR_Select
80 ** DESCRIPTION:
81 **
82 ** The call returns as soon as I/O is ready on one or more of the underlying
83 ** file/socket descriptors or an exceptional condition is pending. A count of the 
84 ** number of ready descriptors is returned unless a timeout occurs in which case 
85 ** zero is returned.  On return, PR_Select replaces the given descriptor sets with 
86 ** subsets consisting of those descriptors that are ready for the requested condition.
87 ** The total number of ready descriptors in all the sets is the return value.
88 **
89 ** INPUTS:
90 **   PRInt32 num             
91 **       This argument is unused but is provided for select(unix) interface
92 **       compatability.  All input PR_fd_set arguments are self-describing
93 **       with its own maximum number of elements in the set.
94 **                               
95 **   PR_fd_set *readfds
96 **       A set describing the io descriptors for which ready for reading
97 **       condition is of interest.  
98 **                               
99 **   PR_fd_set *writefds
100 **       A set describing the io descriptors for which ready for writing
101 **       condition is of interest.  
102 **                               
103 **   PR_fd_set *exceptfds
104 **       A set describing the io descriptors for which exception pending
105 **       condition is of interest.  
106 **
107 **   Any of the above readfds, writefds or exceptfds may be given as NULL 
108 **   pointers if no descriptors are of interest for that particular condition.                          
109 **   
110 **   PRIntervalTime timeout  
111 **       Amount of time the call will block waiting for I/O to become ready. 
112 **       If this time expires without any I/O becoming ready, the result will
113 **       be zero.
114 **
115 ** OUTPUTS:    
116 **   PR_fd_set *readfds
117 **       A set describing the io descriptors which are ready for reading.
118 **                               
119 **   PR_fd_set *writefds
120 **       A set describing the io descriptors which are ready for writing.
121 **                               
122 **   PR_fd_set *exceptfds
123 **       A set describing the io descriptors which have pending exception.
124 **
125 ** RETURN:PRInt32
126 **   Number of io descriptors with asked for conditions or zero if the function
127 **   timed out or -1 on failure.  The reason for the failure is obtained by 
128 **   calling PR_GetError().
129 ** XXX can we implement this on windoze and mac?
130 **************************************************************************
131 */
132 NSPR_API(PRInt32) PR_Select(
133     PRInt32 num, PR_fd_set *readfds, PR_fd_set *writefds,
134     PR_fd_set *exceptfds, PRIntervalTime timeout);
135
136 /* 
137 ** The following are not thread safe for two threads operating on them at the
138 ** same time.
139 **
140 ** The following routines are provided for manipulating io descriptor sets.
141 ** PR_FD_ZERO(&fdset) initializes a descriptor set fdset to the null set.
142 ** PR_FD_SET(fd, &fdset) includes a particular file descriptor fd in fdset.
143 ** PR_FD_CLR(fd, &fdset) removes a file descriptor fd from fdset.  
144 ** PR_FD_ISSET(fd, &fdset) is nonzero if file descriptor fd is a member of 
145 ** fdset, zero otherwise.
146 **
147 ** PR_FD_NSET(osfd, &fdset) includes a particular native file descriptor osfd
148 ** in fdset.
149 ** PR_FD_NCLR(osfd, &fdset) removes a native file descriptor osfd from fdset.  
150 ** PR_FD_NISSET(osfd, &fdset) is nonzero if native file descriptor osfd is a member of 
151 ** fdset, zero otherwise.
152 */
153
154 NSPR_API(void)        PR_FD_ZERO(PR_fd_set *set);
155 NSPR_API(void)        PR_FD_SET(PRFileDesc *fd, PR_fd_set *set);
156 NSPR_API(void)        PR_FD_CLR(PRFileDesc *fd, PR_fd_set *set);
157 NSPR_API(PRInt32)     PR_FD_ISSET(PRFileDesc *fd, PR_fd_set *set);
158 NSPR_API(void)        PR_FD_NSET(PROsfd osfd, PR_fd_set *set);
159 NSPR_API(void)        PR_FD_NCLR(PROsfd osfd, PR_fd_set *set);
160 NSPR_API(PRInt32)     PR_FD_NISSET(PROsfd osfd, PR_fd_set *set);
161
162 /*
163 ** The next two entry points should not be in the API, but they are
164 ** declared here for historical reasons.
165 */
166
167 NSPR_API(PRInt32) PR_GetSysfdTableMax(void);
168
169 NSPR_API(PRInt32) PR_SetSysfdTableSize(PRIntn table_size);
170
171 #ifndef NO_NSPR_10_SUPPORT
172 #include <sys/stat.h>
173
174 NSPR_API(PRInt32) PR_Stat(const char *path, struct stat *buf);
175 #endif /* NO_NSPR_10_SUPPORT */
176
177 PR_END_EXTERN_C
178
179 #endif /* defined(PROBSLET_H) */
180
181 /* probslet.h */