1/***********************************************************************
2*                                                                      *
3*               This software is part of the ast package               *
4*          Copyright (c) 1985-2011 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
24void _STUB_vmwalk(){}
25
26#else
27
28#include	"vmhdr.h"
29
30/*	Walks all segments created in region(s)
31**
32**	Written by Kiem-Phong Vo, kpv@research.att.com (02/08/96)
33*/
34
35#if __STD_C
36int vmwalk(Vmalloc_t* vm, int(*segf)(Vmalloc_t*, Void_t*, size_t, Vmdisc_t*, Void_t*), Void_t* handle )
37#else
38int vmwalk(vm, segf, handle)
39Vmalloc_t*	vm;
40int(*		segf)(/* Vmalloc_t*, Void_t*, size_t, Vmdisc_t* */);
41Void_t*		handle;
42#endif
43{
44	reg Seg_t*	seg;
45	reg int		rv;
46
47	if(!vm)
48	{	for(vm = Vmheap; vm; vm = vm->next)
49		{	if(!(vm->data->mode&VM_TRUST) && ISLOCK(vm->data,0) )
50				continue;
51
52			SETLOCK(vm->data,0);
53			for(seg = vm->data->seg; seg; seg = seg->next)
54			{	rv = (*segf)(vm, seg->addr, seg->extent, vm->disc, handle);
55				if(rv < 0)
56					return rv;
57			}
58			CLRLOCK(vm->data,0);
59		}
60	}
61	else
62	{	if(!(vm->data->mode&VM_TRUST) && ISLOCK(vm->data,0) )
63			return -1;
64
65		SETLOCK(vm->data,0);
66		for(seg = vm->data->seg; seg; seg = seg->next)
67		{	rv = (*segf)(vm, seg->addr, seg->extent, vm->disc, handle);
68			if(rv < 0)
69				return rv;
70		}
71		CLRLOCK(vm->data,0);
72	}
73
74	return 0;
75}
76
77#endif
78