asm-offsets.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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(acr);
  21. ENTRY(srs);
  22. ENTRY(mof);
  23. ENTRY(ccs);
  24. ENTRY(srp);
  25. BLANK();
  26. #undef ENTRY
  27. #define ENTRY(entry) DEFINE(TI_ ## entry, offsetof(struct thread_info, entry))
  28. ENTRY(task);
  29. ENTRY(flags);
  30. ENTRY(preempt_count);
  31. BLANK();
  32. #undef ENTRY
  33. #define ENTRY(entry) DEFINE(THREAD_ ## entry, offsetof(struct thread_struct, entry))
  34. ENTRY(ksp);
  35. ENTRY(usp);
  36. ENTRY(ccs);
  37. BLANK();
  38. #undef ENTRY
  39. #define ENTRY(entry) DEFINE(TASK_ ## entry, offsetof(struct task_struct, entry))
  40. ENTRY(pid);
  41. BLANK();
  42. DEFINE(LCLONE_VM, CLONE_VM);
  43. DEFINE(LCLONE_UNTRACED, CLONE_UNTRACED);
  44. return 0;
  45. }