summaryrefslogtreecommitdiff
path: root/software/vendor/github.com/creack/goselect/fdset_doc.go
blob: d9f15a1cec5b09c6bd63b92bbc1367de6a3f2056 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package goselect

/**
From: XCode's MacOSX10.10.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/select.h
--
// darwin/amd64 / 386
sizeof(__int32_t) == 4
--

typedef __int32_t __fd_mask;

#define	FD_SETSIZE      1024
#define __NFDBITS	(sizeof(__fd_mask) * 8)
#define	__howmany(x, y)	((((x) % (y)) == 0) ? ((x) / (y)) : (((x) / (y)) + 1))

typedef	struct  fd_set {
    __fd_mask   fds_bits[__howmany(__FD_SETSIZE, __NFDBITS)];
}               fd_set;

#define __FD_MASK(n)   ((__fd_mask)1 << ((n) % __NFDBITS))
#define	FD_SET(n, p)    ((p)->fds_bits[(n)/__NFDBITS] |=  __FD_MASK(n))
#define	FD_CLR(n, p)    ((p)->fds_bits[(n)/__NFDBITS] &= ~__FD_MASK(n))
#define FD_ISSET(n, p) (((p)->fds_bits[(n)/__NFDBITS] &   __FD_MASK(n)) != 0)
*/

/**
From: /usr/include/i386-linux-gnu/sys/select.h
--
// linux/i686
sizeof(long int) == 4
--

typedef long int __fd_mask;

#define FD_SETSIZE      1024
#define __NFDBITS       (sizeof(__fd_mask) * 8)


typedef struct  fd_set {
    __fd_mask   fds_bits[__FD_SETSIZE / __NFDBITS];
}               fd_set;

#define __FD_MASK(n)   ((__fd_mask)1 << ((n) % __NFDBITS))
#define FD_SET(n, p)    ((p)->fds_bits[(n)/__NFDBITS] |=  __FD_MASK(n))
#define FD_CLR(n, p)    ((p)->fds_bits[(n)/__NFDBITS] &= ~__FD_MASK(n))
#define FD_ISSET(n, p) (((p)->fds_bits[(n)/__NFDBITS] &   __FD_MASK(n)) != 0)
*/

/**
From: /usr/include/x86_64-linux-gnu/sys/select.h
--
// linux/amd64
sizeof(long int) == 8
--

typedef long int __fd_mask;

#define FD_SETSIZE      1024
#define __NFDBITS       (sizeof(__fd_mask) * 8)


typedef struct  fd_set {
    __fd_mask   fds_bits[__FD_SETSIZE / __NFDBITS];
}               fd_set;

#define __FD_MASK(n)   ((__fd_mask)1 << ((n) % __NFDBITS))
#define FD_SET(n, p)    ((p)->fds_bits[(n)/__NFDBITS] |=  __FD_MASK(n))
#define FD_CLR(n, p)    ((p)->fds_bits[(n)/__NFDBITS] &= ~__FD_MASK(n))
#define FD_ISSET(n, p) (((p)->fds_bits[(n)/__NFDBITS] &   __FD_MASK(n)) != 0)
*/

/**
From: /usr/include/sys/select.h
--
// freebsd/amd64
sizeof(unsigned long) == 8
--

typedef unsigned long   __fd_mask;

#define FD_SETSIZE      1024U
#define __NFDBITS       (sizeof(__fd_mask) * 8)
#define _howmany(x, y)  (((x) + ((y) - 1)) / (y))

typedef struct  fd_set {
    __fd_mask   fds_bits[_howmany(FD_SETSIZE, __NFDBITS)];
}               fd_set;

#define __FD_MASK(n)   ((__fd_mask)1 << ((n) % __NFDBITS))
#define FD_SET(n, p)    ((p)->fds_bits[(n)/__NFDBITS] |=  __FD_MASK(n))
#define FD_CLR(n, p)    ((p)->fds_bits[(n)/__NFDBITS] &= ~__FD_MASK(n))
#define FD_ISSET(n, p) (((p)->fds_bits[(n)/__NFDBITS] &   __FD_MASK(n)) != 0)
*/