Date: Wed, 28 Jun 2006 20:22:32 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 100229 for review Message-ID: <200606282022.k5SKMWND049314@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=100229 Change 100229 by jhb@jhb_mutex on 2006/06/28 20:22:10 Similar treatment to ibcs2_semsys() including using kern_semctl() to axe more stackgap usage. Affected files ... .. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_ipc.c#10 edit Differences ... ==== //depot/projects/smpng/sys/i386/ibcs2/ibcs2_ipc.c#10 (text+ko) ==== @@ -301,77 +301,100 @@ return; } -int -ibcs2_semsys(td, uap) - struct thread *td; - struct ibcs2_semsys_args *uap; +struct ibcs2_semctl_args { + int what; + int semid; + int semnum; + int cmd; + union semun arg; +}; + +static int +ibcs2_semctl(struct thread *td, void *v) { + struct ibcs2_semctl_args *uap = v; + struct ibcs2_semid_ds is; + struct semid_ds bs; + union semun semun; int error; - switch (uap->which) { - case 0: /* semctl */ - switch(uap->a4) { - case IBCS2_IPC_STAT: - { - struct ibcs2_semid_ds *isp; - struct semid_ds *sp; - union semun *sup, ssu; - caddr_t sg = stackgap_init(); + switch(uap->cmd) { + case IBCS2_IPC_STAT: + semun.buf = &bs; + error = kern_semctl(td, uap->semid, uap->semnum, IPC_STAT, + &semun, UIO_SYSSPACE); + if (error) + return (error); + cvt_semid2isemid(&bs, &is); + return (copyout(&is, uap->arg.buf, sizeof(is))); + + case IBCS2_IPC_SET: + error = copyin(uap->arg.buf, &is, sizeof(is)); + if (error) + return (error); + cvt_isemid2semid(&is, &bs); + semun.buf = &bs; + return (kern_semctl(td, uap->semid, uap->semnum, IPC_SET, + &semun, UIO_SYSSPACE)); + } + + return (kern_semctl(td, uap->semid, uap->semnum, uap->cmd, &uap->arg, + UIO_USERSPACE)); +} + +struct ibcs2_semget_args { + int what; + int key; + int nsems; + int semflg; +}; +static int +ibcs2_semget(struct thread *td, void *v) +{ + struct ibcs2_semget_args *uap = v; + struct semget_args ap; - ssu = (union semun) uap->a5; - sp = stackgap_alloc(&sg, sizeof(struct semid_ds)); - sup = stackgap_alloc(&sg, sizeof(union semun)); - sup->buf = sp; - uap->a5 = (int)sup; - error = semsys(td, (struct semsys_args *)uap); - if (!error) { - uap->a5 = (int)ssu.buf; - isp = stackgap_alloc(&sg, sizeof(*isp)); - cvt_semid2isemid(sp, isp); - error = copyout((caddr_t)isp, - (caddr_t)ssu.buf, - sizeof(*isp)); - } - return error; - } - case IBCS2_IPC_SET: - { - struct ibcs2_semid_ds *isp; - struct semid_ds *sp; - caddr_t sg = stackgap_init(); + ap.key = uap->key; + ap.nsems = uap->nsems; + ap.semflg = uap->semflg; + return (semget(td, &ap)); +} - isp = stackgap_alloc(&sg, sizeof(*isp)); - sp = stackgap_alloc(&sg, sizeof(*sp)); - error = copyin((caddr_t)uap->a5, (caddr_t)isp, - sizeof(*isp)); - if (error) - return error; - cvt_isemid2semid(isp, sp); - uap->a5 = (int)sp; - return semsys(td, (struct semsys_args *)uap); - } - case IBCS2_SETVAL: - { - union semun *sp; - caddr_t sg = stackgap_init(); +struct ibcs2_semop_args { + int what; + int semid; + struct sembuf *sops; + size_t nsops; +}; - sp = stackgap_alloc(&sg, sizeof(*sp)); - sp->val = (int) uap->a5; - uap->a5 = (int)sp; - return semsys(td, (struct semsys_args *)uap); - } - } +static int +ibcs2_semop(struct thread *td, void *v) +{ + struct ibcs2_semop_args *uap = v; + struct semop_args ap; - return semsys(td, (struct semsys_args *)uap); + ap.semid = uap->semid; + ap.sops = uap->sops; + ap.nsops = uap->nsops; + return (semop(td, &ap)); +} - case 1: /* semget */ - return semsys(td, (struct semsys_args *)uap); +int +ibcs2_semsys(td, uap) + struct thread *td; + struct ibcs2_semsys_args *uap; +{ - case 2: /* semop */ - return semsys(td, (struct semsys_args *)uap); + switch (uap->which) { + case 0: + return (ibcs2_semctl(td, uap)); + case 1: + return (ibcs2_semget(td, uap)); + case 2: + return (ibcs2_semop(td, uap)); } - return EINVAL; + return (EINVAL); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606282022.k5SKMWND049314>