From a6cc46f9c7752bbd15729e684d4428adbefd4069 Mon Sep 17 00:00:00 2001 From: marcel Date: Thu, 26 Jun 2003 03:55:58 +0000 Subject: Implement _thr_enter_uts() and _thr_switch() as inline functions to minimize the amount and complexity of assembly code that needs to be written. This way the core functionality is spread over 3 elementary functions that don't have to do anything that can more easily and more safely be done in C. As such, assembly code will only have to know about the definition of mcontext_t. The runtime cost of not having these functions being inlined is less important than the cleanliness and maintainability of the code at this stage of the implementation. --- lib/libkse/arch/ia64/include/pthread_md.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'lib/libkse/arch/ia64') diff --git a/lib/libkse/arch/ia64/include/pthread_md.h b/lib/libkse/arch/ia64/include/pthread_md.h index 0965435..94e05a0 100644 --- a/lib/libkse/arch/ia64/include/pthread_md.h +++ b/lib/libkse/arch/ia64/include/pthread_md.h @@ -41,4 +41,34 @@ struct ksd { int ksd_size; }; +void _ia64_enter_uts(kse_func_t uts, struct kse_mailbox *km, void *stack, + size_t stacksz); +int _ia64_restore_context(mcontext_t *mc, intptr_t val, intptr_t *loc); +int _ia64_save_context(mcontext_t *mc); + +static __inline int +_thread_enter_uts(struct kse_thr_mailbox *tm, struct kse_mailbox *km) +{ + if (tm == NULL) + return (-1); + if (!_ia64_save_context(&tm->tm_context.uc_mcontext)) { + _ia64_enter_uts(km->km_func, km, km->km_stack.ss_sp, + km->km_stack.ss_size); + /* We should not reach here. */ + return (-1); + } + return (0); +} + +static __inline int +_thread_switch(struct kse_thr_mailbox *tm, struct kse_thr_mailbox **thrp) +{ + if (tm == NULL) + return (-1); + _ia64_restore_context(&tm->tm_context.uc_mcontext, (intptr_t)tm, + (intptr_t*)thrp); + /* We should not reach here. */ + return (-1); +} + #endif /* _PTHREAD_MD_H_ */ -- cgit v1.1