X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/92f6e64a6da763c45ff9f4ab5eafcab3d8766dcb..b60166b327a9108b07e3069fa6568a451529ffd9:/lunaix-os/includes/lunaix/kpreempt.h diff --git a/lunaix-os/includes/lunaix/kpreempt.h b/lunaix-os/includes/lunaix/kpreempt.h new file mode 100644 index 0000000..d20deba --- /dev/null +++ b/lunaix-os/includes/lunaix/kpreempt.h @@ -0,0 +1,18 @@ +#ifndef __LUNAIX_KPREEMPT_H +#define __LUNAIX_KPREEMPT_H + +#include + +#define _preemptible __attribute__((section(".kf.preempt"))) + +#define ensure_preempt_caller() \ + do { \ + extern int __kf_preempt_start[]; \ + extern int __kf_preempt_end[]; \ + ptr_t _retaddr = abi_get_retaddr(); \ + assert_msg((ptr_t)__kf_preempt_start <= _retaddr \ + && _retaddr < (ptr_t)__kf_preempt_end, \ + "caller must be kernel preemptible"); \ + } while(0) + +#endif /* __LUNAIX_KPREEMPT_H */