sysv_sem.c (194832) | sysv_sem.c (194894) |
---|---|
1/*- 2 * Implementation of SVID semaphores 3 * 4 * Author: Daniel Boulet 5 * 6 * This software is provided ``AS IS'' without any warranties of any kind. 7 */ 8/*- --- 23 unchanged lines hidden (view full) --- 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 */ 38 39#include <sys/cdefs.h> | 1/*- 2 * Implementation of SVID semaphores 3 * 4 * Author: Daniel Boulet 5 * 6 * This software is provided ``AS IS'' without any warranties of any kind. 7 */ 8/*- --- 23 unchanged lines hidden (view full) --- 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 */ 38 39#include <sys/cdefs.h> |
40__FBSDID("$FreeBSD: head/sys/kern/sysv_sem.c 194832 2009-06-24 13:35:38Z jhb $"); | 40__FBSDID("$FreeBSD: head/sys/kern/sysv_sem.c 194894 2009-06-24 20:01:13Z jhb $"); |
41 | 41 |
42#include "opt_compat.h" |
|
42#include "opt_sysvipc.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/sysproto.h> 47#include <sys/eventhandler.h> 48#include <sys/kernel.h> 49#include <sys/proc.h> --- 35 unchanged lines hidden (view full) --- 85int semop(struct thread *td, struct semop_args *uap); 86#endif 87 88static struct sem_undo *semu_alloc(struct thread *td); 89static int semundo_adjust(struct thread *td, struct sem_undo **supptr, 90 int semid, int semseq, int semnum, int adjval); 91static void semundo_clear(int semid, int semnum); 92 | 43#include "opt_sysvipc.h" 44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/sysproto.h> 48#include <sys/eventhandler.h> 49#include <sys/kernel.h> 50#include <sys/proc.h> --- 35 unchanged lines hidden (view full) --- 86int semop(struct thread *td, struct semop_args *uap); 87#endif 88 89static struct sem_undo *semu_alloc(struct thread *td); 90static int semundo_adjust(struct thread *td, struct sem_undo **supptr, 91 int semid, int semseq, int semnum, int adjval); 92static void semundo_clear(int semid, int semnum); 93 |
93/* XXX casting to (sy_call_t *) is bogus, as usual. */ 94static sy_call_t *semcalls[] = { 95 (sy_call_t *)__semctl, (sy_call_t *)semget, 96 (sy_call_t *)semop 97}; 98 | |
99static struct mtx sem_mtx; /* semaphore global lock */ 100static struct mtx sem_undo_mtx; 101static int semtot = 0; 102static struct semid_kernel *sema; /* semaphore id pool */ 103static struct mtx *sema_mtx; /* semaphore id pool mutexes*/ 104static struct sem *sem; /* semaphore pool */ 105LIST_HEAD(, sem_undo) semu_list; /* list of active undo structures */ 106LIST_HEAD(, sem_undo) semu_free_list; /* list of free undo structures */ --- 205 unchanged lines hidden (view full) --- 312} 313 314static moduledata_t sysvsem_mod = { 315 "sysvsem", 316 &sysvsem_modload, 317 NULL 318}; 319 | 94static struct mtx sem_mtx; /* semaphore global lock */ 95static struct mtx sem_undo_mtx; 96static int semtot = 0; 97static struct semid_kernel *sema; /* semaphore id pool */ 98static struct mtx *sema_mtx; /* semaphore id pool mutexes*/ 99static struct sem *sem; /* semaphore pool */ 100LIST_HEAD(, sem_undo) semu_list; /* list of active undo structures */ 101LIST_HEAD(, sem_undo) semu_free_list; /* list of free undo structures */ --- 205 unchanged lines hidden (view full) --- 307} 308 309static moduledata_t sysvsem_mod = { 310 "sysvsem", 311 &sysvsem_modload, 312 NULL 313}; 314 |
320SYSCALL_MODULE_HELPER(semsys); | |
321SYSCALL_MODULE_HELPER(__semctl); 322SYSCALL_MODULE_HELPER(semget); 323SYSCALL_MODULE_HELPER(semop); 324 325DECLARE_MODULE(sysvsem, sysvsem_mod, SI_SUB_SYSV_SEM, SI_ORDER_FIRST); 326MODULE_VERSION(sysvsem, 1); 327 328/* | 315SYSCALL_MODULE_HELPER(__semctl); 316SYSCALL_MODULE_HELPER(semget); 317SYSCALL_MODULE_HELPER(semop); 318 319DECLARE_MODULE(sysvsem, sysvsem_mod, SI_SUB_SYSV_SEM, SI_ORDER_FIRST); 320MODULE_VERSION(sysvsem, 1); 321 322/* |
329 * Entry point for all SEM calls. 330 */ 331int 332semsys(td, uap) 333 struct thread *td; 334 /* XXX actually varargs. */ 335 struct semsys_args /* { 336 int which; 337 int a2; 338 int a3; 339 int a4; 340 int a5; 341 } */ *uap; 342{ 343 int error; 344 345 if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC)) 346 return (ENOSYS); 347 if (uap->which < 0 || 348 uap->which >= sizeof(semcalls)/sizeof(semcalls[0])) 349 return (EINVAL); 350 error = (*semcalls[uap->which])(td, &uap->a2); 351 return (error); 352} 353 354/* | |
355 * Allocate a new sem_undo structure for a process 356 * (returns ptr to structure or NULL if no more room) 357 */ 358 359static struct sem_undo * 360semu_alloc(struct thread *td) 361{ 362 struct sem_undo *suptr; --- 977 unchanged lines hidden (view full) --- 1340 1341static int 1342sysctl_sema(SYSCTL_HANDLER_ARGS) 1343{ 1344 1345 return (SYSCTL_OUT(req, sema, 1346 sizeof(struct semid_kernel) * seminfo.semmni)); 1347} | 323 * Allocate a new sem_undo structure for a process 324 * (returns ptr to structure or NULL if no more room) 325 */ 326 327static struct sem_undo * 328semu_alloc(struct thread *td) 329{ 330 struct sem_undo *suptr; --- 977 unchanged lines hidden (view full) --- 1308 1309static int 1310sysctl_sema(SYSCTL_HANDLER_ARGS) 1311{ 1312 1313 return (SYSCTL_OUT(req, sema, 1314 sizeof(struct semid_kernel) * seminfo.semmni)); 1315} |
1316 1317#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \ 1318 defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7) 1319SYSCALL_MODULE_HELPER(semsys); 1320 1321/* XXX casting to (sy_call_t *) is bogus, as usual. */ 1322static sy_call_t *semcalls[] = { 1323 (sy_call_t *)__semctl, (sy_call_t *)semget, 1324 (sy_call_t *)semop 1325}; 1326 1327/* 1328 * Entry point for all SEM calls. 1329 */ 1330int 1331semsys(td, uap) 1332 struct thread *td; 1333 /* XXX actually varargs. */ 1334 struct semsys_args /* { 1335 int which; 1336 int a2; 1337 int a3; 1338 int a4; 1339 int a5; 1340 } */ *uap; 1341{ 1342 int error; 1343 1344 if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC)) 1345 return (ENOSYS); 1346 if (uap->which < 0 || 1347 uap->which >= sizeof(semcalls)/sizeof(semcalls[0])) 1348 return (EINVAL); 1349 error = (*semcalls[uap->which])(td, &uap->a2); 1350 return (error); 1351} 1352#endif /* COMPAT_FREEBSD4 || COMPAT_FREEBSD5 || COMPAT_FREEBSD6 || 1353 COMPAT_FREEBSD7 */ |
|