【问题标题】:what is u64.l and u64.h?什么是 u64.l 和 u64.h?
【发布时间】:2020-02-05 09:44:41
【问题描述】:

在 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?它们是干什么用的?

【问题讨论】:

    标签: c linux visual-studio


    【解决方案1】:

    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 位。

    【讨论】:

    • 在visual studio中,我不能#include
    猜你喜欢
    • 2019-11-28
    • 1970-01-01
    • 1970-01-01
    • 2021-09-27
    • 2021-12-01
    • 1970-01-01
    • 2015-09-02
    • 1970-01-01
    • 2023-02-22
    相关资源
    最近更新 更多