sysv_sem.c (cb1f0db9dbf89ed25f16308c33a721e7ed6ba531) | sysv_sem.c (78525ce3185cb7196d629f4b1ec2fa2a5039129b) |
---|---|
1/* $FreeBSD$ */ 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 */ 10 11#include "opt_sysvipc.h" 12 13#include <sys/param.h> 14#include <sys/systm.h> 15#include <sys/sysproto.h> 16#include <sys/kernel.h> 17#include <sys/proc.h> 18#include <sys/sem.h> | 1/* $FreeBSD$ */ 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 */ 10 11#include "opt_sysvipc.h" 12 13#include <sys/param.h> 14#include <sys/systm.h> 15#include <sys/sysproto.h> 16#include <sys/kernel.h> 17#include <sys/proc.h> 18#include <sys/sem.h> |
19#include <sys/syscall.h> |
|
19#include <sys/sysent.h> 20#include <sys/sysctl.h> 21#include <sys/malloc.h> 22#include <sys/jail.h> 23 24static MALLOC_DEFINE(M_SEM, "sem", "SVID compatible semaphores"); 25 | 20#include <sys/sysent.h> 21#include <sys/sysctl.h> 22#include <sys/malloc.h> 23#include <sys/jail.h> 24 25static MALLOC_DEFINE(M_SEM, "sem", "SVID compatible semaphores"); 26 |
26static void seminit __P((void *)); | 27static void seminit __P((void)); 28static int sysvsem_modload __P((struct module *, int, void *)); 29static int semunload __P((void)); 30static void semexit_myhook __P((struct proc *p)); |
27 28#ifndef _SYS_SYSPROTO_H_ 29struct __semctl_args; 30int __semctl __P((struct proc *p, struct __semctl_args *uap)); 31struct semget_args; 32int semget __P((struct proc *p, struct semget_args *uap)); 33struct semop_args; 34int semop __P((struct proc *p, struct semop_args *uap)); --- 119 unchanged lines hidden (view full) --- 154RO seminfo.semopm /* SEMOPM unused */ 155RO seminfo.semume 156RO seminfo.semusz /* param - derived from SEMUME for per-proc sizeof */ 157RO seminfo.semvmx /* SEMVMX unused - user param */ 158RO seminfo.semaem /* SEMAEM unused - user param */ 159#endif 160 161static void | 31 32#ifndef _SYS_SYSPROTO_H_ 33struct __semctl_args; 34int __semctl __P((struct proc *p, struct __semctl_args *uap)); 35struct semget_args; 36int semget __P((struct proc *p, struct semget_args *uap)); 37struct semop_args; 38int semop __P((struct proc *p, struct semop_args *uap)); --- 119 unchanged lines hidden (view full) --- 158RO seminfo.semopm /* SEMOPM unused */ 159RO seminfo.semume 160RO seminfo.semusz /* param - derived from SEMUME for per-proc sizeof */ 161RO seminfo.semvmx /* SEMVMX unused - user param */ 162RO seminfo.semaem /* SEMAEM unused - user param */ 163#endif 164 165static void |
162seminit(dummy) 163 void *dummy; | 166seminit(void) |
164{ 165 register int i; 166 167 sem = malloc(sizeof(struct sem) * seminfo.semmns, M_SEM, M_WAITOK); 168 if (sem == NULL) 169 panic("sem is NULL"); 170 sema = malloc(sizeof(struct semid_ds) * seminfo.semmni, M_SEM, M_WAITOK); 171 if (sema == NULL) --- 6 unchanged lines hidden (view full) --- 178 sema[i].sem_base = 0; 179 sema[i].sem_perm.mode = 0; 180 } 181 for (i = 0; i < seminfo.semmnu; i++) { 182 register struct sem_undo *suptr = SEMU(i); 183 suptr->un_proc = NULL; 184 } 185 semu_list = NULL; | 167{ 168 register int i; 169 170 sem = malloc(sizeof(struct sem) * seminfo.semmns, M_SEM, M_WAITOK); 171 if (sem == NULL) 172 panic("sem is NULL"); 173 sema = malloc(sizeof(struct semid_ds) * seminfo.semmni, M_SEM, M_WAITOK); 174 if (sema == NULL) --- 6 unchanged lines hidden (view full) --- 181 sema[i].sem_base = 0; 182 sema[i].sem_perm.mode = 0; 183 } 184 for (i = 0; i < seminfo.semmnu; i++) { 185 register struct sem_undo *suptr = SEMU(i); 186 suptr->un_proc = NULL; 187 } 188 semu_list = NULL; |
189 semexit_hook = &semexit_myhook; |
|
186} | 190} |
187SYSINIT(sysv_sem, SI_SUB_SYSV_SEM, SI_ORDER_FIRST, seminit, NULL) | |
188 | 191 |
192static int 193semunload(void) 194{ 195 196 if (semtot != 0) 197 return (EBUSY); 198 199 free(sem, M_SEM); 200 free(sema, M_SEM); 201 free(semu, M_SEM); 202 semexit_hook = NULL; 203 return (0); 204} 205 206static int 207sysvsem_modload(struct module *module, int cmd, void *arg) 208{ 209 int error = 0; 210 211 switch (cmd) { 212 case MOD_LOAD: 213 seminit(); 214 break; 215 case MOD_UNLOAD: 216 error = semunload(); 217 break; 218 case MOD_SHUTDOWN: 219 break; 220 default: 221 error = EINVAL; 222 break; 223 } 224 return (error); 225} 226 227static moduledata_t sysvsem_moduledata = { 228 "sysvsem_mod", 229 &sysvsem_modload, 230 NULL 231}; 232 233SYSCALL_MODULE_HELPER(semsys, 5); 234SYSCALL_MODULE_HELPER(__semctl, 4); 235SYSCALL_MODULE_HELPER(semget, 3); 236SYSCALL_MODULE_HELPER(semop, 3); 237 238DECLARE_MODULE(sysvsem_mod, sysvsem_moduledata, 239 SI_SUB_SYSV_SEM, SI_ORDER_FIRST); 240 |
|
189/* 190 * Entry point for all SEM calls 191 */ 192int 193semsys(p, uap) 194 struct proc *p; 195 /* XXX actually varargs. */ 196 struct semsys_args /* { --- 731 unchanged lines hidden (view full) --- 928 p->p_retval[0] = 0; 929 return(0); 930} 931 932/* 933 * Go through the undo structures for this process and apply the adjustments to 934 * semaphores. 935 */ | 241/* 242 * Entry point for all SEM calls 243 */ 244int 245semsys(p, uap) 246 struct proc *p; 247 /* XXX actually varargs. */ 248 struct semsys_args /* { --- 731 unchanged lines hidden (view full) --- 980 p->p_retval[0] = 0; 981 return(0); 982} 983 984/* 985 * Go through the undo structures for this process and apply the adjustments to 986 * semaphores. 987 */ |
936void 937semexit(p) | 988static void 989semexit_myhook(p) |
938 struct proc *p; 939{ 940 register struct sem_undo *suptr; 941 register struct sem_undo **supptr; 942 int did_something; 943 944 did_something = 0; 945 --- 70 unchanged lines hidden --- | 990 struct proc *p; 991{ 992 register struct sem_undo *suptr; 993 register struct sem_undo **supptr; 994 int did_something; 995 996 did_something = 0; 997 --- 70 unchanged lines hidden --- |