Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: md-os.c 7617 2007-03-29 23:22:07Z twisti $
+ $Id: md-os.c 7864 2007-05-03 21:17:26Z twisti $
*/
{
ucontext_t *_uc;
mcontext_t *_mc;
+ unsigned long *_gregs;
u1 *pv;
u1 *sp;
u1 *ra;
java_objectheader *o;
_uc = (ucontext_t *) _p;
- _mc = _uc->uc_mcontext.uc_regs;
- pv = (u1 *) _mc->gregs[REG_PV];
- sp = (u1 *) _mc->gregs[REG_SP];
- ra = (u1 *) _mc->gregs[PT_LNK]; /* this is correct for leafs */
- xpc = (u1 *) _mc->gregs[PT_NIP];
+#if defined(__UCLIBC__)
+ _mc = &(_uc->uc_mcontext);
+ _gregs = _mc->regs->gpr;
+#else
+ _mc = _uc->uc_mcontext.uc_regs;
+ _gregs = _mc->gregs;
+#endif
+
+ pv = (u1 *) _gregs[REG_PV];
+ sp = (u1 *) _gregs[REG_SP];
+ ra = (u1 *) _gregs[PT_LNK]; /* this is correct for leafs */
+ xpc = (u1 *) _gregs[PT_NIP];
/* get exception-throwing instruction */
disp = M_INSTR_OP2_IMM_I(mcode);
d = M_INSTR_OP2_IMM_D(mcode);
- val = _mc->gregs[d];
+ val = _gregs[d];
/* check for special-load */
/* This is a normal NPE: addr must be NULL and the NPE-type
define is 0. */
- addr = _mc->gregs[s1];
+ addr = _gregs[s1];
type = EXCEPTION_HARDWARE_NULLPOINTER;
if (addr != 0)
/* set registers */
- _mc->gregs[REG_ITMP1_XPTR] = (ptrint) o;
- _mc->gregs[REG_ITMP2_XPC] = (ptrint) xpc;
- _mc->gregs[PT_NIP] = (ptrint) asm_handle_exception;
+ _gregs[REG_ITMP1_XPTR] = (ptrint) o;
+ _gregs[REG_ITMP2_XPC] = (ptrint) xpc;
+ _gregs[PT_NIP] = (ptrint) asm_handle_exception;
}
{
ucontext_t *_uc;
mcontext_t *_mc;
+ unsigned long *_gregs;
u1 *pv;
u1 *sp;
u1 *ra;
java_objectheader *o;
_uc = (ucontext_t *) _p;
- _mc = _uc->uc_mcontext.uc_regs;
- pv = (u1 *) _mc->gregs[REG_PV];
- sp = (u1 *) _mc->gregs[REG_SP];
- ra = (u1 *) _mc->gregs[PT_LNK]; /* this is correct for leafs */
- xpc = (u1 *) _mc->gregs[PT_NIP];
+#if defined(__UCLIBC__)
+ _mc = &(_uc->uc_mcontext);
+ _gregs = _mc->regs->gpr;
+#else
+ _mc = _uc->uc_mcontext.uc_regs;
+ _gregs = _mc->gregs;
+#endif
+
+ pv = (u1 *) _gregs[REG_PV];
+ sp = (u1 *) _gregs[REG_SP];
+ ra = (u1 *) _gregs[PT_LNK]; /* this is correct for leafs */
+ xpc = (u1 *) _gregs[PT_NIP];
/* get exception-throwing instruction */
/* for now we only handle ArrayIndexOutOfBoundsException */
type = EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS;
- val = _mc->gregs[s1];
+ val = _gregs[s1];
/* generate appropriate exception */
/* set registers */
- _mc->gregs[REG_ITMP1_XPTR] = (ptrint) o;
- _mc->gregs[REG_ITMP2_XPC] = (ptrint) xpc;
- _mc->gregs[PT_NIP] = (ptrint) asm_handle_exception;
+ _gregs[REG_ITMP1_XPTR] = (ptrint) o;
+ _gregs[REG_ITMP2_XPC] = (ptrint) xpc;
+ _gregs[PT_NIP] = (ptrint) asm_handle_exception;
}
#if defined(ENABLE_THREADS)
void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
{
- threadobject *tobj;
- ucontext_t *_uc;
- mcontext_t *_mc;
- u1 *pc;
+ threadobject *tobj;
+ ucontext_t *_uc;
+ mcontext_t *_mc;
+ unsigned long *_gregs;
+ u1 *pc;
tobj = THREADOBJECT;
_uc = (ucontext_t *) _p;
- _mc = _uc->uc_mcontext.uc_regs;
- pc = (u1 *) _mc->gregs[PT_NIP];
+#if defined(__UCLIBC__)
+ _mc = &(_uc->uc_mcontext);
+ _gregs = _mc->regs->gpr;
+#else
+ _mc = _uc->uc_mcontext.uc_regs;
+ _gregs = _mc->gregs;
+#endif
+
+ pc = (u1 *) _gregs[PT_NIP];
tobj->pc = pc;
}
-void thread_restartcriticalsection(ucontext_t *_uc)
+/* md_critical_section_restart *************************************************
+
+ Search the critical sections tree for a matching section and set
+ the PC to the restart point, if necessary.
+
+*******************************************************************************/
+
+void md_critical_section_restart(ucontext_t *_uc)
{
- mcontext_t *_mc;
- u1 *pc;
- void *critical;
+ mcontext_t *_mc;
+ unsigned long *_gregs;
+ u1 *pc;
+ u1 *npc;
+
+#if defined(__UCLIBC__)
+ _mc = &(_uc->uc_mcontext);
+ _gregs = _mc->regs->gpr;
+#else
+ _mc = _uc->uc_mcontext.uc_regs;
+ _gregs = _mc->gregs;
+#endif
- _mc = _uc->uc_mcontext.uc_regs;
+ pc = (u1 *) _gregs[PT_NIP];
- pc = (u1 *) _mc->gregs[PT_NIP];
+ npc = critical_find_restart_point(pc);
- critical = critical_find_restart_point(pc);
+ if (npc != NULL) {
+ log_println("md_critical_section_restart: pc=%p, npc=%p", pc, npc);
- if (critical)
- _mc->gregs[PT_NIP] = (ptrint) critical;
+ _gregs[PT_NIP] = (ptrint) npc;
+ }
}
#endif