Fix ucontext32_t on AMD64. Add optional compile time assertions for

ucontext_t and ucontext32_t to ensure that they don't change.
Provide the constants for AMD64, ARM, i386, and M68K.
This commit is contained in:
joerg 2011-02-23 02:58:38 +00:00
parent 37ff8deec2
commit 13d02bb5bf
7 changed files with 43 additions and 11 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_machdep.c,v 1.70 2011/02/07 03:54:45 chs Exp $ */
/* $NetBSD: netbsd32_machdep.c,v 1.71 2011/02/23 02:58:38 joerg Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.70 2011/02/07 03:54:45 chs Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.71 2011/02/23 02:58:38 joerg Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@ -870,7 +870,7 @@ cpu_setmcontext32(struct lwp *l, const mcontext32_t *mcp, unsigned int flags)
fpusave_lwp(l, false);
}
memcpy(&pcb->pcb_savefpu.fp_fxsave, &mcp->__fpregs,
sizeof (mcp->__fpregs));
+ sizeof (pcb->pcb_savefpu.fp_fxsave));
/* If not set already. */
l->l_md.md_flags |= MDP_USEDFPU;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mcontext.h,v 1.11 2008/10/26 00:08:15 mrg Exp $ */
/* $NetBSD: mcontext.h,v 1.12 2011/02/23 02:58:39 joerg Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -80,6 +80,7 @@ typedef struct {
#define _UC_SETSTACK 0x00010000
#define _UC_CLRSTACK 0x00020000
#define __UCONTEXT_SIZE 784
#ifdef _KERNEL
@ -116,14 +117,31 @@ typedef __greg32_t __gregset32_t[_NGREG32];
/*
* Floating point register state
*/
typedef struct fxsave64 __fpregset32_t;
typedef struct {
union {
struct {
int __fp_state[27]; /* Environment and registers */
int __fp_status; /* Software status word */
} __fpchip_state;
struct {
char __fp_emul[246];
char __fp_epad[2];
} __fp_emul_space;
struct {
char __fp_xmm[512];
} __fp_xmm_state;
int __fp_fpregs[128];
} __fp_reg_set;
int __fp_wregs[33]; /* Weitek? */
} __fpregset32_t;
typedef struct {
__gregset32_t __gregs;
__fpregset32_t __fpregs;
} mcontext32_t;
#define _UC_MACHINE_PAD32 5
#define _UC_MACHINE32_PAD 5
#define __UCONTEXT32_SIZE 776
struct trapframe;
struct lwp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mcontext.h,v 1.6 2008/04/28 20:23:14 martin Exp $ */
/* $NetBSD: mcontext.h,v 1.7 2011/02/23 02:58:39 joerg Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@ -104,4 +104,6 @@ typedef struct {
#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc)
#define __UCONTEXT_SIZE 256
#endif /* !_ARM_MCONTEXT_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mcontext.h,v 1.7 2008/04/28 20:23:24 martin Exp $ */
/* $NetBSD: mcontext.h,v 1.8 2011/02/23 02:58:39 joerg Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -123,4 +123,6 @@ typedef struct {
#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc)
#define __UCONTEXT_SIZE 776
#endif /* !_I386_MCONTEXT_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mcontext.h,v 1.6 2008/04/28 20:23:26 martin Exp $ */
/* $NetBSD: mcontext.h,v 1.7 2011/02/23 02:58:39 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -105,4 +105,6 @@ typedef struct {
#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc)
#define __UCONTEXT_SIZE 1024
#endif /* !_M68K_MCONTEXT_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ucontext.h,v 1.3 2008/04/28 20:23:46 martin Exp $ */
/* $NetBSD: ucontext.h,v 1.4 2011/02/23 02:58:39 joerg Exp $ */
/*-
* Copyright (c) 1999, 2003 The NetBSD Foundation, Inc.
@ -53,6 +53,10 @@ struct __ucontext32 {
#endif
};
#ifdef __UCONTEXT32_SIZE
__CTASSERT(sizeof(ucontext32_t) == __UCONTEXT32_SIZE)
#endif
#endif /* COMPAT_NETBSD32 && _KERNEL */
#ifdef _KERNEL

View File

@ -1,4 +1,4 @@
/* $NetBSD: ucontext.h,v 1.12 2009/11/18 12:29:22 yamt Exp $ */
/* $NetBSD: ucontext.h,v 1.13 2011/02/23 02:58:40 joerg Exp $ */
/*-
* Copyright (c) 1999, 2003 The NetBSD Foundation, Inc.
@ -77,6 +77,10 @@ struct __ucontext {
#ifdef _KERNEL
struct lwp;
#ifdef __UCONTEXT_SIZE
__CTASSERT(sizeof(ucontext_t) == __UCONTEXT_SIZE)
#endif
void getucontext(struct lwp *, ucontext_t *);
void getucontext_sa(struct lwp *, ucontext_t *);
int setucontext(struct lwp *, const ucontext_t *);