在Linux中,dmidecode源代码:
https://github.com/mirror/dmidecode/blob/master/dmidecode.c#L273
我看到这个:
static void dmi_print_memory_size(u64 code, int shift)
{
...
split[0] = code.l & 0x3FFUL;
split[1] = (code.l >> 10) & 0x3FFUL;
split[2] = (code.l >> 20) & 0x3FFUL;
split[3] = ((code.h << 2) & 0x3FCUL) | (code.l >> 30);
split[4] = (code.h >> 8) & 0x3FFUL;
split[5] = (code.h >> 18) & 0x3FFUL;
split[6] = code.h >> 28;
“code”是一个u64变量,为什么它有成员.l和.h?它们是干什么用的?
最佳答案
u64类型在types.h
中定义:
#ifdef BIGENDIAN
typedef struct {
u32 h;
u32 l;
} u64;
#else
typedef struct {
u32 l;
u32 h;
} u64;
#endif
因此,似乎
.l
和.h
成员表示64位数字的“低”和“高”32位。关于c - 什么是u64.l和u64.h?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58280681/