implement a simple function, emul_flags_translate() to do table-based
flags translation.
This commit is contained in:
parent
9ce6dc617d
commit
5b217baeb1
|
@ -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.
|
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||||
|
@ -190,6 +190,28 @@ bad:
|
||||||
return error;
|
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
|
caddr_t
|
||||||
stackgap_init(e)
|
stackgap_init(e)
|
||||||
struct emul *e;
|
struct emul *e;
|
||||||
|
|
|
@ -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.
|
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||||
|
@ -70,12 +70,21 @@
|
||||||
struct emul;
|
struct emul;
|
||||||
struct proc;
|
struct proc;
|
||||||
|
|
||||||
|
struct emul_flags_xtab {
|
||||||
|
unsigned long omask;
|
||||||
|
unsigned long oval;
|
||||||
|
unsigned long nval;
|
||||||
|
};
|
||||||
|
|
||||||
caddr_t stackgap_init __P((struct emul *));
|
caddr_t stackgap_init __P((struct emul *));
|
||||||
void *stackgap_alloc __P((caddr_t *, size_t));
|
void *stackgap_alloc __P((caddr_t *, size_t));
|
||||||
|
|
||||||
int emul_find __P((struct proc *, caddr_t *, const char *, const char *,
|
int emul_find __P((struct proc *, caddr_t *, const char *, const char *,
|
||||||
const char **, int));
|
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));
|
void compat_offseterr __P((struct vnode *, char *msg));
|
||||||
|
|
||||||
#define CHECK_ALT_EXIST(p, sgp, root, path) \
|
#define CHECK_ALT_EXIST(p, sgp, root, path) \
|
||||||
|
|
Loading…
Reference in New Issue