mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-25 11:11:35 +01:00
aarch64 basically done, but missing: - other archs - maybe convert main.c into C++ to use templates? - full review of ASSERT_EQ calling convention issues not seen by tests by chance - documentation
33 lines
645 B
C
33 lines
645 B
C
/* https://github.com/cirosantilli/linux-kernel-module-cheat#userland-assembly-c-standard-library */
|
|
|
|
#ifndef COMMON_H
|
|
#define COMMON_H
|
|
|
|
/* We define in this header only macros that are the same on all archs. */
|
|
|
|
/* common_arch.h contains arch specific macros. */
|
|
#include "common_arch.h"
|
|
|
|
.extern \
|
|
exit, \
|
|
printf, \
|
|
puts \
|
|
;
|
|
|
|
/* Assert that the given branch instruction is taken. */
|
|
#define ASSERT(branch_if_pass) \
|
|
branch_if_pass 1f; \
|
|
FAIL; \
|
|
1: \
|
|
;
|
|
|
|
#ifndef ASSERT_EQ_REG
|
|
/* Assert that a register equals another register. */
|
|
#define ASSERT_EQ_REG(reg1, reg2) \
|
|
cmp reg1, reg2; \
|
|
ASSERT(beq); \
|
|
;
|
|
#endif
|
|
|
|
#endif
|