Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../usr/include/X11
File: Xpoll.h
/*
[0] Fix | Delete
[1] Fix | Delete
Copyright 1994, 1998 The Open Group
[2] Fix | Delete
[3] Fix | Delete
Permission to use, copy, modify, distribute, and sell this software and its
[4] Fix | Delete
documentation for any purpose is hereby granted without fee, provided that
[5] Fix | Delete
the above copyright notice appear in all copies and that both that
[6] Fix | Delete
copyright notice and this permission notice appear in supporting
[7] Fix | Delete
documentation.
[8] Fix | Delete
[9] Fix | Delete
The above copyright notice and this permission notice shall be included
[10] Fix | Delete
in all copies or substantial portions of the Software.
[11] Fix | Delete
[12] Fix | Delete
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
[13] Fix | Delete
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
[14] Fix | Delete
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
[15] Fix | Delete
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
[16] Fix | Delete
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
[17] Fix | Delete
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
[18] Fix | Delete
OTHER DEALINGS IN THE SOFTWARE.
[19] Fix | Delete
[20] Fix | Delete
Except as contained in this notice, the name of The Open Group shall
[21] Fix | Delete
not be used in advertising or otherwise to promote the sale, use or
[22] Fix | Delete
other dealings in this Software without prior written authorization
[23] Fix | Delete
from The Open Group.
[24] Fix | Delete
[25] Fix | Delete
*/
[26] Fix | Delete
[27] Fix | Delete
/*
[28] Fix | Delete
* Copyright © 2005 Daniel Stone
[29] Fix | Delete
*
[30] Fix | Delete
* Permission to use, copy, modify, distribute, and sell this software and its
[31] Fix | Delete
* documentation for any purpose is hereby granted without fee, provided that
[32] Fix | Delete
* the above copyright notice appear in all copies and that both that
[33] Fix | Delete
* copyright notice and this permission notice appear in supporting
[34] Fix | Delete
* documentation, and that the name of Daniel Stone not be used in advertising
[35] Fix | Delete
* or publicity pertaining to distribution of the software without specific,
[36] Fix | Delete
* written prior permission. Daniel Stone makes no representations about the
[37] Fix | Delete
* suitability of this software for any purpose. It is provided "as is"
[38] Fix | Delete
* without express or implied warranty.
[39] Fix | Delete
*
[40] Fix | Delete
* DANIEL STONE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
[41] Fix | Delete
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
[42] Fix | Delete
* DANIEL STONE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
[43] Fix | Delete
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
[44] Fix | Delete
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
[45] Fix | Delete
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
[46] Fix | Delete
*/
[47] Fix | Delete
[48] Fix | Delete
#ifndef _XPOLL_H_
[49] Fix | Delete
#define _XPOLL_H_
[50] Fix | Delete
[51] Fix | Delete
#if !defined(WIN32) || defined(__CYGWIN__)
[52] Fix | Delete
[53] Fix | Delete
#ifndef USE_POLL
[54] Fix | Delete
[55] Fix | Delete
#include <X11/Xos.h>
[56] Fix | Delete
[57] Fix | Delete
#include <sys/select.h> /* Get the FD_* macros. */
[58] Fix | Delete
[59] Fix | Delete
#include <X11/Xmd.h>
[60] Fix | Delete
[61] Fix | Delete
#ifdef CSRG_BASED
[62] Fix | Delete
#include <sys/param.h>
[63] Fix | Delete
# if BSD < 199103
[64] Fix | Delete
typedef long fd_mask;
[65] Fix | Delete
# endif
[66] Fix | Delete
#endif
[67] Fix | Delete
[68] Fix | Delete
#if defined(FD_SETSIZE) && FD_SETSIZE < 512
[69] Fix | Delete
# define XFD_SETSIZE FD_SETSIZE
[70] Fix | Delete
#else
[71] Fix | Delete
# define XFD_SETSIZE 512
[72] Fix | Delete
# ifndef FD_SETSIZE
[73] Fix | Delete
# define FD_SETSIZE XFD_SETSIZE
[74] Fix | Delete
# endif
[75] Fix | Delete
#endif
[76] Fix | Delete
[77] Fix | Delete
#ifndef NBBY
[78] Fix | Delete
#define NBBY 8 /* number of bits in a byte */
[79] Fix | Delete
#endif
[80] Fix | Delete
[81] Fix | Delete
#ifndef NFDBITS
[82] Fix | Delete
#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
[83] Fix | Delete
#endif
[84] Fix | Delete
[85] Fix | Delete
#ifndef howmany
[86] Fix | Delete
#define howmany(x,y) (((x)+((y)-1))/(y))
[87] Fix | Delete
#endif
[88] Fix | Delete
[89] Fix | Delete
#if defined(BSD) && BSD < 198911
[90] Fix | Delete
typedef struct fd_set {
[91] Fix | Delete
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
[92] Fix | Delete
} fd_set;
[93] Fix | Delete
#endif
[94] Fix | Delete
[95] Fix | Delete
# define Select(n,r,w,e,t) select(n,(fd_set*)r,(fd_set*)w,(fd_set*)e,(struct timeval*)t)
[96] Fix | Delete
[97] Fix | Delete
#define __X_FDS_BITS __fds_bits
[98] Fix | Delete
[99] Fix | Delete
#ifndef __FDS_BITS
[100] Fix | Delete
# define __FDS_BITS(p) ((p)->__X_FDS_BITS)
[101] Fix | Delete
#endif
[102] Fix | Delete
[103] Fix | Delete
#define __XFDS_BITS(p, n) (__FDS_BITS(p))[n]
[104] Fix | Delete
[105] Fix | Delete
#ifndef FD_SET
[106] Fix | Delete
#define FD_SET(n, p) (__XFDS_BITS(p, ((n)/NFDBITS)) |= ((fd_mask)1 << ((n) % NFDBITS)))
[107] Fix | Delete
#endif
[108] Fix | Delete
#ifndef FD_CLR
[109] Fix | Delete
#define FD_CLR(n, p) (__XFDS_BITS((p), ((n)/NFDBITS)) &= ~((fd_mask)1 << ((n) % NFDBITS)))
[110] Fix | Delete
#endif
[111] Fix | Delete
#ifndef FD_ISSET
[112] Fix | Delete
#define FD_ISSET(n, p) ((__XFDS_BITS((p), ((n)/NFDBITS))) & ((fd_mask)1 << ((n) % NFDBITS)))
[113] Fix | Delete
#endif
[114] Fix | Delete
#ifndef FD_ZERO
[115] Fix | Delete
#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
[116] Fix | Delete
#endif
[117] Fix | Delete
[118] Fix | Delete
/*
[119] Fix | Delete
* The howmany(FD_SETSIZE, NFDBITS) computes the number of elements in the
[120] Fix | Delete
* array. before accessing an element in the array we check it exists.
[121] Fix | Delete
* If it does not exist then the compiler discards the code to access it.
[122] Fix | Delete
*/
[123] Fix | Delete
#define XFD_ANYSET(p) \
[124] Fix | Delete
((howmany(FD_SETSIZE, NFDBITS) > 0 && (__XFDS_BITS(p, 0))) || \
[125] Fix | Delete
(howmany(FD_SETSIZE, NFDBITS) > 1 && (__XFDS_BITS(p, 1))) || \
[126] Fix | Delete
(howmany(FD_SETSIZE, NFDBITS) > 2 && (__XFDS_BITS(p, 2))) || \
[127] Fix | Delete
(howmany(FD_SETSIZE, NFDBITS) > 3 && (__XFDS_BITS(p, 3))) || \
[128] Fix | Delete
(howmany(FD_SETSIZE, NFDBITS) > 4 && (__XFDS_BITS(p, 4))) || \
[129] Fix | Delete
(howmany(FD_SETSIZE, NFDBITS) > 5 && (__XFDS_BITS(p, 5))) || \
[130] Fix | Delete
(howmany(FD_SETSIZE, NFDBITS) > 6 && (__XFDS_BITS(p, 6))) || \
[131] Fix | Delete
(howmany(FD_SETSIZE, NFDBITS) > 7 && (__XFDS_BITS(p, 7))) || \
[132] Fix | Delete
(howmany(FD_SETSIZE, NFDBITS) > 8 && (__XFDS_BITS(p, 8))) || \
[133] Fix | Delete
(howmany(FD_SETSIZE, NFDBITS) > 9 && (__XFDS_BITS(p, 9))) || \
[134] Fix | Delete
(howmany(FD_SETSIZE, NFDBITS) > 10 && (__XFDS_BITS(p, 10))) || \
[135] Fix | Delete
(howmany(FD_SETSIZE, NFDBITS) > 11 && (__XFDS_BITS(p, 11))) || \
[136] Fix | Delete
(howmany(FD_SETSIZE, NFDBITS) > 12 && (__XFDS_BITS(p, 12))) || \
[137] Fix | Delete
(howmany(FD_SETSIZE, NFDBITS) > 13 && (__XFDS_BITS(p, 13))) || \
[138] Fix | Delete
(howmany(FD_SETSIZE, NFDBITS) > 14 && (__XFDS_BITS(p, 14))) || \
[139] Fix | Delete
(howmany(FD_SETSIZE, NFDBITS) > 15 && (__XFDS_BITS(p, 15))))
[140] Fix | Delete
[141] Fix | Delete
[142] Fix | Delete
#define XFD_COPYSET(src,dst) { \
[143] Fix | Delete
int __i__; \
[144] Fix | Delete
for (__i__ = 0; __i__ < howmany(FD_SETSIZE, NFDBITS); __i__++) \
[145] Fix | Delete
__XFDS_BITS((dst), __i__) = __XFDS_BITS((src), __i__); \
[146] Fix | Delete
}
[147] Fix | Delete
#define XFD_ANDSET(dst,b1,b2) { \
[148] Fix | Delete
int __i__; \
[149] Fix | Delete
for (__i__ = 0; __i__ < howmany(FD_SETSIZE, NFDBITS); __i__++) \
[150] Fix | Delete
__XFDS_BITS((dst), __i__) = ((__XFDS_BITS((b1), __i__)) & (__XFDS_BITS((b2), __i__))); \
[151] Fix | Delete
}
[152] Fix | Delete
#define XFD_ORSET(dst,b1,b2) { \
[153] Fix | Delete
int __i__; \
[154] Fix | Delete
for (__i__ = 0; __i__ < howmany(FD_SETSIZE, NFDBITS); __i__++) \
[155] Fix | Delete
__XFDS_BITS((dst), __i__) = ((__XFDS_BITS((b1), __i__)) | (__XFDS_BITS((b2), __i__))); \
[156] Fix | Delete
}
[157] Fix | Delete
#define XFD_UNSET(dst,b1) { \
[158] Fix | Delete
int __i__; \
[159] Fix | Delete
for (__i__ = 0; __i__ < howmany(FD_SETSIZE, NFDBITS); __i__++) \
[160] Fix | Delete
__XFDS_BITS((dst), __i__) &= ~(__XFDS_BITS((b1), __i__)); \
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
#else /* USE_POLL */
[164] Fix | Delete
#include <sys/poll.h>
[165] Fix | Delete
#endif /* USE_POLL */
[166] Fix | Delete
[167] Fix | Delete
#else /* WIN32 */
[168] Fix | Delete
[169] Fix | Delete
#define XFD_SETSIZE 512
[170] Fix | Delete
#ifndef FD_SETSIZE
[171] Fix | Delete
#define FD_SETSIZE XFD_SETSIZE
[172] Fix | Delete
#endif
[173] Fix | Delete
#include <X11/Xwinsock.h>
[174] Fix | Delete
[175] Fix | Delete
#define Select(n,r,w,e,t) select(0,(fd_set*)r,(fd_set*)w,(fd_set*)e,(struct timeval*)t)
[176] Fix | Delete
[177] Fix | Delete
#define XFD_SETCOUNT(p) (((fd_set FAR *)(p))->fd_count)
[178] Fix | Delete
#define XFD_FD(p,i) (((fd_set FAR *)(p))->fd_array[i])
[179] Fix | Delete
#define XFD_ANYSET(p) XFD_SETCOUNT(p)
[180] Fix | Delete
[181] Fix | Delete
#define XFD_COPYSET(src,dst) { \
[182] Fix | Delete
u_int __i; \
[183] Fix | Delete
FD_ZERO(dst); \
[184] Fix | Delete
for (__i = 0; __i < XFD_SETCOUNT(src) ; __i++) { \
[185] Fix | Delete
XFD_FD(dst,__i) = XFD_FD(src,__i); \
[186] Fix | Delete
} \
[187] Fix | Delete
XFD_SETCOUNT(dst) = XFD_SETCOUNT(src); \
[188] Fix | Delete
}
[189] Fix | Delete
[190] Fix | Delete
#define XFD_ANDSET(dst,b1,b2) { \
[191] Fix | Delete
u_int __i; \
[192] Fix | Delete
FD_ZERO(dst); \
[193] Fix | Delete
for (__i = 0; __i < XFD_SETCOUNT(b1) ; __i++) { \
[194] Fix | Delete
if (FD_ISSET(XFD_FD(b1,__i), b2)) \
[195] Fix | Delete
FD_SET(XFD_FD(b1,__i), dst); \
[196] Fix | Delete
} \
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
#define XFD_ORSET(dst,b1,b2) { \
[200] Fix | Delete
u_int __i; \
[201] Fix | Delete
if (dst != b1) XFD_COPYSET(b1,dst); \
[202] Fix | Delete
for (__i = 0; __i < XFD_SETCOUNT(b2) ; __i++) { \
[203] Fix | Delete
if (!FD_ISSET(XFD_FD(b2,__i), dst)) \
[204] Fix | Delete
FD_SET(XFD_FD(b2,__i), dst); \
[205] Fix | Delete
} \
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
/* this one is really sub-optimal */
[209] Fix | Delete
#define XFD_UNSET(dst,b1) { \
[210] Fix | Delete
u_int __i; \
[211] Fix | Delete
for (__i = 0; __i < XFD_SETCOUNT(b1) ; __i++) { \
[212] Fix | Delete
FD_CLR(XFD_FD(b1,__i), dst); \
[213] Fix | Delete
} \
[214] Fix | Delete
}
[215] Fix | Delete
[216] Fix | Delete
/* we have to pay the price of having an array here, unlike with bitmasks
[217] Fix | Delete
calling twice FD_SET with the same fd is not transparent, so be careful */
[218] Fix | Delete
#undef FD_SET
[219] Fix | Delete
#define FD_SET(fd,set) do { \
[220] Fix | Delete
if (XFD_SETCOUNT(set) < FD_SETSIZE && !FD_ISSET(fd,set)) \
[221] Fix | Delete
XFD_FD(set,XFD_SETCOUNT(set)++)=(fd); \
[222] Fix | Delete
} while(0)
[223] Fix | Delete
[224] Fix | Delete
#define getdtablesize() FD_SETSIZE
[225] Fix | Delete
[226] Fix | Delete
#endif /* WIN32 */
[227] Fix | Delete
[228] Fix | Delete
#endif /* _XPOLL_H_ */
[229] Fix | Delete
[230] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function