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_vmsegment()244887Schin void _STUB_vmsegment(){}
254887Schin
264887Schin #else
274887Schin
284887Schin #include "vmhdr.h"
294887Schin
304887Schin /* Get the segment containing this address
314887Schin **
324887Schin ** Written by Kiem-Phong Vo, kpv@research.att.com, 02/07/95
334887Schin */
344887Schin
354887Schin #if __STD_C
vmsegment(Vmalloc_t * vm,Void_t * addr)364887Schin Void_t* vmsegment(Vmalloc_t* vm, Void_t* addr)
374887Schin #else
384887Schin Void_t* vmsegment(vm, addr)
394887Schin Vmalloc_t* vm; /* region */
404887Schin Void_t* addr; /* address */
414887Schin #endif
424887Schin {
434887Schin reg Seg_t* seg;
444887Schin reg Vmdata_t* vd = vm->data;
458462SApril.Chin@Sun.COM reg int inuse;
464887Schin
478462SApril.Chin@Sun.COM SETINUSE(vd, inuse);
484887Schin if(!(vd->mode&VM_TRUST))
494887Schin { if(ISLOCK(vd,0))
508462SApril.Chin@Sun.COM { CLRINUSE(vd, inuse);
514887Schin return NIL(Void_t*);
528462SApril.Chin@Sun.COM }
534887Schin SETLOCK(vd,0);
544887Schin }
554887Schin
564887Schin for(seg = vd->seg; seg; seg = seg->next)
574887Schin if((Vmuchar_t*)addr >= (Vmuchar_t*)seg->addr &&
584887Schin (Vmuchar_t*)addr < (Vmuchar_t*)seg->baddr )
594887Schin break;
604887Schin
614887Schin CLRLOCK(vd,0);
628462SApril.Chin@Sun.COM CLRINUSE(vd, inuse);
634887Schin return seg ? (Void_t*)seg->addr : NIL(Void_t*);
644887Schin }
654887Schin
664887Schin #endif
67