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