Add a #define that expands to the compat wrapper for sigaltstack1().

Use it for the netbsd32_compat_13.c version of the code.
This commit is contained in:
dsl 2007-06-03 14:59:46 +00:00
parent 8ed58e93b0
commit 938cde68e5
2 changed files with 52 additions and 33 deletions

View File

@ -0,0 +1,46 @@
/* $NetBSD: compat_sigaltstack.h,v 1.1 2007/06/03 14:59:46 dsl Exp $ */
/* Wrapper for calling sigaltstack1() from compat (or other) code */
/* Maybe these definitions could be global. */
#ifdef SCARG_P32
/* compat32 */
#define SCARG_COMPAT_PTR(uap,p) SCARG_P32(uap, p)
#define COMPAT_GET_PTR(p) NETBSD32PTR64(p)
#define COMPAT_SET_PTR(p, v) NETBSD32PTR32(p, v)
#else
/* not a size change */
#define SCARG_COMPAT_PTR(uap,p) SCARG(uap, p)
#define COMPAT_GET_PTR(p) (p)
#define COMPAT_SET_PTR(p, v) ((p) = (v))
#endif
#define compat_sigaltstack(uap, compat_ss) do { \
struct compat_ss css; \
struct sigaltstack nss, oss; \
int error; \
\
if (SCARG_COMPAT_PTR(uap, nss)) { \
error = copyin(SCARG_COMPAT_PTR(uap, nss), &css, sizeof css); \
if (error) \
return error; \
nss.ss_sp = COMPAT_GET_PTR(css.ss_sp); \
nss.ss_size = css.ss_size; \
nss.ss_flags = css.ss_flags; \
} \
\
error = sigaltstack1(l, SCARG_COMPAT_PTR(uap, nss) ? &nss : 0, \
SCARG_COMPAT_PTR(uap, oss) ? &oss : 0); \
if (error) \
return (error); \
\
if (SCARG_COMPAT_PTR(uap, oss)) { \
COMPAT_SET_PTR(css.ss_sp, oss.ss_sp); \
css.ss_size = oss.ss_size; \
css.ss_flags = oss.ss_flags; \
error = copyout(&css, SCARG_COMPAT_PTR(uap, oss), sizeof(css)); \
if (error) \
return (error); \
} \
return (0); \
} while (0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_compat_13.c,v 1.20 2007/06/03 11:09:35 dsl Exp $ */
/* $NetBSD: netbsd32_compat_13.c,v 1.21 2007/06/03 14:59:46 dsl Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_13.c,v 1.20 2007/06/03 11:09:35 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_13.c,v 1.21 2007/06/03 14:59:46 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -46,43 +46,16 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_13.c,v 1.20 2007/06/03 11:09:35 dsl
#include <compat/sys/signal.h>
#include <compat/sys/signalvar.h>
#include <compat/common/compat_sigaltstack.h>
int
compat_13_netbsd32_sigaltstack13(l, v, retval)
struct lwp *l;
void *v;
register_t *retval;
{
struct compat_13_netbsd32_sigaltstack13_args /* {
syscallarg(const netbsd32_sigaltstack13p_t) nss;
syscallarg(netbsd32_sigaltstack13p_t) oss;
} */ *uap = v;
struct netbsd32_sigaltstack13 s32ss;
struct sigaltstack nbss, obss;
int error;
if (SCARG(uap, nss)) {
error = copyin(SCARG_P32(uap, nss), &s32ss, sizeof s32ss);
if (error)
return (error);
nss.ss_sp = s32ss.ss_sp;
nss.ss_size = s32ss.ss_size;
nss.ss_flags = s32ss.ss_flags;
}
error = sigaltstack1(l,
SCARG(uap, nss) ? &nss : 0, SCARG(uap, oss) ? &oss : 0);
if (error)
return (error);
if (SCARG(uap, oss)) {
s32ss.ss_sp = oss.ss_sp;
s32ss.ss_size =onss.ss_size;
s32ss.ss_flags = oss.ss_flags;
error = copyout(&s32ss, SCARG_P32(uap, oss), sizeof(s32ss));
if (error)
return (error);
}
return (0);
struct compat_13_netbsd32_sigaltstack13_args *uap = v;
compat_sigaltstack(uap, netbsd32_sigaltstack13);
}