summaryrefslogtreecommitdiffstats
path: root/lib/libkse/arch/ia64
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2003-06-26 03:55:58 +0000
committermarcel <marcel@FreeBSD.org>2003-06-26 03:55:58 +0000
commita6cc46f9c7752bbd15729e684d4428adbefd4069 (patch)
treeb0fde455c2721227a455a501f893666d59d73cf2 /lib/libkse/arch/ia64
parent96a2974d03abdc99936766ffe10848a8b7fb509f (diff)
downloadFreeBSD-src-a6cc46f9c7752bbd15729e684d4428adbefd4069.zip
FreeBSD-src-a6cc46f9c7752bbd15729e684d4428adbefd4069.tar.gz
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.
Diffstat (limited to 'lib/libkse/arch/ia64')
-rw-r--r--lib/libkse/arch/ia64/include/pthread_md.h30
1 files changed, 30 insertions, 0 deletions
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_ */
OpenPOWER on IntegriCloud