sysv_sem.c (12819) | sysv_sem.c (12866) |
---|---|
1/* $Id: sysv_sem.c,v 1.10 1995/10/21 19:49:59 bde Exp $ */ | 1/* $Id: sysv_sem.c,v 1.11 1995/12/14 08:31:52 phk Exp $ */ |
2 3/* 4 * Implementation of SVID semaphores 5 * 6 * Author: Daniel Boulet 7 * 8 * This software is provided ``AS IS'' without any warranties of any kind. 9 */ --- 4 unchanged lines hidden (view full) --- 14#include <sys/kernel.h> 15#include <sys/proc.h> 16#include <sys/sem.h> 17#include <sys/sysent.h> 18 19static void seminit __P((void *)); 20SYSINIT(sysv_sem, SI_SUB_SYSV_SEM, SI_ORDER_FIRST, seminit, NULL) 21 | 2 3/* 4 * Implementation of SVID semaphores 5 * 6 * Author: Daniel Boulet 7 * 8 * This software is provided ``AS IS'' without any warranties of any kind. 9 */ --- 4 unchanged lines hidden (view full) --- 14#include <sys/kernel.h> 15#include <sys/proc.h> 16#include <sys/sem.h> 17#include <sys/sysent.h> 18 19static void seminit __P((void *)); 20SYSINIT(sysv_sem, SI_SUB_SYSV_SEM, SI_ORDER_FIRST, seminit, NULL) 21 |
22struct semctl_args; 23static int semctl __P((struct proc *p, struct semctl_args *uap, int *retval)); | 22#ifndef _SYS_SYSPROTO_H_ 23struct __semctl_args; 24int __semctl __P((struct proc *p, struct __semctl_args *uap, int *retval)); |
24struct semget_args; | 25struct semget_args; |
25static int semget __P((struct proc *p, struct semget_args *uap, int *retval)); | 26int semget __P((struct proc *p, struct semget_args *uap, int *retval)); |
26struct semop_args; | 27struct semop_args; |
27static int semop __P((struct proc *p, struct semop_args *uap, int *retval)); | 28int semop __P((struct proc *p, struct semop_args *uap, int *retval)); |
28struct semconfig_args; | 29struct semconfig_args; |
29static int semconfig __P((struct proc *p, struct semconfig_args *uap, | 30int semconfig __P((struct proc *p, struct semconfig_args *uap, |
30 int *retval)); | 31 int *retval)); |
32#endif |
|
31 32static struct sem_undo *semu_alloc __P((struct proc *p)); 33static int semundo_adjust __P((struct proc *p, struct sem_undo **supptr, 34 int semid, int semnum, int adjval)); 35static void semundo_clear __P((int semid, int semnum)); 36static void semexit __P((struct proc *p)); 37 38/* XXX casting to (sy_call_t *) is bogus, as usual. */ 39static sy_call_t *semcalls[] = { | 33 34static struct sem_undo *semu_alloc __P((struct proc *p)); 35static int semundo_adjust __P((struct proc *p, struct sem_undo **supptr, 36 int semid, int semnum, int adjval)); 37static void semundo_clear __P((int semid, int semnum)); 38static void semexit __P((struct proc *p)); 39 40/* XXX casting to (sy_call_t *) is bogus, as usual. */ 41static sy_call_t *semcalls[] = { |
40 (sy_call_t *)semctl, (sy_call_t *)semget, | 42 (sy_call_t *)__semctl, (sy_call_t *)semget, |
41 (sy_call_t *)semop, (sy_call_t *)semconfig 42}; 43 44static int semtot = 0; 45struct semid_ds *sema; /* semaphore id pool */ 46struct sem *sem; /* semaphore pool */ 47static struct map *semmap; /* semaphore allocation map */ 48static struct sem_undo *semu_list; /* list of active undo structures */ --- 58 unchanged lines hidden (view full) --- 107 * of the getkerninfo facility. 108 * 109 * At the time that the current version of semconfig was written, ipcs is 110 * the only user of the semconfig facility. It uses it to ensure that the 111 * semaphore facility data structures remain static while it fishes around 112 * in /dev/kmem. 113 */ 114 | 43 (sy_call_t *)semop, (sy_call_t *)semconfig 44}; 45 46static int semtot = 0; 47struct semid_ds *sema; /* semaphore id pool */ 48struct sem *sem; /* semaphore pool */ 49static struct map *semmap; /* semaphore allocation map */ 50static struct sem_undo *semu_list; /* list of active undo structures */ --- 58 unchanged lines hidden (view full) --- 109 * of the getkerninfo facility. 110 * 111 * At the time that the current version of semconfig was written, ipcs is 112 * the only user of the semconfig facility. It uses it to ensure that the 113 * semaphore facility data structures remain static while it fishes around 114 * in /dev/kmem. 115 */ 116 |
117#ifndef _SYS_SYSPROTO_H_ |
|
115struct semconfig_args { 116 semconfig_ctl_t flag; 117}; | 118struct semconfig_args { 119 semconfig_ctl_t flag; 120}; |
121#endif |
|
118 | 122 |
119static int | 123int |
120semconfig(p, uap, retval) 121 struct proc *p; 122 struct semconfig_args *uap; 123 int *retval; 124{ 125 int eval = 0; 126 127 switch (uap->flag) { --- 182 unchanged lines hidden (view full) --- 310 if (semnum != -1) 311 break; 312 } 313 i++, sunptr++; 314 } 315 } 316} 317 | 124semconfig(p, uap, retval) 125 struct proc *p; 126 struct semconfig_args *uap; 127 int *retval; 128{ 129 int eval = 0; 130 131 switch (uap->flag) { --- 182 unchanged lines hidden (view full) --- 314 if (semnum != -1) 315 break; 316 } 317 i++, sunptr++; 318 } 319 } 320} 321 |
318struct semctl_args { | 322/* 323 * Note that the user-mode half of this passes a union, not a pointer 324 */ 325#ifndef _SYS_SYSPROTO_H_ 326struct __semctl_args { |
319 int semid; 320 int semnum; 321 int cmd; 322 union semun *arg; 323}; | 327 int semid; 328 int semnum; 329 int cmd; 330 union semun *arg; 331}; |
332#endif |
|
324 | 333 |
325static int 326semctl(p, uap, retval) | 334int 335__semctl(p, uap, retval) |
327 struct proc *p; | 336 struct proc *p; |
328 register struct semctl_args *uap; | 337 register struct __semctl_args *uap; |
329 int *retval; 330{ 331 int semid = uap->semid; 332 int semnum = uap->semnum; 333 int cmd = uap->cmd; 334 union semun *arg = uap->arg; 335 union semun real_arg; 336 struct ucred *cred = p->p_ucred; --- 137 unchanged lines hidden (view full) --- 474 return(EINVAL); 475 } 476 477 if (eval == 0) 478 *retval = rval; 479 return(eval); 480} 481 | 338 int *retval; 339{ 340 int semid = uap->semid; 341 int semnum = uap->semnum; 342 int cmd = uap->cmd; 343 union semun *arg = uap->arg; 344 union semun real_arg; 345 struct ucred *cred = p->p_ucred; --- 137 unchanged lines hidden (view full) --- 483 return(EINVAL); 484 } 485 486 if (eval == 0) 487 *retval = rval; 488 return(eval); 489} 490 |
491#ifndef _SYS_SYSPROTO_H_ |
|
482struct semget_args { 483 key_t key; 484 int nsems; 485 int semflg; 486}; | 492struct semget_args { 493 key_t key; 494 int nsems; 495 int semflg; 496}; |
497#endif |
|
487 | 498 |
488static int | 499int |
489semget(p, uap, retval) 490 struct proc *p; 491 register struct semget_args *uap; 492 int *retval; 493{ 494 int semid, eval; 495 int key = uap->key; 496 int nsems = uap->nsems; --- 90 unchanged lines hidden (view full) --- 587 return(ENOENT); 588 } 589 590found: 591 *retval = IXSEQ_TO_IPCID(semid, sema[semid].sem_perm); 592 return(0); 593} 594 | 500semget(p, uap, retval) 501 struct proc *p; 502 register struct semget_args *uap; 503 int *retval; 504{ 505 int semid, eval; 506 int key = uap->key; 507 int nsems = uap->nsems; --- 90 unchanged lines hidden (view full) --- 598 return(ENOENT); 599 } 600 601found: 602 *retval = IXSEQ_TO_IPCID(semid, sema[semid].sem_perm); 603 return(0); 604} 605 |
606#ifndef _SYS_SYSPROTO_H_ |
|
595struct semop_args { 596 int semid; 597 struct sembuf *sops; 598 int nsops; 599}; | 607struct semop_args { 608 int semid; 609 struct sembuf *sops; 610 int nsops; 611}; |
612#endif |
|
600 | 613 |
601static int | 614int |
602semop(p, uap, retval) 603 struct proc *p; 604 register struct semop_args *uap; 605 int *retval; 606{ 607 int semid = uap->semid; 608 int nsops = uap->nsops; 609 struct sembuf sops[MAX_SOPS]; --- 363 unchanged lines hidden --- | 615semop(p, uap, retval) 616 struct proc *p; 617 register struct semop_args *uap; 618 int *retval; 619{ 620 int semid = uap->semid; 621 int nsops = uap->nsops; 622 struct sembuf sops[MAX_SOPS]; --- 363 unchanged lines hidden --- |