xref: /onnv-gate/usr/src/lib/libast/common/vmalloc/vmset.c (revision 12068:08a39a083754)
14887Schin /***********************************************************************
24887Schin *                                                                      *
34887Schin *               This software is part of the ast package               *
4*12068SRoger.Faulkner@Oracle.COM *          Copyright (c) 1985-2010 AT&T Intellectual Property          *
54887Schin *                      and is licensed under the                       *
64887Schin *                  Common Public License, Version 1.0                  *
78462SApril.Chin@Sun.COM *                    by AT&T Intellectual Property                     *
84887Schin *                                                                      *
94887Schin *                A copy of the License is available at                 *
104887Schin *            http://www.opensource.org/licenses/cpl1.0.txt             *
114887Schin *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
124887Schin *                                                                      *
134887Schin *              Information and Software Systems Research               *
144887Schin *                            AT&T Research                             *
154887Schin *                           Florham Park NJ                            *
164887Schin *                                                                      *
174887Schin *                 Glenn Fowler <gsf@research.att.com>                  *
184887Schin *                  David Korn <dgk@research.att.com>                   *
194887Schin *                   Phong Vo <kpv@research.att.com>                    *
204887Schin *                                                                      *
214887Schin ***********************************************************************/
224887Schin #if defined(_UWIN) && defined(_BLD_ast)
234887Schin 
_STUB_vmset()244887Schin void _STUB_vmset(){}
254887Schin 
264887Schin #else
274887Schin 
284887Schin #include	"vmhdr.h"
294887Schin 
304887Schin 
314887Schin /*	Set the control flags for a region.
324887Schin **
334887Schin **	Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
344887Schin */
354887Schin #if __STD_C
vmset(reg Vmalloc_t * vm,int flags,int on)364887Schin int vmset(reg Vmalloc_t* vm, int flags, int on)
374887Schin #else
384887Schin int vmset(vm, flags, on)
394887Schin reg Vmalloc_t*	vm;	/* region being worked on		*/
404887Schin int		flags;	/* flags must be in VM_FLAGS		*/
414887Schin int		on;	/* !=0 if turning on, else turning off	*/
424887Schin #endif
434887Schin {
448462SApril.Chin@Sun.COM 	reg int		mode, inuse;
454887Schin 	reg Vmdata_t*	vd = vm->data;
464887Schin 
474887Schin 	if(flags == 0 && on == 0)
484887Schin 		return vd->mode;
494887Schin 
508462SApril.Chin@Sun.COM 	SETINUSE(vd, inuse);
514887Schin 	if(!(vd->mode&VM_TRUST) )
524887Schin 	{	if(ISLOCK(vd,0))
538462SApril.Chin@Sun.COM 		{	CLRINUSE(vd, inuse);
544887Schin 			return 0;
558462SApril.Chin@Sun.COM 		}
564887Schin 		SETLOCK(vd,0);
574887Schin 	}
584887Schin 
594887Schin 	mode = vd->mode;
604887Schin 
614887Schin 	if(on)
624887Schin 		vd->mode |=  (flags&VM_FLAGS);
634887Schin 	else	vd->mode &= ~(flags&VM_FLAGS);
644887Schin 
654887Schin 	if(vd->mode&(VM_TRACE|VM_MTDEBUG))
664887Schin 		vd->mode &= ~VM_TRUST;
674887Schin 
684887Schin 	CLRLOCK(vd,0);
698462SApril.Chin@Sun.COM 	CLRINUSE(vd, inuse);
704887Schin 
714887Schin 	return mode;
724887Schin }
734887Schin 
744887Schin #endif
75