Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/system/lib/llvm-libc/include/llvm-libc-macros/sys-select-macros.h
6173 views
1
//===-- Macros defined in sys/select.h header file ------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLVM_LIBC_MACROS_SYS_SELECT_MACROS_H
10
#define LLVM_LIBC_MACROS_SYS_SELECT_MACROS_H
11
12
#define FD_SETSIZE 1024
13
#define __FD_SET_WORD_TYPE unsigned long
14
#define __FD_SET_WORD_SIZE (sizeof(__FD_SET_WORD_TYPE) * 8)
15
#define __FD_SET_ARRAYSIZE (FD_SETSIZE / __FD_SET_WORD_SIZE)
16
17
#define FD_ZERO(set) \
18
do { \
19
unsigned i; \
20
for (i = 0; i < __FD_SET_ARRAYSIZE; ++i) \
21
(set)->__set[i] = 0; \
22
} while (0)
23
24
#define __FD_WORD(fd) ((fd) / __FD_SET_WORD_SIZE)
25
#define __FD_MASK(fd) \
26
((__FD_SET_WORD_TYPE)1) << ((__FD_SET_WORD_TYPE)((fd) % __FD_SET_WORD_SIZE))
27
28
#define FD_CLR(fd, set) (void)((set)->__set[__FD_WORD(fd)] &= ~__FD_MASK(fd))
29
30
#define FD_SET(fd, set) (void)((set)->__set[__FD_WORD(fd)] |= __FD_MASK(fd))
31
32
#define FD_ISSET(fd, set) \
33
(int)(((set)->__set[__FD_WORD(fd)] & __FD_MASK(fd)) != 0)
34
35
#endif // LLVM_LIBC_MACROS_SYS_SELECT_MACROS_H
36
37