diff options
author | Eric Jackson <ericj@cvs.openbsd.org> | 2000-07-27 18:32:36 +0000 |
---|---|---|
committer | Eric Jackson <ericj@cvs.openbsd.org> | 2000-07-27 18:32:36 +0000 |
commit | cdbd329bc108fa68d9f144443b031125e23e9a1c (patch) | |
tree | 4644f97b9af7edb27696dd7ab218d789449c534f | |
parent | 3388e93c0e8ad61b4c319241f7c2cbf842ef48f4 (diff) |
some cleanup and add the emul_flags_translate from netbsd to translate
flags. deraadt@ OK
-rw-r--r-- | sys/compat/common/compat_util.c | 46 | ||||
-rw-r--r-- | sys/compat/common/compat_util.h | 36 |
2 files changed, 58 insertions, 24 deletions
diff --git a/sys/compat/common/compat_util.c b/sys/compat/common/compat_util.c index 89cba00ae75..7ec53eb5bb2 100644 --- a/sys/compat/common/compat_util.c +++ b/sys/compat/common/compat_util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: compat_util.c,v 1.5 1996/12/08 14:25:46 niklas Exp $ */ +/* $OpenBSD: compat_util.c,v 1.6 2000/07/27 18:32:35 ericj Exp $ */ /* $NetBSD: compat_util.c,v 1.4 1996/03/14 19:31:45 christos Exp $ */ /* @@ -169,3 +169,47 @@ bad: free(buf, M_TEMP); return error; } + +/* + * Translate one set of flags to another, based on the entries in + * the given table. If 'leftover' is specified, it is filled in + * with any flags which could not be translated. + */ +unsigned long +emul_flags_translate(tab, in, leftover) + const struct emul_flags_xtab *tab; + unsigned long in; + unsigned long *leftover; +{ + unsigned long out; + + for (out = 0; tab->omask != 0; tab++) { + if ((in & tab->omask) == tab->oval) { + in &= ~tab->omask; + out |= tab->nval; + } + } + if (leftover != NULL) + *leftover = in; + return (out); +} + +caddr_t +stackgap_init(e) + struct emul *e; +{ +#define szsigcode ((caddr_t)(e->e_esigcode - e->e_sigcode)) + return STACKGAPBASE; +#undef szsigcode +} + +void * +stackgap_alloc(sgp, sz) + caddr_t *sgp; + size_t sz; +{ + void *p = (void *) *sgp; + + *sgp += ALIGN(sz); + return p; +} diff --git a/sys/compat/common/compat_util.h b/sys/compat/common/compat_util.h index e2b56e911ed..ccfb6f594bf 100644 --- a/sys/compat/common/compat_util.h +++ b/sys/compat/common/compat_util.h @@ -1,4 +1,4 @@ -/* $OpenBSD: compat_util.h,v 1.3 1999/09/17 09:39:21 deraadt Exp $ */ +/* $OpenBSD: compat_util.h,v 1.4 2000/07/27 18:32:35 ericj Exp $ */ /* $NetBSD: compat_util.h,v 1.1 1995/06/24 20:16:05 christos Exp $ */ /* @@ -33,38 +33,28 @@ #ifndef _COMPAT_UTIL_H_ #define _COMPAT_UTIL_H_ -#include <sys/param.h> #include <vm/vm.h> #include <vm/vm_param.h> #include <sys/exec.h> -#include <sys/cdefs.h> -#include <sys/proc.h> -static __inline caddr_t stackgap_init __P((struct emul *)); -static __inline void *stackgap_alloc __P((caddr_t *, size_t)); +struct emul; +/* struct proc; */ -static __inline caddr_t -stackgap_init(e) - struct emul *e; -{ -#define szsigcode ((caddr_t)(e->e_esigcode - e->e_sigcode)) - return STACKGAPBASE; -} +caddr_t stackgap_init __P((struct emul *)); +void *stackgap_alloc __P((caddr_t *, size_t)); - -static __inline void * -stackgap_alloc(sgp, sz) - caddr_t *sgp; - size_t sz; -{ - void *p = (void *) *sgp; - *sgp += ALIGN(sz); - return p; -} +struct emul_flags_xtab { + unsigned long omask; + unsigned long oval; + unsigned long nval; +}; int emul_find __P((struct proc *, caddr_t *, const char *, char *, char **, int)); +unsigned long emul_flags_translate(const struct emul_flags_xtab *tab, + unsigned long in, unsigned long *leftover); + #define CHECK_ALT_EXIST(p, sgp, root, path) \ emul_find(p, sgp, root, path, &(path), 0) |