asm-offsets.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <linux/sched.h>
  2. #include <asm/thread_info.h>
  3. /*
  4. * Generate definitions needed by assembly language modules.
  5. * This code generates raw asm output which is post-processed to extract
  6. * and format the required data.
  7. */
  8. #define DEFINE(sym, val) \
  9. asm volatile("\n->" #sym " %0 " #val : : "i" (val))
  10. #define BLANK() asm volatile("\n->" : : )
  11. int main(void)
  12. {
  13. #define ENTRY(entry) DEFINE(PT_ ## entry, offsetof(struct pt_regs, entry))
  14. ENTRY(orig_r10);
  15. ENTRY(r13);
  16. ENTRY(r12);
  17. ENTRY(r11);
  18. ENTRY(r10);
  19. ENTRY(r9);
  20. ENTRY(mof);
  21. ENTRY(dccr);
  22. ENTRY(srp);
  23. BLANK();
  24. #undef ENTRY
  25. #define ENTRY(entry) DEFINE(TI_ ## entry, offsetof(struct thread_info, entry))
  26. ENTRY(task);
  27. ENTRY(flags);
  28. ENTRY(preempt_count);
  29. BLANK();
  30. #undef ENTRY
  31. #define ENTRY(entry) DEFINE(THREAD_ ## entry, offsetof(struct thread_struct, entry))
  32. ENTRY(ksp);
  33. ENTRY(usp);
  34. ENTRY(dccr);
  35. BLANK();
  36. #undef ENTRY
  37. #define ENTRY(entry) DEFINE(TASK_ ## entry, offsetof(struct task_struct, entry))
  38. ENTRY(pid);
  39. BLANK();
  40. DEFINE(LCLONE_VM, CLONE_VM);
  41. DEFINE(LCLONE_UNTRACED, CLONE_UNTRACED);
  42. return 0;
  43. }