semutot--;
semundo_adjust(struct proc *p, struct sem_undo **supptr, int semid, int semnum,	int adjval){	struct sem_undo *suptr;	struct undo *sunptr;	int i;	/*	 * Look for and remember the sem_undo if the caller doesn't provide it.	 */	suptr = *supptr;	if (suptr == NULL) {		for (suptr = semu_list; suptr != NULL; suptr = suptr->un_next) {			if (suptr->un_proc == p) {				*supptr = suptr;				break;			}		}		if (suptr == NULL) {			if (adjval == 0)				return (0);			suptr = semu_alloc(p);			if (suptr == NULL)				return (ENOSPC);			*supptr = suptr;		}	}	/*	 * Look for the requested entry and adjust it	 * (delete if adjval becomes 0).	 */	sunptr = &suptr->un_ent[0];	for (i = 0; i < suptr->un_cnt; i++, sunptr++) {		if (sunptr->un_id != semid || sunptr->un_num != semnum)			continue;		if (adjval == 0)			sunptr->un_adjval = 0;		else			sunptr->un_adjval += adjval;		if (sunptr->un_adjval != 0)			return (0);		if (--suptr->un_cnt == 0) {			struct sem_undo *suprev;			if (semu_list == suptr)				semu_list = suptr->un_next;			else {				/* this code path should be rare */				for (suprev = semu_list; suprev != NULL &&				    suprev->un_next != suptr;				    suprev = suprev->un_next)					/* NOTHING */;#ifdef DIAGNOSTIC				if (suprev == NULL)					panic("semundo_adjust: "					    "suptr not in semu_list");#endif				suprev->un_next = suptr->un_next;			}			pool_put(&semu_pool, suptr);		} else if (i < suptr->un_cnt)			suptr->un_ent[i] =			    suptr->un_ent[suptr->un_cnt];		return (0);	}	/* Didn't find the right entry - create it */	if (adjval == 0)		return (0);	if (suptr->un_cnt == SEMUME)		return (EINVAL);	sunptr = &suptr->un_ent[suptr->un_cnt];	suptr->un_cnt++;	sunptr->un_adjval = adjval;	sunptr->un_id = semid;	sunptr->un_num = semnum;	return (0);}