implement a simple function, emul_flags_translate() to do table-based

flags translation.
This commit is contained in:
cgd 1999-04-24 02:56:06 +00:00
parent 9ce6dc617d
commit 5b217baeb1
2 changed files with 33 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat_util.c,v 1.11 1999/02/14 14:32:02 christos Exp $ */
/* $NetBSD: compat_util.c,v 1.12 1999/04/24 02:56:06 cgd Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
@ -190,6 +190,28 @@ bad:
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(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;

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat_util.h,v 1.5 1999/02/09 20:16:08 christos Exp $ */
/* $NetBSD: compat_util.h,v 1.6 1999/04/24 02:56:06 cgd Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
@ -70,12 +70,21 @@
struct emul;
struct proc;
struct emul_flags_xtab {
unsigned long omask;
unsigned long oval;
unsigned long nval;
};
caddr_t stackgap_init __P((struct emul *));
void *stackgap_alloc __P((caddr_t *, size_t));
int emul_find __P((struct proc *, caddr_t *, const char *, const char *,
const char **, int));
unsigned long emul_flags_translate(const struct emul_flags_xtab *tab,
unsigned long in, unsigned long *leftover);
void compat_offseterr __P((struct vnode *, char *msg));
#define CHECK_ALT_EXIST(p, sgp, root, path) \