Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 1 | #ifndef Py_MYSELECT_H |
| 2 | #define Py_MYSELECT_H |
| 3 | #ifdef __cplusplus |
| 4 | extern "C" { |
| 5 | #endif |
| 6 | |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 7 | /*********************************************************** |
Guido van Rossum | 9bfef44 | 1993-03-29 10:43:31 +0000 | [diff] [blame] | 8 | Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, |
| 9 | Amsterdam, The Netherlands. |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 10 | |
| 11 | All Rights Reserved |
| 12 | |
| 13 | Permission to use, copy, modify, and distribute this software and its |
| 14 | documentation for any purpose and without fee is hereby granted, |
| 15 | provided that the above copyright notice appear in all copies and that |
| 16 | both that copyright notice and this permission notice appear in |
| 17 | supporting documentation, and that the names of Stichting Mathematisch |
| 18 | Centrum or CWI not be used in advertising or publicity pertaining to |
| 19 | distribution of the software without specific, written prior permission. |
| 20 | |
| 21 | STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
| 22 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 23 | FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
| 24 | FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 25 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 26 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 27 | OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 28 | |
| 29 | ******************************************************************/ |
| 30 | |
| 31 | /* Common definitions for files that use the BSD select system call. |
| 32 | This is so complicated because every UNIX variant requires that |
| 33 | you include a different set of headers. Customizing this one file |
| 34 | should be easier than patching each of the files using select()... */ |
| 35 | |
| 36 | |
| 37 | /* XXX You may have to include some of these only if not already included */ |
| 38 | #include <sys/types.h> |
| 39 | #include <sys/time.h> /* Implies <time.h> everywhere, as far as I know */ |
| 40 | #include <sys/param.h> |
| 41 | |
| 42 | |
| 43 | /* Hacks for various systems that need hand-holding... */ |
| 44 | |
| 45 | #ifdef _SEQUENT_ |
| 46 | #include <sys/select.h> |
| 47 | /* Sequent doesn't seem to define struct timezone anywhere?!?! */ |
| 48 | struct timezone { |
| 49 | int tz_minuteswest; |
| 50 | int tz_dsttime; |
| 51 | }; |
| 52 | #endif |
| 53 | |
| 54 | #ifdef _AIX /* I *think* this works */ |
| 55 | /* AIX defines fd_set in a separate file. Sigh... */ |
| 56 | #include <sys/select.h> |
| 57 | #endif |
| 58 | |
| 59 | |
| 60 | |
| 61 | /* (Very) old versions of BSD don't define the FD_* set of macros. |
| 62 | The following will usually do... */ |
| 63 | |
| 64 | #ifndef FD_SETSIZE |
| 65 | #define FD_SETSIZE 256 |
| 66 | #endif |
| 67 | |
| 68 | #ifndef FD_SET |
| 69 | |
| 70 | typedef long fd_mask; |
| 71 | |
| 72 | #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ |
| 73 | #ifndef howmany |
| 74 | #define howmany(x, y) (((x)+((y)-1))/(y)) |
| 75 | #endif |
| 76 | |
| 77 | typedef struct fd_set { |
| 78 | fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; |
| 79 | } fd_set; |
| 80 | |
| 81 | #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) |
| 82 | #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) |
| 83 | #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) |
Guido van Rossum | 4fbf798 | 1992-08-04 09:13:45 +0000 | [diff] [blame] | 84 | #define FD_ZERO(p) memset((char *)(p), '\0', sizeof(*(p))) |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 85 | |
| 86 | #endif /* FD_SET */ |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 87 | |
| 88 | #ifdef __cplusplus |
| 89 | } |
| 90 | #endif |
| 91 | #endif /* !Py_MYSELECT_H */ |