1 /*
2  * Copyright (C) 2018 Alibaba Group Holding Limited
3  */
4 
5 /*
6 modification history
7 --------------------
8 21jan2018,WangMin  writen.
9 */
10 
11 /*
12 DESCRIPTION
13 This file provides base type of cpu set and method for cpu set.
14 */
15 
16 #ifndef __cpuset_h__
17 #define __cpuset_h__
18 
19 #include "k_atomic.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 /* typedefs */
26 
27 typedef unsigned int             cpuset_t;
28 
29 #define CPUSET_ATOMIC_SET(cpuset, n)                \
30 	(void) rhino_atomic_or ((atomic_t *) &(cpuset), 1 << (n))
31 #define CPUSET_ATOMIC_CLR(cpuset, n)                \
32 	(void) rhino_atomic_and ((atomic_t *) &(cpuset), ~((1 << (n))))
33 #define CPUSET_ATOMIC_COPY(cpusetDst, cpusetSrc)    \
34     (void) rhino_atomic_set ((atomic_t *) &(cpusetDst), (atomic_t) (cpusetSrc))
35 
36 #define CPUSET_CLR(cpuset, n)       ((cpuset) &= ~(1 << (n)))
37 #define CPUSET_ZERO(cpuset)         ((cpuset) = 0)
38 #define CPUSET_IS_ZERO(cpuset)      ((cpuset) == 0)
39 #define CPUSET_SET(cpuset, n)       ((cpuset) |= (1 << (n)))
40 #define CPUSET_ISSET(cpuset, n)     ((cpuset) & (1 << (n)))
41 
42 #ifdef __cplusplus
43 }
44 #endif
45 
46 #endif /* __cpuset_h__ */
47 
48