Skip to content

Instantly share code, notes, and snippets.

@giuseppe998e
Last active March 26, 2021 17:08
Show Gist options
  • Save giuseppe998e/ab96430c5b58f22cd1f303ab19674675 to your computer and use it in GitHub Desktop.
Save giuseppe998e/ab96430c5b58f22cd1f303ab19674675 to your computer and use it in GitHub Desktop.
Example of bit subdivision of an id of a XenTrace event
#include <stdio.h>
int main() {
// TRC_TRACE_CPU_CHANGE
unsigned cpu_change = 0x0001f003;
struct {
unsigned minor:12,
sub:4,
main:12,
unused:4;
} *evt = (typeof(evt)) &cpu_change;
printf("0x%01x 0x%03x 0x%01x 0x%03x\n", evt->unused, evt->main, evt->sub, evt->minor);
// "0x0 0x001 0xf 0x003 \n"
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment