Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/common implement a simple function, emul_flags_tr...



details:   https://anonhg.NetBSD.org/src/rev/4d73fd6c6868
branches:  trunk
changeset: 472175:4d73fd6c6868
user:      cgd <cgd%NetBSD.org@localhost>
date:      Sat Apr 24 02:56:06 1999 +0000

description:
implement a simple function, emul_flags_translate() to do table-based
flags translation.

diffstat:

 sys/compat/common/compat_util.c |  24 +++++++++++++++++++++++-
 sys/compat/common/compat_util.h |  11 ++++++++++-
 2 files changed, 33 insertions(+), 2 deletions(-)

diffs (69 lines):

diff -r c6319cecfcb1 -r 4d73fd6c6868 sys/compat/common/compat_util.c
--- a/sys/compat/common/compat_util.c   Sat Apr 24 00:41:39 1999 +0000
+++ b/sys/compat/common/compat_util.c   Sat Apr 24 02:56:06 1999 +0000
@@ -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 @@
        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;
diff -r c6319cecfcb1 -r 4d73fd6c6868 sys/compat/common/compat_util.h
--- a/sys/compat/common/compat_util.h   Sat Apr 24 00:41:39 1999 +0000
+++ b/sys/compat/common/compat_util.h   Sat Apr 24 02:56:06 1999 +0000
@@ -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) \



Home | Main Index | Thread Index | Old Index