summaryrefslogtreecommitdiff
path: root/src/pal/src/include/pal/fakepoll.h
blob: eec40d6612de5157fcd233954529f8e6e08326b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

// fakepoll.h
// poll using select
// Warning: a call to this poll() takes about 4K of stack space.

// Greg Parker     gparker@cs.stanford.edu     December 2000
// This code is in the public domain and may be copied or modified without 
// permission. 

// Located at <http://www.sealiesoftware.com/fakepoll.h>.




#ifndef _FAKE_POLL_H
#define _FAKE_POLL_H

#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus

#ifdef FD_SETSIZE
#undef FD_SETSIZE
#endif
#define FD_SETSIZE OPEN_MAX

typedef struct pollfd {
    int fd;                         /* file desc to poll */
    short events;                   /* events of interest on fd */
    short revents;                  /* events that occurred on fd */
} pollfd_t;

// Typically defined in sys/stropts.h and used for an infinite timeout.
#ifndef _INFTIM
#define _INFTIM -1
#endif
#ifndef INFTIM
#define INFTIM _INFTIM
#endif

// poll flags
#define POLLIN  0x0001
#define POLLOUT 0x0004
#define POLLERR 0x0008

// synonyms
#define POLLNORM POLLIN
#define POLLPRI POLLIN
#define POLLRDNORM POLLIN
#define POLLRDBAND POLLIN
#define POLLWRNORM POLLOUT
#define POLLWRBAND POLLOUT

// ignored
#define POLLHUP 0x0010
#define POLLNVAL 0x0020

int poll(struct pollfd *pollSet, int pollCount, int pollTimeout);

#ifdef __cplusplus
}
#endif // __cplusplus

#endif  /* _FAKE_POLL_H */