Also, use need_hop_back() instead of on_extra_stack() in code that determines whether or not to call stack_hop_back().
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/stacks.c | 8 ++++---- src/stacks.h | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/stacks.c b/src/stacks.c index dd955fb..4fd70a7 100644 --- a/src/stacks.c +++ b/src/stacks.c @@ -115,7 +115,7 @@ u8 ExtraStack[BUILD_EXTRA_STACK_SIZE+1] VARLOW __aligned(8); u8 *StackPos VARLOW;
// Test if currently on the extra stack -static inline int +int on_extra_stack(void) { return MODE16 && GET_SEG(SS) == SEG_LOW && getesp() > (u32)ExtraStack; @@ -197,7 +197,7 @@ void VISIBLE16 _farcall16(struct bregs *callregs, u16 callregseg) { ASSERT16(); - if (on_extra_stack()) { + if (need_hop_back()) { stack_hop_back((u32)callregs, callregseg, _farcall16); return; } @@ -384,7 +384,7 @@ fail: void VISIBLE16 check_irqs(void) { - if (on_extra_stack()) { + if (need_hop_back()) { stack_hop_back(0, 0, check_irqs); return; } @@ -416,7 +416,7 @@ yield(void) void VISIBLE16 wait_irq(void) { - if (on_extra_stack()) { + if (need_hop_back()) { stack_hop_back(0, 0, wait_irq); return; } diff --git a/src/stacks.h b/src/stacks.h index 9d3422f..265b404 100644 --- a/src/stacks.h +++ b/src/stacks.h @@ -9,6 +9,7 @@ u32 call32(void *func, u32 eax, u32 errret); extern u8 ExtraStack[], *StackPos; u32 stack_hop(u32 eax, u32 edx, void *func); u32 stack_hop_back(u32 eax, u32 edx, void *func); +int on_extra_stack(void); struct bregs; inline void farcall16(struct bregs *callregs); inline void farcall16big(struct bregs *callregs); @@ -35,4 +36,13 @@ int wait_preempt(void); void check_preempt(void); u32 call32_params(void *func, u32 eax, u32 edx, u32 ecx, u32 errret);
+// Inline functions + +// Check if a call to stack_hop_back is needed. +static inline int +need_hop_back(void) +{ + return on_extra_stack(); +} + #endif // stacks.h