Fix ucontext conversion macros. From Christian Limpach.

This commit is contained in:
martin 2003-11-11 16:21:05 +00:00
parent bb69a241e8
commit 3e8ef3d56a
1 changed files with 22 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pthread_md.h,v 1.2 2003/01/18 10:34:22 thorpej Exp $ */
/* $NetBSD: pthread_md.h,v 1.3 2003/11/11 16:21:05 martin Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -61,21 +61,35 @@ pthread__sp(void)
*/
#define PTHREAD_UCONTEXT_TO_REG(reg, uc) do { \
memcpy(&(reg)->r_tstate, &(uc)->uc_mcontext.__gregs, sizeof(__gregset_t));\
memcpy(&(reg)->r_tstate, &(uc)->uc_mcontext.__gregs, \
_REG_Y * sizeof(__greg_t)); \
(reg)->r_y = (uc)->uc_mcontext.__gregs[_REG_Y]; \
memcpy(&(reg)->r_global[1], &(uc)->uc_mcontext.__gregs[_REG_G1],\
(_REG_O7 - _REG_G1 + 1) * sizeof(__greg_t)); \
(reg)->r_global[0] = 0; \
} while (/*CONSTCOND*/0)
#define PTHREAD_REG_TO_UCONTEXT(uc, reg) do { \
memcpy(&(uc)->uc_mcontext.__gregs, &(reg)->r_tstate, sizeof(__gregset_t));\
memcpy(&(uc)->uc_mcontext.__gregs, &(reg)->r_tstate, \
_REG_Y * sizeof(__greg_t)); \
(uc)->uc_mcontext.__gregs[_REG_Y] = (reg)->r_y; \
memcpy(&(uc)->uc_mcontext.__gregs[_REG_G1], &(reg)->r_global[1],\
(_REG_O7 - _REG_G1 + 1) * sizeof(__greg_t)); \
(uc)->uc_flags = ((uc)->uc_flags | _UC_CPU) & ~_UC_USER; \
} while (/*CONSTCOND*/0)
#define PTHREAD_UCONTEXT_TO_FPREG(freg, uc) \
memcpy((freg), &(uc)->uc_mcontext.__fpregs, \
sizeof(struct fpreg)) \
#define PTHREAD_UCONTEXT_TO_FPREG(freg, uc) do { \
memcpy((freg)->fr_regs, \
&(uc)->uc_mcontext.__fpregs.__fpu_fr.__fpu_dregs, \
32*sizeof(double)); \
(freg)->fr_fsr = (uc)->uc_mcontext.__fpregs.__fpu_fsr; \
} while (/*CONSTCOND*/0)
#define PTHREAD_FPREG_TO_UCONTEXT(uc, freg) do { \
memcpy(&(uc)->uc_mcontext.__fpregs, (freg), \
sizeof(struct fpreg)); \
memcpy(&(uc)->uc_mcontext.__fpregs.__fpu_fr.__fpu_dregs, \
(freg)->fr_regs, \
32*sizeof(double)); \
(uc)->uc_mcontext.__fpregs.__fpu_fsr = (freg)->fr_fsr; \
(uc)->uc_flags = ((uc)->uc_flags | _UC_FPU) & ~_UC_USER; \
} while (/*CONSTCOND*/0)