mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-28 06:11:32 +01:00
MINOR: cpuset: add ha_cpuset_isset() to check for the presence of a CPU in a set
This function will be convenient to test for the presence of a given CPU in a set.
This commit is contained in:
parent
fca3fc0d90
commit
eb10567254
@ -23,6 +23,9 @@ int ha_cpuset_clr(struct hap_cpuset *set, int cpu);
|
||||
*/
|
||||
void ha_cpuset_and(struct hap_cpuset *dst, struct hap_cpuset *src);
|
||||
|
||||
/* returns non-zero if CPU index <cpu> is set in <set>, otherwise 0. */
|
||||
int ha_cpuset_isset(const struct hap_cpuset *set, int cpu);
|
||||
|
||||
/* Returns the count of set index in <set>.
|
||||
*/
|
||||
int ha_cpuset_count(const struct hap_cpuset *set);
|
||||
|
||||
15
src/cpuset.c
15
src/cpuset.c
@ -60,6 +60,21 @@ void ha_cpuset_and(struct hap_cpuset *dst, struct hap_cpuset *src)
|
||||
#endif
|
||||
}
|
||||
|
||||
int ha_cpuset_isset(const struct hap_cpuset *set, int cpu)
|
||||
{
|
||||
if (cpu >= ha_cpuset_size())
|
||||
return 0;
|
||||
|
||||
#if defined(CPUSET_USE_CPUSET) || defined(CPUSET_USE_FREEBSD_CPUSET)
|
||||
return CPU_ISSET(cpu, &set->cpuset);
|
||||
|
||||
#elif defined(CPUSET_USE_ULONG)
|
||||
return !!(set->cpuset & (0x1 << cpu));
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int ha_cpuset_count(const struct hap_cpuset *set)
|
||||
{
|
||||
#if defined(CPUSET_USE_CPUSET) || defined(CPUSET_USE_FREEBSD_CPUSET)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user