#import <mach-o/loader.h>
#ifdef m68k
#import <mach/m68k/thread_status.h>
#endif
#ifdef __i386__
#import <mach/i386/thread_status.h>
#endif
#ifdef hppa
#import <mach/hppa/thread_status.h>
#endif
#ifdef sparc
#import <mach/sparc/thread_status.h>
#endif
#ifdef __ppc__
#import <mach/ppc/thread_status.h>
#endif
unsigned long
get_entry_point(
struct thread_command *thread_command)
{
unsigned long *p, flavor, count;
#ifdef m68k
struct m68k_thread_state_regs *cpu;
#endif
#ifdef __i386__
i386_thread_state_t *cpu;
#endif
#ifdef hppa
struct hp_pa_frame_thread_state *cpu;
#endif
#ifdef sparc
struct sparc_thread_state_regs *cpu;
#endif
#ifdef __ppc__
ppc_thread_state_t *cpu;
#endif
p = (unsigned long *)(((char *)thread_command) +
sizeof(struct thread_command));
for(;;){
flavor = *p++;
count = *p++;
#ifdef m68k
if(flavor == M68K_THREAD_STATE_REGS){
cpu = (struct m68k_thread_state_regs *)p;
return(cpu->pc);
}
#endif
#ifdef __i386__
if(flavor == (unsigned long)i386_THREAD_STATE){
cpu = (i386_thread_state_t *)p;
return(cpu->eip);
}
#endif
#ifdef hppa
if(flavor == HPPA_FRAME_THREAD_STATE){
cpu = (struct hp_pa_frame_thread_state *)p;
return(cpu->ts_pcoq_front);
}
#endif
#ifdef sparc
if(flavor == SPARC_THREAD_STATE_REGS){
cpu = (struct sparc_thread_state_regs *)p;
return(cpu->regs.r_pc);
}
#endif
#ifdef __ppc__
if(flavor == PPC_THREAD_STATE){
cpu = (ppc_thread_state_t *)p;
return(cpu->srr0);
}
#endif
p += count;
}
}