'is cpu_online_mask integer value
There is this, cpu_online_mask macro defined in Linux Kernel, wanted to know what does it return? does it return some integer value?
#define cpu_online_mask ((const struct cpumask *)&__cpu_online_mask)
https://elixir.bootlin.com/linux/latest/source/include/linux/cpumask.h#L96
or does it return a pointer to cpumask struct
typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
so that DECLARE_BITMAP(bits, NR_CPUS) = cpu_online_mask ??
I didn't understand how member of struct "cpumask" DECLARE_BITMAP(bits, NR_CPUS) is initialized ?
Solution 1:[1]
is cpu_online_mask integer value
No.
wanted to know what does it return?
A pointer to constant struct cpumask.
does it return some integer value?
No.
does it return a pointer to cpumask struct
Yes!
o that DECLARE_BITMAP(bits, NR_CPUS) = cpu_online_mask ?
No. It's just DECLARE_BITMAP from types.h. You could say that DECLARE_BITMAP(bits, NR_CPUS) defines cpu_online_mask->bits member.
how member of struct "cpumask" DECLARE_BITMAP(bits, NR_CPUS) is initialized ?
The variable __cpu_online_mask has no initializer in kernel/cpu.c.
*** The macro cpu_online_mask does not really "return" anything, the token in source code cpu_online_mask is literally replaced by the result of expansion. For example code like cpu_online_mask->bits[0] = 1; is replaced by ((const struct cpumask *)&__cpu_online_mask)->buts[0] = 1; and then compiled.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | KamilCuk |
