include/sched.h: CPU_XXX macros can also be used without CONFIG_SMP

Allow CPU_XXX macros to be used without CONFIG_SMP=y

Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
Co-authored-by: Bowen Wang <wangbowen6@xiaomi.com>
This commit is contained in:
yanghuatao 2023-12-20 09:45:38 +08:00 committed by Xiang Xiao
parent cd57bc16c7
commit 87dfcd1020

View File

@ -71,112 +71,108 @@
/* These are not standard but are defined for Linux compatibility */ /* These are not standard but are defined for Linux compatibility */
#ifdef CONFIG_SMP
/* void CPU_ZERO(FAR cpu_set_t *set); */ /* void CPU_ZERO(FAR cpu_set_t *set); */
# define CPU_ZERO(s) do { *(s) = 0; } while (0) #define CPU_ZERO(s) do { *(s) = 0; } while (0)
/* void CPU_SET(int cpu, FAR cpu_set_t *set); */ /* void CPU_SET(int cpu, FAR cpu_set_t *set); */
# define CPU_SET(c,s) do { *(s) |= (1 << (c)); } while (0) #define CPU_SET(c,s) do { *(s) |= (1 << (c)); } while (0)
/* void CPU_CLR(int cpu, FAR cpu_set_t *set); */ /* void CPU_CLR(int cpu, FAR cpu_set_t *set); */
# define CPU_CLR(c,s) do { *(s) &= ~(1 << (c)); } while (0) #define CPU_CLR(c,s) do { *(s) &= ~(1 << (c)); } while (0)
/* int CPU_ISSET(int cpu, FAR const cpu_set_t *set); */ /* int CPU_ISSET(int cpu, FAR const cpu_set_t *set); */
# define CPU_ISSET(c,s) ((*(s) & (1 << (c))) != 0) #define CPU_ISSET(c,s) ((*(s) & (1 << (c))) != 0)
/* int CPU_COUNT(FAR const cpu_set_t *set); */ /* int CPU_COUNT(FAR const cpu_set_t *set); */
# define CPU_COUNT(s) popcountl(*s) #define CPU_COUNT(s) popcountl(*s)
/* void CPU_AND(FAR cpu_set_t *destset, FAR const cpu_set_t *srcset1, /* void CPU_AND(FAR cpu_set_t *destset, FAR const cpu_set_t *srcset1,
* FAR const cpu_set_t *srcset2); * FAR const cpu_set_t *srcset2);
*/ */
# define CPU_AND(d,s1,s2) do { *(d) = *(s1) & *(s2); } while (0) #define CPU_AND(d,s1,s2) do { *(d) = *(s1) & *(s2); } while (0)
/* void CPU_OR(FAR cpu_set_t *destset, FAR const cpu_set_t *srcset1, /* void CPU_OR(FAR cpu_set_t *destset, FAR const cpu_set_t *srcset1,
* FAR const cpu_set_t *srcset2); * FAR const cpu_set_t *srcset2);
*/ */
# define CPU_OR(d,s1,s2) do { *(d) = *(s1) | *(s2); } while (0) #define CPU_OR(d,s1,s2) do { *(d) = *(s1) | *(s2); } while (0)
/* void CPU_XOR(FAR cpu_set_t *destset, FAR const cpu_set_t *srcset1, /* void CPU_XOR(FAR cpu_set_t *destset, FAR const cpu_set_t *srcset1,
* FAR const cpu_set_t *srcset2); * FAR const cpu_set_t *srcset2);
*/ */
# define CPU_XOR(d,s1,s2) do { *(d) = *(s1) ^ *(s2); } while (0) #define CPU_XOR(d,s1,s2) do { *(d) = *(s1) ^ *(s2); } while (0)
/* int CPU_EQUAL(FAR const cpu_set_t *set1, FAR const cpu_set_t *set2); */ /* int CPU_EQUAL(FAR const cpu_set_t *set1, FAR const cpu_set_t *set2); */
# define CPU_EQUAL(s1,s2) (*(s1) == *(s2)) #define CPU_EQUAL(s1,s2) (*(s1) == *(s2))
/* REVISIT: Variably sized CPU sets are not supported */ /* REVISIT: Variably sized CPU sets are not supported */
/* FAR cpu_set_t *CPU_ALLOC(int num_cpus); */ /* FAR cpu_set_t *CPU_ALLOC(int num_cpus); */
# define CPU_ALLOC(n) (FAR cpu_set_t *)malloc(sizeof(cpu_set_t)); #define CPU_ALLOC(n) (FAR cpu_set_t *)malloc(sizeof(cpu_set_t));
/* void CPU_FREE(cpu_set_t *set); */ /* void CPU_FREE(cpu_set_t *set); */
# define CPU_FREE(s) free(s) #define CPU_FREE(s) free(s)
/* size_t CPU_ALLOC_SIZE(int num_cpus); */ /* size_t CPU_ALLOC_SIZE(int num_cpus); */
# define CPU_ALLOC_SIZE(n) sizeof(cpu_set_t) #define CPU_ALLOC_SIZE(n) sizeof(cpu_set_t)
/* void CPU_ZERO_S(size_t setsize, FAR cpu_set_t *set); */ /* void CPU_ZERO_S(size_t setsize, FAR cpu_set_t *set); */
# define CPU_ZERO_S(n,s) CPU_ZERO_S(s) #define CPU_ZERO_S(n,s) CPU_ZERO_S(s)
/* void CPU_SET_S(int cpu, size_t setsize, FAR cpu_set_t *set); */ /* void CPU_SET_S(int cpu, size_t setsize, FAR cpu_set_t *set); */
# define CPU_SET_S(c,n,s) CPU_SET(c,s) #define CPU_SET_S(c,n,s) CPU_SET(c,s)
/* void CPU_CLR_S(int cpu, size_t setsize, FAR cpu_set_t *set); */ /* void CPU_CLR_S(int cpu, size_t setsize, FAR cpu_set_t *set); */
# define CPU_CLR_S(c,n,s) CPU_CLR(c,s) #define CPU_CLR_S(c,n,s) CPU_CLR(c,s)
/* int CPU_ISSET_S(int cpu, size_t setsize, FAR const cpu_set_t *set); */ /* int CPU_ISSET_S(int cpu, size_t setsize, FAR const cpu_set_t *set); */
# define CPU_ISSET_S(c,n,s) CPU_ISSET(c,s) #define CPU_ISSET_S(c,n,s) CPU_ISSET(c,s)
/* int CPU_COUNT_S(size_t setsize, FAR const cpu_set_t *set); */ /* int CPU_COUNT_S(size_t setsize, FAR const cpu_set_t *set); */
# define CPU_COUNT_S(n,s) CPU_COUNT(s) #define CPU_COUNT_S(n,s) CPU_COUNT(s)
/* void CPU_AND_S(size_t setsize, FAR cpu_set_t *destset, /* void CPU_AND_S(size_t setsize, FAR cpu_set_t *destset,
* FAR const cpu_set_t *srcset1, * FAR const cpu_set_t *srcset1,
* FAR const cpu_set_t *srcset2); * FAR const cpu_set_t *srcset2);
*/ */
# define CPU_AND_S(n,d,s1,s2) CPU_AND(d,s1,s2) #define CPU_AND_S(n,d,s1,s2) CPU_AND(d,s1,s2)
/* void CPU_OR_S(size_t setsize, FAR cpu_set_t *destset, /* void CPU_OR_S(size_t setsize, FAR cpu_set_t *destset,
* FAR const cpu_set_t *srcset1, * FAR const cpu_set_t *srcset1,
* FAR const cpu_set_t *srcset2); * FAR const cpu_set_t *srcset2);
*/ */
# define CPU_OR_S(n,d,s1,s2) CPU_OR(d,s1,s2) #define CPU_OR_S(n,d,s1,s2) CPU_OR(d,s1,s2)
/* void CPU_XOR_S(size_t setsize, FAR cpu_set_t *destset, /* void CPU_XOR_S(size_t setsize, FAR cpu_set_t *destset,
* FAR const cpu_set_t *srcset1, * FAR const cpu_set_t *srcset1,
* FAR const cpu_set_t *srcset2); * FAR const cpu_set_t *srcset2);
*/ */
# define CPU_XOR_S(n,d,s1,s2) CPU_XOR(d,s1,s2) #define CPU_XOR_S(n,d,s1,s2) CPU_XOR(d,s1,s2)
/* int CPU_EQUAL_S(size_t setsize, FAR const cpu_set_t *set1, /* int CPU_EQUAL_S(size_t setsize, FAR const cpu_set_t *set1,
* FAR const cpu_set_t *set2); * FAR const cpu_set_t *set2);
*/ */
# define CPU_EQUAL_S(n,s1,s2) CPU_EQUAL(s1,s2) #define CPU_EQUAL_S(n,s1,s2) CPU_EQUAL(s1,s2)
#endif /* CONFIG_SMP */
/**************************************************************************** /****************************************************************************
* Public Type Definitions * Public Type Definitions