Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include "stdio.h"
  2. #define N 10
  3.  
  4. typedef struct __attribute__((aligned(0x100)) _element {
  5. int val;
  6. char padding[64];
  7. struct _element *next;
  8.  
  9. } element;
  10.  
  11.  
  12. int main() {
  13.  
  14. element* head = new element;
  15. element* current = head;
  16. for (int i = 0; i < N; ++i) {
  17. current->val = i;
  18. if (i == N - 1)
  19. break;
  20. current->next = new element;
  21. current = current->next;
  22. }
  23. current->next = NULL;
  24.  
  25. current = head;
  26. printf("sizeof(element) = 0x%xn", (unsigned int)sizeof(element));
  27. while (current) {
  28. printf("*(%p) = %dn", &current->val, current->val);
  29. current = current->next;
  30. }
  31.  
  32. return 0;
  33. }
  34.  
  35. sizeof(element) = 0x100
  36. *(0x501010) = 0
  37. *(0x501120) = 1
  38. *(0x501230) = 2
  39. *(0x501340) = 3
  40. *(0x501450) = 4
  41. *(0x501560) = 5
  42. *(0x501670) = 6
  43. *(0x501780) = 7
  44. *(0x501890) = 8
  45. *(0x5019a0) = 9
  46.  
  47. attribute(__aligned__())
  48.  
  49. 0xxxxxx30 % 0x40 == 0x0 //really? that's aligned to 64b?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement