[flang] Use object before converts in fir.dispatch (#68589)
[llvm-project.git] / libc / include / llvm-libc-macros / sys-select-macros.h
blob5d6592c1c281c4fce27b1cf33362b5c87a1eca98
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 //===----------------------------------------------------------------------===//
9 #ifndef __LLVM_LIBC_MACROS_SYS_SELECT_MACROS_H
10 #define __LLVM_LIBC_MACROS_SYS_SELECT_MACROS_H
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)
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)
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))
28 #define FD_CLR(fd, set) (void)((set)->__set[__FD_WORD(fd)] &= ~__FD_MASK(fd))
30 #define FD_SET(fd, set) (void)((set)->__set[__FD_WORD(fd)] |= __FD_MASK(fd))
32 #define FD_ISSET(fd, set) \
33 (int)(((set)->__set[__FD_WORD(fd)] & __FD_MASK(fd)) != 0)
35 #endif // __LLVM_LIBC_MACROS_SYS_SELECT_MACROS_H