1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-12 09:58:36 +00:00

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.
This commit is contained in:
Marcel Moolenaar 2003-06-26 03:55:58 +00:00
parent 6833c6add5
commit 6351f43f14
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=116866
2 changed files with 60 additions and 0 deletions

View File

@ -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_ */

View File

@ -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_ */