blob: 3562af8c42ecf3a87581aa16a42148f8b2125525 [file] [log] [blame]
Guido van Rossumed233a51992-06-23 09:07:03 +00001/***********************************************************
Guido van Rossumfd71b9e2000-06-30 23:50:40 +00002Copyright (c) 2000, BeOpen.com.
3Copyright (c) 1995-2000, Corporation for National Research Initiatives.
4Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
5All rights reserved.
Guido van Rossumed233a51992-06-23 09:07:03 +00006
Guido van Rossumfd71b9e2000-06-30 23:50:40 +00007See the file "Misc/COPYRIGHT" for information on usage and
8redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
Guido van Rossumed233a51992-06-23 09:07:03 +00009******************************************************************/
10
Peter Schneider-Kamp7e018902000-07-31 15:28:04 +000011/***************************************
12THIS FILE IS OBSOLETE
13USE "pyport.h" INSTEAD
14***************************************/
15
Peter Schneider-Kamp25f68942000-07-31 22:19:30 +000016#ifndef Py_MYSELECT_H
17#define Py_MYSELECT_H
18#ifdef __cplusplus
19extern "C" {
20#endif
21
Guido van Rossumb6775db1994-08-01 11:34:53 +000022/* Include file for users of select() */
Guido van Rossumed233a51992-06-23 09:07:03 +000023
Guido van Rossumb6775db1994-08-01 11:34:53 +000024/* NB caller must include <sys/types.h> */
Guido van Rossumed233a51992-06-23 09:07:03 +000025
Guido van Rossumb6775db1994-08-01 11:34:53 +000026#ifdef HAVE_SYS_SELECT_H
Guido van Rossumed233a51992-06-23 09:07:03 +000027
Guido van Rossumb6775db1994-08-01 11:34:53 +000028#ifdef SYS_SELECT_WITH_SYS_TIME
29#include "mytime.h"
30#else /* !SYS_SELECT_WITH_SYS_TIME */
31#include <time.h>
32#endif /* !SYS_SELECT_WITH_SYS_TIME */
Guido van Rossumed233a51992-06-23 09:07:03 +000033
Guido van Rossum03dc5381998-09-28 22:05:22 +000034#include <sys/select.h>
35
Guido van Rossumb6775db1994-08-01 11:34:53 +000036#else /* !HAVE_SYS_SELECT_H */
Guido van Rossumed233a51992-06-23 09:07:03 +000037
Guido van Rossumddc3b632000-04-24 15:12:54 +000038#ifdef USE_GUSI1
Jack Jansene708f401996-02-14 16:04:39 +000039/* If we don't have sys/select the definition may be in unistd.h */
40#include <GUSI.h>
41#endif
42
Guido van Rossumb6775db1994-08-01 11:34:53 +000043#include "mytime.h"
Guido van Rossumed233a51992-06-23 09:07:03 +000044
Guido van Rossumb6775db1994-08-01 11:34:53 +000045#endif /* !HAVE_SYS_SELECT_H */
46
47/* If the fd manipulation macros aren't defined,
48 here is a set that should do the job */
Guido van Rossumed233a51992-06-23 09:07:03 +000049
50#ifndef FD_SETSIZE
51#define FD_SETSIZE 256
52#endif
53
54#ifndef FD_SET
55
Guido van Rossumb6775db1994-08-01 11:34:53 +000056typedef long fd_mask;
Guido van Rossumed233a51992-06-23 09:07:03 +000057
58#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
59#ifndef howmany
60#define howmany(x, y) (((x)+((y)-1))/(y))
Guido van Rossumb6775db1994-08-01 11:34:53 +000061#endif /* howmany */
Guido van Rossumed233a51992-06-23 09:07:03 +000062
63typedef struct fd_set {
64 fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
65} fd_set;
66
67#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
68#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
69#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
Guido van Rossum4fbf7981992-08-04 09:13:45 +000070#define FD_ZERO(p) memset((char *)(p), '\0', sizeof(*(p)))
Guido van Rossumed233a51992-06-23 09:07:03 +000071
72#endif /* FD_SET */
Guido van Rossuma3309961993-07-28 09:05:47 +000073
74#ifdef __cplusplus
75}
76#endif
77#endif /* !Py_MYSELECT_H */