asm-offsets.c 710 B

12345678910111213141516171819202122232425
  1. /*
  2. * Generate definitions needed by assembly language modules.
  3. * This code generates raw asm output which is post-processed
  4. * to extract and format the required data.
  5. */
  6. #include <linux/thread_info.h>
  7. #define DEFINE(sym, val) \
  8. asm volatile("\n->" #sym " %0 " #val : : "i" (val))
  9. #define BLANK() asm volatile("\n->" : : )
  10. #define OFFSET(sym, str, mem) \
  11. DEFINE(sym, offsetof(struct str, mem));
  12. void foo(void)
  13. {
  14. OFFSET(TI_task, thread_info, task);
  15. OFFSET(TI_exec_domain, thread_info, exec_domain);
  16. OFFSET(TI_flags, thread_info, flags);
  17. OFFSET(TI_cpu, thread_info, cpu);
  18. OFFSET(TI_preempt_count, thread_info, preempt_count);
  19. OFFSET(TI_restart_block, thread_info, restart_block);
  20. }