common.h 645 B

123456789101112131415161718192021222324252627282930313233
  1. /* https://github.com/cirosantilli/linux-kernel-module-cheat#userland-assembly-c-standard-library */
  2. #ifndef COMMON_H
  3. #define COMMON_H
  4. /* We define in this header only macros that are the same on all archs. */
  5. /* common_arch.h contains arch specific macros. */
  6. #include "common_arch.h"
  7. .extern \
  8. exit, \
  9. printf, \
  10. puts \
  11. ;
  12. /* Assert that the given branch instruction is taken. */
  13. #define ASSERT(branch_if_pass) \
  14. branch_if_pass 1f; \
  15. FAIL; \
  16. 1: \
  17. ;
  18. #ifndef ASSERT_EQ_REG
  19. /* Assert that a register equals another register. */
  20. #define ASSERT_EQ_REG(reg1, reg2) \
  21. cmp reg1, reg2; \
  22. ASSERT(beq); \
  23. ;
  24. #endif
  25. #endif