Pull down revision 1.3.6.1 by skrll@ (adapted to include reg::r_gbr).

struct mcontext != struct reg on sh3.

    Fix PTHREAD_UCONTEXT_TO_REG / PTHREAD_REG_TO_UCONTEXT to deal with this.
This commit is contained in:
uwe 2008-10-27 00:47:22 +00:00
parent 70eb15d9df
commit 47cd7b4502
1 changed files with 48 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pthread_md.h,v 1.4 2008/02/10 18:50:55 ad Exp $ */
/* $NetBSD: pthread_md.h,v 1.5 2008/10/27 00:47:22 uwe Exp $ */
/*
* Copyright 2003 Wasabi Systems, Inc.
@ -68,11 +68,55 @@ pthread__sp(void)
* libpthread_dbg.
*/
#define PTHREAD_UCONTEXT_TO_REG(reg, uc) \
memcpy((reg), &(uc)->uc_mcontext.__gregs[0], sizeof(*(reg)))
#define PTHREAD_UCONTEXT_TO_REG(reg, uc) do { \
(reg)->r_spc = (uc)->uc_mcontext.__gregs[_REG_PC]; \
(reg)->r_ssr = (uc)->uc_mcontext.__gregs[_REG_SR]; \
(reg)->r_pr = (uc)->uc_mcontext.__gregs[_REG_PR]; \
(reg)->r_mach = (uc)->uc_mcontext.__gregs[_REG_MACH]; \
(reg)->r_macl = (uc)->uc_mcontext.__gregs[_REG_MACL]; \
(reg)->r_r15 = (uc)->uc_mcontext.__gregs[_REG_R15]; \
(reg)->r_r14 = (uc)->uc_mcontext.__gregs[_REG_R14]; \
(reg)->r_r13 = (uc)->uc_mcontext.__gregs[_REG_R13]; \
(reg)->r_r12 = (uc)->uc_mcontext.__gregs[_REG_R12]; \
(reg)->r_r11 = (uc)->uc_mcontext.__gregs[_REG_R11]; \
(reg)->r_r10 = (uc)->uc_mcontext.__gregs[_REG_R10]; \
(reg)->r_r9 = (uc)->uc_mcontext.__gregs[_REG_R9]; \
(reg)->r_r8 = (uc)->uc_mcontext.__gregs[_REG_R8]; \
(reg)->r_r7 = (uc)->uc_mcontext.__gregs[_REG_R7]; \
(reg)->r_r6 = (uc)->uc_mcontext.__gregs[_REG_R6]; \
(reg)->r_r5 = (uc)->uc_mcontext.__gregs[_REG_R5]; \
(reg)->r_r4 = (uc)->uc_mcontext.__gregs[_REG_R4]; \
(reg)->r_r3 = (uc)->uc_mcontext.__gregs[_REG_R3]; \
(reg)->r_r2 = (uc)->uc_mcontext.__gregs[_REG_R2]; \
(reg)->r_r1 = (uc)->uc_mcontext.__gregs[_REG_R1]; \
(reg)->r_r0 = (uc)->uc_mcontext.__gregs[_REG_R0]; \
(reg)->r_gbr = (uc)->uc_mcontext.__gregs[_REG_GBR]; \
} while (/*CONSTCOND*/0)
#define PTHREAD_REG_TO_UCONTEXT(uc, reg) do { \
memcpy(&(uc)->uc_mcontext.__gregs[0], (reg), sizeof(*(reg))); \
(uc)->uc_mcontext.__gregs[_REG_GBR] = (reg)->r_gbr; \
(uc)->uc_mcontext.__gregs[_REG_PC] = (reg)->r_spc; \
(uc)->uc_mcontext.__gregs[_REG_SR] = (reg)->r_ssr; \
(uc)->uc_mcontext.__gregs[_REG_PR] = (reg)->r_pr; \
(uc)->uc_mcontext.__gregs[_REG_MACH] = (reg)->r_mach; \
(uc)->uc_mcontext.__gregs[_REG_MACL] = (reg)->r_macl; \
(uc)->uc_mcontext.__gregs[_REG_R15] = (reg)->r_r15; \
(uc)->uc_mcontext.__gregs[_REG_R14] = (reg)->r_r14; \
(uc)->uc_mcontext.__gregs[_REG_R13] = (reg)->r_r13; \
(uc)->uc_mcontext.__gregs[_REG_R12] = (reg)->r_r12; \
(uc)->uc_mcontext.__gregs[_REG_R11] = (reg)->r_r11; \
(uc)->uc_mcontext.__gregs[_REG_R10] = (reg)->r_r10; \
(uc)->uc_mcontext.__gregs[_REG_R9] = (reg)->r_r9; \
(uc)->uc_mcontext.__gregs[_REG_R8] = (reg)->r_r8; \
(uc)->uc_mcontext.__gregs[_REG_R7] = (reg)->r_r7; \
(uc)->uc_mcontext.__gregs[_REG_R6] = (reg)->r_r6; \
(uc)->uc_mcontext.__gregs[_REG_R5] = (reg)->r_r5; \
(uc)->uc_mcontext.__gregs[_REG_R4] = (reg)->r_r4; \
(uc)->uc_mcontext.__gregs[_REG_R3] = (reg)->r_r3; \
(uc)->uc_mcontext.__gregs[_REG_R2] = (reg)->r_r2; \
(uc)->uc_mcontext.__gregs[_REG_R1] = (reg)->r_r1; \
(uc)->uc_mcontext.__gregs[_REG_R0] = (reg)->r_r0; \
\
(uc)->uc_flags = ((uc)->uc_flags | _UC_CPU) & ~_UC_USER; \
} while (/*CONSTCOND*/0)