refactor: Optimize the context switch overhead
[lunaix-os.git] / lunaix-os / includes / arch / x86 / i386_abi.h
index 22481c9cc587334860596e7033984e3838957b79..8bc8cd20701e0d2e27dc4a2da63fc1b5474d7893 100644 (file)
@@ -1,9 +1,9 @@
 #ifndef __LUNAIX_I386ABI_H
 #define __LUNAIX_I386ABI_H
 
-#define store_retval(retval) __current->intr_ctx.registers.eax = (retval)
+#define store_retval(retval) __current->intr_ctx->registers.eax = (retval)
 
-#define store_retval_to(proc, retval) (proc)->intr_ctx.registers.eax = (retval)
+#define store_retval_to(proc, retval) (proc)->intr_ctx->registers.eax = (retval)
 
 #define j_usr(sp, pc)                                                          \
     asm volatile("movw %0, %%ax\n"                                             \
                  "r"(pc)                                                       \
                  : "eax", "memory");
 
+#define push_arg1(stack_ptr, arg) *((typeof((arg))*)(stack_ptr)--) = arg
+#define push_arg2(stack_ptr, arg1, arg2)                                       \
+    {                                                                          \
+        *((typeof((arg1))*)(stack_ptr)--) = arg1;                              \
+        *((typeof((arg2))*)(stack_ptr)--) = arg2;                              \
+    }
+#define push_arg3(stack_ptr, arg1, arg2, arg3)                                 \
+    {                                                                          \
+        *((typeof((arg1))*)(stack_ptr)--) = arg1;                              \
+        *((typeof((arg2))*)(stack_ptr)--) = arg2;                              \
+        *((typeof((arg3))*)(stack_ptr)--) = arg3;                              \
+    }
+#define push_arg4(stack_ptr, arg1, arg2, arg3, arg4)                           \
+    {                                                                          \
+        *((typeof((arg1))*)(stack_ptr)--) = arg1;                              \
+        *((typeof((arg2))*)(stack_ptr)--) = arg2;                              \
+        *((typeof((arg3))*)(stack_ptr)--) = arg3;                              \
+        *((typeof((arg4))*)(stack_ptr)--) = arg4;                              \
+    }
+
 #endif /* __LUNAIX_ABI_H */