This is mach_dep.c in view mode; [Download] [Up]
/* Routine to mark from registers that are preserved by the C compiler.
** This must be ported to every new architecture.
*/
/* This is a NeXT specific file. It makes things easier to follow.
** Right now I can only test the Motorola specific code.
**
** Jason
*/
#include "gc_private.h"
#include <mach/mach.h>
#include <mach/thread_status.h>
static void next_push_regs (void)
{
thread_t my_thread = thread_self ();
thread_array_t threads;
u_int t_cnt, reg_cnt, ndx, r_ndx;
thread_state_t state_regs[M68K_THREAD_STATE_REGS_COUNT];
thread_state_t user_regs[M68K_THREAD_STATE_USER_REG_COUNT];
kern_return_t stat;
stat = task_threads (task_self(), &threads, &t_cnt);
for (ndx = 0; ndx < t_cnt; ++ndx) {
if (threads[ndx] == my_thread)
continue;
reg_cnt = M68K_THREAD_STATE_REGS_COUNT;
stat = thread_get_state (threads[ndx],
M68K_THREAD_STATE_REGS, state_regs, ®_cnt);
if (stat == KERN_SUCCESS) {
for (r_ndx = 0; r_ndx < reg_cnt; ++r_ndx)
GC_push_one (state_regs[r_ndx]);
}
}
}
/* Do this in a seperate thread so it can get at all the other
** thread registers. A thread can't get its own registers in the same way.
*/
void GC_push_regs (void)
{
cthread_join (cthread_fork (next_push_regs, NULL));
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.