1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
9 * This file is added to support the common code in eal_common_thread.c
10 * as Microsoft libc does not contain sched.h. This may be removed
18 #define CPU_SETSIZE RTE_MAX_LCORE
21 #define _BITS_PER_SET (sizeof(long long) * 8)
22 #define _BIT_SET_MASK (_BITS_PER_SET - 1)
24 #define _NUM_SETS(b) (((b) + _BIT_SET_MASK) / _BITS_PER_SET)
25 #define _WHICH_SET(b) ((b) / _BITS_PER_SET)
26 #define _WHICH_BIT(b) ((b) & (_BITS_PER_SET - 1))
28 typedef struct _rte_cpuset_s {
29 long long _bits[_NUM_SETS(CPU_SETSIZE)];
32 #define CPU_SET(b, s) ((s)->_bits[_WHICH_SET(b)] |= (1LL << _WHICH_BIT(b)))
38 for (_i = 0; _i < _NUM_SETS(CPU_SETSIZE); _i++) \
39 (s)->_bits[_i] = 0LL; \
42 #define CPU_ISSET(b, s) (((s)->_bits[_WHICH_SET(b)] & \
43 (1LL << _WHICH_BIT(b))) != 0LL)
46 count_cpu(rte_cpuset_t *s)
51 for (_i = 0; _i < _NUM_SETS(CPU_SETSIZE); _i++)
52 if (CPU_ISSET(_i, s) != 0LL)
56 #define CPU_COUNT(s) count_cpu(s)
58 #define CPU_AND(dst, src1, src2) \
62 for (_i = 0; _i < _NUM_SETS(CPU_SETSIZE); _i++) \
63 (dst)->_bits[_i] = (src1)->_bits[_i] & (src2)->_bits[_i]; \
66 #define CPU_OR(dst, src1, src2) \
70 for (_i = 0; _i < _NUM_SETS(CPU_SETSIZE); _i++) \
71 (dst)->_bits[_i] = (src1)->_bits[_i] | (src2)->_bits[_i]; \
77 for (_i = 0; _i < _NUM_SETS(CPU_SETSIZE); _i++) \
78 (s)->_bits[_i] = -1LL; \
81 #define CPU_NOT(dst, src) \
84 for (_i = 0; _i < _NUM_SETS(CPU_SETSIZE); _i++) \
85 (dst)->_bits[_i] = (src)->_bits[_i] ^ -1LL; \
92 #endif /* _SCHED_H_ */