News for hackers. Stuff that matters.
Re:Ask HN: Favorite pointer tricks in C? by Locke1689 on Saturday November 20, 2010 @08:52PM (#1925954)
If you're willing to use packed structs, here's a neat one when you're dealing with e.g., the entry controls in VMX.

From my virtual machine work:

  struct vmx_entry_ctrls {
      union {
          uint32_t value;
          struct {
              uint_t rsvd1                : 2;
              uint_t ld_dbg_ctrls         : 1;
              uint_t rsvd2                : 6;
              uint_t guest_ia32e          : 1;
              uint_t smm_entry            : 1;
              uint_t no_dual_monitor      : 1;
              uint_t rsvd3                : 1;
              uint_t ld_perf_glbl_ctrl    : 1;
              uint_t ld_pat               : 1;
              uint_t ld_efer              : 1;
              uint_t rsvd4                : 16;
          } __attribute__((packed));
      } __attribute__((packed));
  } __attribute__((packed));

There are no comments on this comment yet.