1/* $Id$ $Revision$ */
2/* vim:set shiftwidth=4 ts=8: */
3
4/*************************************************************************
5 * Copyright (c) 2011 AT&T Intellectual Property
6 * All rights reserved. This program and the accompanying materials
7 * are made available under the terms of the Eclipse Public License v1.0
8 * which accompanies this distribution, and is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 *
11 * Contributors: See CVS logs. Details at http://www.graphviz.org/
12 *************************************************************************/
13
14#include "vmhdr.h"
15
16
17/* Set the control flags for a region.
18**
19** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
20*/
21/**
22 * @param vm region being worked on
23 * @param flags flags must be in VM_FLAGS
24 * @param on !=0 if turning on, else turning off
25 */
26int vmset(reg Vmalloc_t * vm, int flags, int on)
27{
28 reg int mode;
29 reg Vmdata_t *vd = vm->data;
30
31 if (flags == 0 && on == 0)
32 return vd->mode;
33
34 if (!(vd->mode & VM_TRUST)) {
35 if (ISLOCK(vd, 0))
36 return 0;
37 SETLOCK(vd, 0);
38 }
39
40 mode = vd->mode;
41
42 if (on)
43 vd->mode |= (flags & VM_FLAGS);
44 else
45 vd->mode &= ~(flags & VM_FLAGS);
46
47 if (vd->mode & (VM_TRACE | VM_MTDEBUG))
48 vd->mode &= ~VM_TRUST;
49
50 CLRLOCK(vd, 0);
51
52 return mode;
53}
54