blob: 174da11a4022e2e56bc3bc159d65ffdabbde96f9 [file] [log] [blame]
Guido van Rossuma3309961993-07-28 09:05:47 +00001#ifndef Py_MYSELECT_H
2#define Py_MYSELECT_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
Guido van Rossumed233a51992-06-23 09:07:03 +00007/***********************************************************
Guido van Rossum9bfef441993-03-29 10:43:31 +00008Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
9Amsterdam, The Netherlands.
Guido van Rossumed233a51992-06-23 09:07:03 +000010
11 All Rights Reserved
12
13Permission to use, copy, modify, and distribute this software and its
14documentation for any purpose and without fee is hereby granted,
15provided that the above copyright notice appear in all copies and that
16both that copyright notice and this permission notice appear in
17supporting documentation, and that the names of Stichting Mathematisch
18Centrum or CWI not be used in advertising or publicity pertaining to
19distribution of the software without specific, written prior permission.
20
21STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
22THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
23FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
24FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
25WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
26ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
27OF 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?!?! */
48struct 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
70typedef 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
77typedef 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 Rossum4fbf7981992-08-04 09:13:45 +000084#define FD_ZERO(p) memset((char *)(p), '\0', sizeof(*(p)))
Guido van Rossumed233a51992-06-23 09:07:03 +000085
86#endif /* FD_SET */
Guido van Rossuma3309961993-07-28 09:05:47 +000087
88#ifdef __cplusplus
89}
90#endif
91#endif /* !Py_MYSELECT_H */