probslet.h 6.8 KB

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