xref: /titanic_44/usr/src/lib/libast/common/vmalloc/vmregion.c (revision 7ff178cd8db129d385d3177eb20744d3b6efc59b)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1985-2010 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *            http://www.opensource.org/licenses/cpl1.0.txt             *
11 *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                 Glenn Fowler <gsf@research.att.com>                  *
18 *                  David Korn <dgk@research.att.com>                   *
19 *                   Phong Vo <kpv@research.att.com>                    *
20 *                                                                      *
21 ***********************************************************************/
22 #if defined(_UWIN) && defined(_BLD_ast)
23 
24 void _STUB_vmregion(){}
25 
26 #else
27 
28 #include	"vmhdr.h"
29 
30 /*	Return the containing region of an allocated piece of memory.
31 **	Beware: this only works with Vmbest, Vmdebug and Vmprofile.
32 **
33 **	10/31/2009: Add handling of shared/persistent memory regions.
34 **
35 **	Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
36 */
37 #if __STD_C
38 Vmalloc_t* vmregion(Void_t* addr)
39 #else
40 Vmalloc_t* vmregion(addr)
41 Void_t*	addr;
42 #endif
43 {
44 	Vmalloc_t	*vm;
45 	Vmdata_t	*vd;
46 
47 	if(!addr)
48 		return NIL(Vmalloc_t*);
49 
50 	vd = SEG(BLOCK(addr))->vmdt;
51 	for(vm = Vmheap; vm; vm = vm->next)
52 		if(vm->data == vd)
53 			break;
54 
55 	return vm;
56 }
57 
58 #endif
59