source: trunk/src/emx/include/sys/select.h@ 383

Last change on this file since 383 was 383, checked in by bird, 22 years ago

#434: bsdselect() for both 4.4 and 4.3 modes.

  • Property cvs2svn:cvs-rev set to 1.6
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 3.8 KB
Line 
1/* sys/select.h (emx+gcc) */
2
3#ifndef _SYS_SELECT_H
4#define _SYS_SELECT_H
5#define _SYS_SELECT_H_
6
7#if defined (__cplusplus)
8extern "C" {
9#endif
10
11#include <sys/cdefs.h>
12
13/** Define sigset_t here for pselect(). */
14#if !defined (_SIGSET_T)
15#define _SIGSET_T
16typedef unsigned long sigset_t;
17#endif
18
19/** Define the number of file handles in the select buffer.
20 * @remark we might wanna bump this one up a bit... */
21#if !defined (FD_SETSIZE)
22#define FD_SETSIZE 256
23#elif FD_SETSIZE < 256
24#error FD_SETSIZE must be at least 256
25#endif
26
27/** BSD thingy to figure out the size of a bitmap array. */
28#ifndef _howmany
29#define _howmany(a,b) (((a) + ((b) - 1)) / (b))
30#endif
31#if defined(TCPV40HDRS) && !defined(howmany)
32#define howmany(a,b) (((a) + ((b) - 1)) / (b))
33#endif
34
35#if !defined (_FD_SET_T)
36#define _FD_SET_T
37/** The base type for the select file descriptor bitmap. */
38typedef unsigned long __fd_mask;
39/** Number of bits in a byte. */
40#define NBBY 8
41/** Number of bits in a byte. */
42#define _NFDBITS (sizeof(__fd_mask) * 8) /* bits per mask */
43/** Select set. */
44typedef struct fd_set
45{
46 __fd_mask __fds_bits[_howmany(FD_SETSIZE, _NFDBITS)];
47} fd_set;
48
49#if defined(__BSD_VISIBLE) || defined(TCPV40HDRS)
50typedef __fd_mask fd_mask;
51#define fds_bits __fds_bits
52#define NFDBITS _NFDBITS
53#endif
54
55#endif
56
57#ifndef FD_SET
58/** Set a bit in the select file descriptor bitmap. */
59#define FD_SET(n,s) ((s)->__fds_bits[(n)/_NFDBITS] |= (1L << ((n) & (_NFDBITS - 1))))
60/** Clear a bit in the select file descriptor bitmap. */
61#define FD_CLR(n,s) ((s)->__fds_bits[(n)/_NFDBITS] &= ~(1L << ((n) & (_NFDBITS - 1))))
62/** Test if a bit in the select file descriptor bitmap is set. */
63#define FD_ISSET(n,s) ((s)->__fds_bits[(n)/_NFDBITS] & (1L << ((n) & (_NFDBITS - 1))))
64/** Initialize the select file descriptor bitmap clearing all bits. */
65#define FD_ZERO(s) (void)memset(s, 0, sizeof(*(s)))
66#if __BSD_VISIBLE
67/** Copy a select file descriptor bitmap. */
68#define FD_COPY(src,trg) (void)(*(trg) = *(src))
69#endif
70#endif /* !FD_SET */
71
72/* bird: baka baka! need memset prototype which needs size_t. */
73#include <sys/_types.h>
74#if !defined(_SIZE_T_DECLARED) && !defined(_SIZE_T) /* bird: emx */
75typedef __size_t size_t;
76#define _SIZE_T_DECLARED
77#define _SIZE_T /* bird: emx */
78#endif
79
80struct timeval;
81int select (int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *);
82int _select (int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *);
83void *memset (void *, int, size_t); /* Used by FD_ZERO */
84#ifdef _LIBC_TODO
85/** A slightly different select call which have better time precision and signal support. */
86#warning int pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *, const sigset_t *);
87#endif
88
89
90/** This is the bsd styled select.
91 * Normally it's mapped to select(), but since we don't want any such
92 * confusion we don't.
93 * @remark The normal select() doesn't have socket capabilities since the sys style libc.
94 */
95int _System bsdselect(int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *);
96/** This is the TCPIP OS/2 styled select. */
97int _System os2_select(int *, int, int, int, long);
98
99/* toolkit BSD pollution: */
100#ifndef TCPV40HDRS
101#include <sys/_types.h>
102#if !defined(_PID_T_DECLARED) && !defined(_PID_T) /* bird:emx */
103typedef __pid_t pid_t; /* process id */
104#define _PID_T_DECLARED
105#define _PID_T /* bird: emx */
106#endif
107
108/*
109 * Used to maintain information about processes that wish to be
110 * notified when I/O becomes possible.
111 */
112#pragma pack(1)
113struct selinfo {
114 pid_t si_pid; /* process to be notified */
115 short si_flags; /* see below */
116};
117#pragma pack()
118#define SI_COLL 0x0001 /* collision occurred */
119#endif /* !TCPV40HDRS */
120
121#if defined (__cplusplus)
122}
123#endif
124
125#endif /* not _SYS_SELECT_H */
Note: See TracBrowser for help on using the repository browser.