Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/netbsd32 make netbsd32_copyargs() an inline



details:   https://anonhg.NetBSD.org/src/rev/9f5b5a2ff74a
branches:  trunk
changeset: 499926:9f5b5a2ff74a
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Dec 01 22:05:18 2000 +0000

description:
make netbsd32_copyargs() an inline

diffstat:

 sys/compat/netbsd32/netbsd32_exec.h |  55 ++++++++++++++++++++++++++++++++++--
 1 files changed, 52 insertions(+), 3 deletions(-)

diffs (74 lines):

diff -r 384d17a58731 -r 9f5b5a2ff74a sys/compat/netbsd32/netbsd32_exec.h
--- a/sys/compat/netbsd32/netbsd32_exec.h       Fri Dec 01 21:54:01 2000 +0000
+++ b/sys/compat/netbsd32/netbsd32_exec.h       Fri Dec 01 22:05:18 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_exec.h,v 1.6 2000/11/27 17:25:24 jdolecek Exp $       */
+/*     $NetBSD: netbsd32_exec.h,v 1.7 2000/12/01 22:05:18 jdolecek Exp $       */
 
 /*
  * Copyright (c) 1998 Matthew R. Green
@@ -54,8 +54,6 @@
 
 #ifdef EXEC_AOUT
 int exec_netbsd32_makecmds __P((struct proc *, struct exec_package *));
-void *netbsd32_copyargs __P((struct exec_package *, struct ps_strings *,
-       void *, void *));
 #endif
 #ifdef EXEC_ELF32
 int netbsd32_elf32_probe __P((struct proc *, struct exec_package *, void *,
@@ -64,4 +62,55 @@
        void *, void *));
 #endif /* EXEC_ELF32 */
 
+static __inline void *netbsd32_copyargs __P((struct exec_package *,
+       struct ps_strings *, void *, void *));
+
+/*
+ * We need to copy out all pointers as 32-bit values.
+ */
+static __inline void *
+netbsd32_copyargs(pack, arginfo, stack, argp)
+       struct exec_package *pack;
+       struct ps_strings *arginfo;
+       void *stack;
+       void *argp;
+{
+       u_int32_t *cpp = stack;
+       u_int32_t dp;
+       u_int32_t nullp = 0;
+       char *sp;
+       size_t len;
+       int argc = arginfo->ps_nargvstr;
+       int envc = arginfo->ps_nenvstr;
+
+       if (copyout(&argc, cpp++, sizeof(argc)))
+               return NULL;
+
+       dp = (u_long) (cpp + argc + envc + 2 + pack->ep_esch->es_arglen);
+       sp = argp;
+
+       /* XXX don't copy them out, remap them! */
+       arginfo->ps_argvstr = (char **)(u_long)cpp; /* remember location of argv for later */
+
+       for (; --argc >= 0; sp += len, dp += len) {
+               if (copyout(&dp, cpp++, sizeof(dp)) ||
+                   copyoutstr(sp, (char *)(u_long)dp, ARG_MAX, &len))
+                       return NULL;
+       }
+       if (copyout(&nullp, cpp++, sizeof(nullp)))
+               return NULL;
+
+       arginfo->ps_envstr = (char **)(u_long)cpp; /* remember location of envp for later */
+
+       for (; --envc >= 0; sp += len, dp += len) {
+               if (copyout(&dp, cpp++, sizeof(dp)) ||
+                   copyoutstr(sp, (char *)(u_long)dp, ARG_MAX, &len))
+                       return NULL;
+       }
+       if (copyout(&nullp, cpp++, sizeof(nullp)))
+               return NULL;
+
+       return cpp;
+}
+
 #endif /* !_NETBSD32_EXEC_H_ */



Home | Main Index | Thread Index | Old Index