From ff4eeac9d31b9d027c29e4fbd014d4ff9e2fc83a Mon Sep 17 00:00:00 2001 From: christos Date: Sun, 4 Feb 2001 22:59:26 +0000 Subject: [PATCH] cosmetic fixes. --- sys/compat/linux/arch/powerpc/linux_errno.h | 72 +++++++++---------- sys/compat/linux/arch/powerpc/linux_exec.h | 11 +-- .../linux/arch/powerpc/linux_exec_powerpc.c | 14 ++-- sys/compat/linux/arch/powerpc/linux_fcntl.h | 8 +-- sys/compat/linux/arch/powerpc/linux_machdep.c | 68 ++++++++++-------- sys/compat/linux/arch/powerpc/linux_ptrace.c | 30 ++++---- 6 files changed, 108 insertions(+), 95 deletions(-) diff --git a/sys/compat/linux/arch/powerpc/linux_errno.h b/sys/compat/linux/arch/powerpc/linux_errno.h index a27ae7436a18..d3449c3c6e93 100644 --- a/sys/compat/linux/arch/powerpc/linux_errno.h +++ b/sys/compat/linux/arch/powerpc/linux_errno.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux_errno.h,v 1.1 2001/01/19 12:27:13 manu Exp $ */ +/* $NetBSD: linux_errno.h,v 1.2 2001/02/04 22:59:26 christos Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -46,57 +46,57 @@ * From Linux's include/asm-ppc/errno.h */ #define LINUX_ENAMETOOLONG 36 -#define LINUX_ENOLCK 37 -#define LINUX_ENOSYS 38 +#define LINUX_ENOLCK 37 +#define LINUX_ENOSYS 38 #define LINUX_ENOTEMPTY 39 -#define LINUX_ELOOP 40 +#define LINUX_ELOOP 40 #define LINUX_EWOULDBLOCK LINUX_EAGAIN -#define LINUX_ENOMSG 42 -#define LINUX_EIDRM 43 -#define LINUX_ECHRNG 44 +#define LINUX_ENOMSG 42 +#define LINUX_EIDRM 43 +#define LINUX_ECHRNG 44 #define LINUX_EL2NSYNC 45 -#define LINUX_EL3HLT 46 -#define LINUX_EL3RST 47 -#define LINUX_ELNRNG 48 +#define LINUX_EL3HLT 46 +#define LINUX_EL3RST 47 +#define LINUX_ELNRNG 48 #define LINUX_EUNATCH 49 -#define LINUX_ENOCSI 50 -#define LINUX_EL2HLT 51 -#define LINUX_EBADE 52 -#define LINUX_EBADR 53 -#define LINUX_EXFULL 54 -#define LINUX_ENOANO 55 +#define LINUX_ENOCSI 50 +#define LINUX_EL2HLT 51 +#define LINUX_EBADE 52 +#define LINUX_EBADR 53 +#define LINUX_EXFULL 54 +#define LINUX_ENOANO 55 #define LINUX_EBADRQC 56 #define LINUX_EBADSLT 57 #define LINUX_EDEADLOCK 58 -#define LINUX_EBFONT 59 -#define LINUX_ENOSTR 60 +#define LINUX_EBFONT 59 +#define LINUX_ENOSTR 60 #define LINUX_ENODATA 61 -#define LINUX_ETIME 62 -#define LINUX_ENOSR 63 -#define LINUX_ENONET 64 -#define LINUX_ENOPKG 65 +#define LINUX_ETIME 62 +#define LINUX_ENOSR 63 +#define LINUX_ENONET 64 +#define LINUX_ENOPKG 65 #define LINUX_EREMOTE 66 #define LINUX_ENOLINK 67 -#define LINUX_EADV 68 -#define LINUX_ESRMNT 69 -#define LINUX_ECOMM 70 -#define LINUX_EPROTO 71 +#define LINUX_EADV 68 +#define LINUX_ESRMNT 69 +#define LINUX_ECOMM 70 +#define LINUX_EPROTO 71 #define LINUX_EMULTIHOP 72 #define LINUX_EDOTDOT 73 #define LINUX_EBADMSG 74 #define LINUX_EOVERFLOW 75 #define LINUX_ENOTUNIQ 76 -#define LINUX_EBADFD 77 +#define LINUX_EBADFD 77 #define LINUX_EREMCHG 78 #define LINUX_ELIBACC 79 #define LINUX_ELIBBAD 80 #define LINUX_ELIBSCN 81 #define LINUX_ELIBMAX 82 #define LINUX_ELIBEXEC 83 -#define LINUX_EILSEQ 84 +#define LINUX_EILSEQ 84 #define LINUX_ERESTART 85 #define LINUX_ESTRPIPE 86 -#define LINUX_EUSERS 87 +#define LINUX_EUSERS 87 #define LINUX_ENOTSOCK 88 #define LINUX_EDESTADDRREQ 89 #define LINUX_EMSGSIZE 90 @@ -104,10 +104,10 @@ #define LINUX_ENOPROTOOPT 92 #define LINUX_EPROTONOSUPPORT 93 #define LINUX_ESOCKTNOSUPPORT 94 -#define LINUX_EOPNOTSUPP 95 -#define LINUX_EPFNOSUPPORT 96 -#define LINUX_EAFNOSUPPORT 97 -#define LINUX_EADDRINUSE 98 +#define LINUX_EOPNOTSUPP 95 +#define LINUX_EPFNOSUPPORT 96 +#define LINUX_EAFNOSUPPORT 97 +#define LINUX_EADDRINUSE 98 #define LINUX_EADDRNOTAVAIL 99 #define LINUX_ENETDOWN 100 #define LINUX_ENETUNREACH 101 @@ -125,13 +125,13 @@ #define LINUX_EHOSTUNREACH 113 #define LINUX_EALREADY 114 #define LINUX_EINPROGRESS 115 -#define LINUX_ESTALE 116 +#define LINUX_ESTALE 116 #define LINUX_EUCLEAN 117 #define LINUX_ENOTNAM 118 #define LINUX_ENAVAIL 119 -#define LINUX_EISNAM 120 +#define LINUX_EISNAM 120 #define LINUX_EREMOTEIO 121 -#define LINUX_EDQUOT 122 +#define LINUX_EDQUOT 122 #define LINUX_ENOMEDIUM 123 #define LINUX_EMEDIUMTYPE 124 diff --git a/sys/compat/linux/arch/powerpc/linux_exec.h b/sys/compat/linux/arch/powerpc/linux_exec.h index 29555a643530..a254460091e4 100644 --- a/sys/compat/linux/arch/powerpc/linux_exec.h +++ b/sys/compat/linux/arch/powerpc/linux_exec.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux_exec.h,v 1.1 2001/01/19 01:31:23 manu Exp $ */ +/* $NetBSD: linux_exec.h,v 1.2 2001/02/04 22:59:26 christos Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -98,11 +98,11 @@ */ #ifdef LINUX_SP_WRAP #define LINUX_ELF_AUX_ARGSIZ \ - ((howmany(ELF_AUX_ENTRIES * sizeof(LinuxAuxInfo), sizeof(Elf32_Addr))) + 16 \ - + LINUX_SP_WRAP) + ((howmany(ELF_AUX_ENTRIES * sizeof(LinuxAuxInfo), sizeof(Elf32_Addr))) \ + + 16 + LINUX_SP_WRAP) #else #define LINUX_ELF_AUX_ARGSIZ \ - ((howmany(ELF_AUX_ENTRIES * sizeof(LinuxAuxInfo), sizeof(Elf32_Addr))) + 16) + ((howmany(ELF_AUX_ENTRIES * sizeof(LinuxAuxInfo), sizeof(Elf32_Addr))) + 16) #endif /* XXX should use ELFNAME2 */ @@ -116,7 +116,8 @@ typedef struct { #ifdef _KERNEL __BEGIN_DECLS -void * linux_elf32_copyargs __P((struct exec_package *, struct ps_strings *, void *, void *)); +void * linux_elf32_copyargs __P((struct exec_package *, + struct ps_strings *, void *, void *)); __END_DECLS #endif /* _KERNEL */ diff --git a/sys/compat/linux/arch/powerpc/linux_exec_powerpc.c b/sys/compat/linux/arch/powerpc/linux_exec_powerpc.c index 7bdbc058182f..240338a936d4 100644 --- a/sys/compat/linux/arch/powerpc/linux_exec_powerpc.c +++ b/sys/compat/linux/arch/powerpc/linux_exec_powerpc.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_exec_powerpc.c,v 1.1 2001/01/19 01:36:51 manu Exp $ */ +/* $NetBSD: linux_exec_powerpc.c,v 1.2 2001/02/04 22:59:26 christos Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -105,10 +105,10 @@ ELFNAME2(linux,copyargs)(pack, arginfo, stack, argp) #ifdef LINUX_SHIFT /* * From Linux's arch/ppc/kernel/process.c:shove_aux_table(). GNU ld.so - * expects the ELF auxiliary table to start on a 16 bytes boundary on the - * PowerPC. + * expects the ELF auxiliary table to start on a 16 bytes boundary on + * the PowerPC. */ - (unsigned long) stack = ((unsigned long) stack + LINUX_SHIFT) & ~LINUX_SHIFT; + stack = (void *)(((unsigned long) stack + LINUX_SHIFT) & ~LINUX_SHIFT); #endif memset(ai, 0, sizeof(LinuxAuxInfo) * LINUX_ELF_AUX_ENTRIES); @@ -133,9 +133,9 @@ ELFNAME2(linux,copyargs)(pack, arginfo, stack, argp) #if 1 /* * The exec_package doesn't have a proc pointer and it's not - * exactly trivial to add one since the credentials are changing. - * - * XXX Linux uses curproc's credentials. Why can't we use them too? + * exactly trivial to add one since the credentials are + * changing. XXX Linux uses curproc's credentials. + * Why can't we use them too? */ a->a_type = LINUX_AT_EGID; a->a_v = p->p_ucred->cr_gid; diff --git a/sys/compat/linux/arch/powerpc/linux_fcntl.h b/sys/compat/linux/arch/powerpc/linux_fcntl.h index 0bcf37fe3133..ba20f8fafe0c 100644 --- a/sys/compat/linux/arch/powerpc/linux_fcntl.h +++ b/sys/compat/linux/arch/powerpc/linux_fcntl.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux_fcntl.h,v 1.2 2001/01/21 22:19:26 manu Exp $ */ +/* $NetBSD: linux_fcntl.h,v 1.3 2001/02/04 22:59:26 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 2001 The NetBSD Foundation, Inc. @@ -53,15 +53,15 @@ * Theses are octal values (remember 0100 != 100 in C) */ #define LINUX_O_CREAT 0100 -#define LINUX_O_EXCL 0200 +#define LINUX_O_EXCL 0200 #define LINUX_O_NOCTTY 0400 #define LINUX_O_TRUNC 01000 #define LINUX_O_APPEND 02000 #define LINUX_O_NONBLOCK 04000 #define LINUX_O_NDELAY LINUX_O_NONBLOCK -#define LINUX_O_SYNC 010000 +#define LINUX_O_SYNC 010000 -#define LINUX_FASYNC 020000 +#define LINUX_FASYNC 020000 /* * fcntl(2) operations diff --git a/sys/compat/linux/arch/powerpc/linux_machdep.c b/sys/compat/linux/arch/powerpc/linux_machdep.c index 4e1890b9c0bd..d1e7cfed6368 100644 --- a/sys/compat/linux/arch/powerpc/linux_machdep.c +++ b/sys/compat/linux/arch/powerpc/linux_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_machdep.c,v 1.3 2001/01/26 19:46:16 manu Exp $ */ +/* $NetBSD: linux_machdep.c,v 1.4 2001/02/04 22:59:26 christos Exp $ */ /*- * Copyright (c) 1995, 2000, 2001 The NetBSD Foundation, Inc. @@ -124,7 +124,7 @@ linux_sendsig(catcher, sig, mask, code) /* XXX Check me */ struct proc *p = curproc; struct trapframe *tf; struct linux_sigregs *fp, frame; - struct linux_pt_regs linux_regs; + struct linux_pt_regs linux_regs; struct linux_sigcontext sc; int onstack; int i; @@ -147,11 +147,13 @@ linux_sendsig(catcher, sig, mask, code) /* XXX Check me */ /* * Allocate space for the signal handler context. */ - if (onstack) - fp = (struct linux_sigregs *)((caddr_t)p->p_sigctx.ps_sigstk.ss_sp + + if (onstack) { + fp = (struct linux_sigregs *) + ((caddr_t)p->p_sigctx.ps_sigstk.ss_sp + p->p_sigctx.ps_sigstk.ss_size); - else + } else { fp = (struct linux_sigregs *)tf->fixreg[1]; + } fp = (struct linux_sigregs *)((int)(fp - 1) & ~0xf); /* @@ -168,7 +170,7 @@ linux_sendsig(catcher, sig, mask, code) /* XXX Check me */ * * Save register context. */ - for (i=0; i<=31; i++) + for (i = 0; i < 32; i++) linux_regs.lgpr[i] = tf->fixreg[i]; linux_regs.lnip = tf->srr0; linux_regs.lmsr = tf->srr1; @@ -178,11 +180,11 @@ linux_sendsig(catcher, sig, mask, code) /* XXX Check me */ linux_regs.lxer = tf->xer; linux_regs.lccr = tf->cr; linux_regs.lmq = 0; /* Unused, 601 only */ - linux_regs.ltrap = 0; /* XXX What is ltrap counterpart in NetBSD ? */ + linux_regs.ltrap = 0; /* XXX What is ltrap counterpart in NetBSD ? */ linux_regs.ldar = tf->dar; linux_regs.ldsisr = tf->dsisr; linux_regs.lresult = tf->exc; - bcopy (&linux_regs, &frame.lgp_regs, sizeof (frame.lgp_regs)); + memcpy(&frame.lgp_regs, &linux_regs, sizeof(frame.lgp_regs)); /* * NetBSD does not uses the FPU in the kernel, so there is no @@ -190,14 +192,14 @@ linux_sendsig(catcher, sig, mask, code) /* XXX Check me */ * them to be saved on the stack. Therefore we just keep a * gap of zero'ed data where the FP registers should be stored */ - memset (&frame.lfp_regs, 0, sizeof (frame.lfp_regs)); + memset(&frame.lfp_regs, 0, sizeof (frame.lfp_regs)); /* - * Copy Linux's signal trampoline on the user stack It should not be used, - * but Linux binaries might expect him to be there. + * Copy Linux's signal trampoline on the user stack It should not + * be used, but Linux binaries might expect him to be there. */ - frame.ltramp[0]=0x38997777; /* li r0, 0x7777 */ - frame.ltramp[1]=0x44000002; /* sc */ + frame.ltramp[0] = 0x38997777; /* li r0, 0x7777 */ + frame.ltramp[1] = 0x44000002; /* sc */ /* * Move it to the user stack @@ -206,7 +208,7 @@ linux_sendsig(catcher, sig, mask, code) /* XXX Check me */ * binaries. But the Linux kernel seems to do without it, and it * just skip it when building the stack frame. Hence the LINUX_ABIGAP. */ - if (copyout(&frame, fp, sizeof (frame) - LINUX_ABIGAP)) { + if (copyout(&frame, fp, sizeof (frame) - LINUX_ABIGAP) != 0) { /* * Process has trashed its stack; give it an illegal * instructoin to halt it in its tracks. @@ -218,17 +220,19 @@ linux_sendsig(catcher, sig, mask, code) /* XXX Check me */ /* * adjust stack pointer after the previous data copy */ - (unsigned long)fp -= (sizeof (frame) - LINUX_ABIGAP); + fp = (struct linux_sigregs *) + ((unsigned long)fp - (sizeof (frame) - LINUX_ABIGAP)); /* * "Mind the gap" Linux expects a gap here. */ - (unsigned long)fp -= LINUX__SIGNAL_FRAMESIZE; + fp = (struct linux_sigregs *) + ((unsigned long)fp - LINUX__SIGNAL_FRAMESIZE); /* * Add a sigcontext on the stack */ - if (copyout(&sc, fp, sizeof (struct linux_sigcontext))) { + if (copyout(&sc, fp, sizeof (struct linux_sigcontext)) != 0) { /* * Process has trashed its stack; give it an illegal * instructoin to halt it in its tracks. @@ -297,15 +301,15 @@ linux_sys_rt_sigreturn(p, v, retval) scp = SCARG(uap, sfp); /* - * It seems we need a 16 bytes alignement here (it just works with it, don't - * ask me why + * It seems we need a 16 bytes alignement here (it just works with it, + * don't ask me why */ - (unsigned long)scp = (unsigned long) scp & ~0xfUL; + scp = (linux_rt_sigframe *)((unsigned long)scp & ~0xfUL); /* * Get the context from user stack */ - if (copyin((caddr_t)scp, &sigframe, sizeof(struct linux_rt_sigframe)) != 0) + if (copyin((caddr_t)scp, &sigframe, sizeof(*scp)) != 0) return (EFAULT); /* @@ -326,7 +330,7 @@ linux_sys_rt_sigreturn(p, v, retval) (tf->srr1 & PSL_USERSTATIC)) return (EINVAL); - for (i=0; i<=31; i++) + for (i = 0; i < 32; i++) tf->fixreg[i] = sigframe.luc.luc_context.lregs->lgpr[i]; tf->lr = sigframe.luc.luc_context.lregs->llink; tf->cr = sigframe.luc.luc_context.lregs->lccr; @@ -380,15 +384,15 @@ linux_sys_sigreturn(p, v, retval) scp = SCARG(uap, scp); /* - * It seems we need a 16 bytes alignement here (it just works with it, don't - * ask me why + * It seems we need a 16 bytes alignement here (it just works with it, + * don't ask me why */ (unsigned long)scp = (unsigned long) scp & ~0xfUL; /* * Get the context from user stack */ - if (copyin((caddr_t)scp, &context, sizeof(struct linux_sigcontext)) != 0) + if (copyin(scp, &context, sizeof(struct linux_sigcontext)) != 0) return (EFAULT); /* @@ -400,10 +404,11 @@ linux_sys_sigreturn(p, v, retval) (unsigned long)tf, (unsigned long)scp); #endif - if ((context.lregs->lmsr & PSL_USERSTATIC) != (tf->srr1 & PSL_USERSTATIC)) + if ((context.lregs->lmsr & PSL_USERSTATIC) != + (tf->srr1 & PSL_USERSTATIC)) return (EINVAL); - for (i=0; i<=31; i++) + for (i = 0; i < 32; i++) tf->fixreg[i] = context.lregs->lgpr[i]; tf->lr = context.lregs->llink; tf->cr = context.lregs->lccr; @@ -421,9 +426,11 @@ linux_sys_sigreturn(p, v, retval) * XXX cannot find the onstack information in Linux sig context. * Is signal stack really supported on Linux? */ - /* if (sc.sc_onstack & SS_ONSTACK) +#if 0 + if (sc.sc_onstack & SS_ONSTACK) p->p_sigctx.ps_sigstk.ss_flags |= SS_ONSTACK; - else */ + else +#endif p->p_sigctx.ps_sigstk.ss_flags &= ~SS_ONSTACK; /* Restore signal mask. */ @@ -441,7 +448,8 @@ linux_sys_modify_ldt(p, v, retval) register_t *retval; { /* - * This syscall is not implemented in Linux/PowerPC: we should not be here + * This syscall is not implemented in Linux/PowerPC: we should not + * be here */ #ifdef DEBUG_LINUX printf("linux_sys_modify_ldt: should not be here.\n"); diff --git a/sys/compat/linux/arch/powerpc/linux_ptrace.c b/sys/compat/linux/arch/powerpc/linux_ptrace.c index 6ebd430b9c14..4f3f95c96c6d 100644 --- a/sys/compat/linux/arch/powerpc/linux_ptrace.c +++ b/sys/compat/linux/arch/powerpc/linux_ptrace.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ptrace.c,v 1.2 2001/02/04 14:24:38 manu Exp $ */ +/* $NetBSD: linux_ptrace.c,v 1.3 2001/02/04 22:59:26 christos Exp $ */ /*- * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc. @@ -94,7 +94,7 @@ struct linux_user { unsigned long start_data; unsigned long start_stack; long int signal; - struct linux_pt_regs *u_ar0; /* help gdb find registers */ + struct linux_pt_regs *u_ar0; /* help gdb find registers */ unsigned long magic; char u_comm[32]; }; @@ -120,19 +120,22 @@ linux_sys_ptrace_arch(p, v, retval) /* XXX Check me! (From NetBSD/i386) */ struct reg *regs = NULL; struct fpreg *fpregs = NULL; struct linux_pt_regs *linux_regs = NULL; - double *linux_fpreg=NULL; /* it's an array, not a struct */ + double *linux_fpreg = NULL; /* it's an array, not a struct */ int addr; int i; - request = SCARG(uap, request); - if ((request != LINUX_PTRACE_PEEKUSR) && - (request != LINUX_PTRACE_POKEUSR) && - (request != LINUX_PTRACE_GETREGS) && - (request != LINUX_PTRACE_SETREGS) && - (request != LINUX_PTRACE_GETFPREGS) && - (request != LINUX_PTRACE_SETFPREGS)) + switch (request = SCARG(uap, request)) { + case LINUX_PTRACE_PEEKUSR: + case LINUX_PTRACE_POKEUSR: + case LINUX_PTRACE_GETREGS: + case LINUX_PTRACE_SETREGS: + case LINUX_PTRACE_GETFPREGS: + case LINUX_PTRACE_SETFPREGS: + break; + default: return EIO; + } /* Find the process we're supposed to be operating on. */ if ((t = pfind(SCARG(uap, pid))) == NULL) @@ -169,7 +172,7 @@ linux_sys_ptrace_arch(p, v, retval) /* XXX Check me! (From NetBSD/i386) */ switch (request) { case LINUX_PTRACE_GETREGS: MALLOC(regs, struct reg*, sizeof(struct reg), M_TEMP, M_WAITOK); - MALLOC(linux_regs, struct linux_pt_regs*, sizeof(struct linux_pt_regs), + MALLOC(linux_regs, struct linux_pt_regs*, sizeof(*linux_regs), M_TEMP, M_WAITOK); error = process_read_regs(t, regs); @@ -180,7 +183,8 @@ linux_sys_ptrace_arch(p, v, retval) /* XXX Check me! (From NetBSD/i386) */ linux_regs->lgpr[i] = regs->fixreg[i]; linux_regs->lnip = regs->pc; linux_regs->lmsr = 0; - linux_regs->lorig_gpr3 = regs->fixreg[3]; /* XXX Is that right? */ + /* XXX Is that right? */ + linux_regs->lorig_gpr3 = regs->fixreg[3]; linux_regs->lctr = regs->ctr; linux_regs->llink = regs->lr; linux_regs->lxer = regs->xer; @@ -197,7 +201,7 @@ linux_sys_ptrace_arch(p, v, retval) /* XXX Check me! (From NetBSD/i386) */ case LINUX_PTRACE_SETREGS: MALLOC(regs, struct reg*, sizeof(struct reg), M_TEMP, M_WAITOK); - MALLOC(linux_regs, struct linux_pt_regs*, sizeof(struct linux_pt_regs), + MALLOC(linux_regs, struct linux_pt_regs*, sizeof(*linux_regs), M_TEMP, M_WAITOK); error = copyin((caddr_t)SCARG(uap, data), linux_regs,