diff options
| author | Nick Barnes | 2001-10-31 14:40:56 +0000 |
|---|---|---|
| committer | Nick Barnes | 2001-10-31 14:40:56 +0000 |
| commit | 7acfca905d76140f4cc0b09c9a12de237de364cd (patch) | |
| tree | 3ed8babfa3a73d30f29e08ca5d5adcda4ca4e826 /mps/code/ref.c | |
| parent | b7ce4893f9902d57cd67ac9a92fa6c3d5a8fc833 (diff) | |
| download | emacs-7acfca905d76140f4cc0b09c9a12de237de364cd.tar.gz emacs-7acfca905d76140f4cc0b09c9a12de237de364cd.zip | |
Branch imports for masters.
Copied from Perforce
Change: 23678
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code/ref.c')
| -rw-r--r-- | mps/code/ref.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/mps/code/ref.c b/mps/code/ref.c new file mode 100644 index 00000000000..8614cd5b451 --- /dev/null +++ b/mps/code/ref.c | |||
| @@ -0,0 +1,81 @@ | |||
| 1 | /* impl.c.ref: REFERENCES | ||
| 2 | * | ||
| 3 | * $HopeName: MMsrc!ref.c(trunk.12) $ | ||
| 4 | * Copyright (C) 1999 Harlequin Limited. All rights reserved. | ||
| 5 | * | ||
| 6 | * .purpose: Implement operations on Ref, RefSet, ZoneSet, and Rank. | ||
| 7 | * | ||
| 8 | * .design: See design.mps.ref and design.mps.refset. | ||
| 9 | */ | ||
| 10 | |||
| 11 | #include "mpm.h" | ||
| 12 | |||
| 13 | SRCID(ref, "$HopeName: MMsrc!ref.c(trunk.12) $"); | ||
| 14 | |||
| 15 | |||
| 16 | /* RankCheck -- check a rank value */ | ||
| 17 | |||
| 18 | Bool RankCheck(Rank rank) | ||
| 19 | { | ||
| 20 | CHECKL(rank < RankLIMIT); | ||
| 21 | UNUSED(rank); /* impl.c.mpm.check.unused */ | ||
| 22 | return TRUE; | ||
| 23 | } | ||
| 24 | |||
| 25 | |||
| 26 | /* RankSetCheck -- check a rank set */ | ||
| 27 | |||
| 28 | Bool RankSetCheck(RankSet rankSet) | ||
| 29 | { | ||
| 30 | CHECKL(rankSet < (1uL << RankLIMIT)); | ||
| 31 | UNUSED(rankSet); /* impl.c.mpm.check.unused */ | ||
| 32 | return TRUE; | ||
| 33 | } | ||
| 34 | |||
| 35 | |||
| 36 | /* ZoneSetOfRange -- calculate the zone set of a range of addresses */ | ||
| 37 | |||
| 38 | RefSet ZoneSetOfRange(Arena arena, Addr base, Addr limit) | ||
| 39 | { | ||
| 40 | Word zbase, zlimit; | ||
| 41 | |||
| 42 | AVERT(Arena, arena); | ||
| 43 | AVER(limit > base); | ||
| 44 | |||
| 45 | /* The base and limit zones of the range are calculated. The limit */ | ||
| 46 | /* zone is the zone after the last zone of the range, not the zone of */ | ||
| 47 | /* the limit address. */ | ||
| 48 | zbase = (Word)base >> arena->zoneShift; | ||
| 49 | zlimit = (((Word)limit-1) >> arena->zoneShift) + 1; | ||
| 50 | |||
| 51 | |||
| 52 | /* If the range is large enough to span all zones, its zone set is */ | ||
| 53 | /* universal. */ | ||
| 54 | if (zlimit - zbase >= MPS_WORD_WIDTH) | ||
| 55 | return ZoneSetUNIV; | ||
| 56 | |||
| 57 | zbase &= MPS_WORD_WIDTH - 1; | ||
| 58 | zlimit &= MPS_WORD_WIDTH - 1; | ||
| 59 | |||
| 60 | /* If the base zone is less than the limit zone, the zone set looks */ | ||
| 61 | /* like 000111100, otherwise it looks like 111000011. */ | ||
| 62 | if (zbase < zlimit) | ||
| 63 | return ((ZoneSet)1<<zlimit) - ((ZoneSet)1<<zbase); | ||
| 64 | else | ||
| 65 | return ~(((ZoneSet)1<<zbase) - ((ZoneSet)1<<zlimit)); | ||
| 66 | } | ||
| 67 | |||
| 68 | |||
| 69 | /* ZoneSetOfSeg -- calculate the zone set of segment addresses | ||
| 70 | * | ||
| 71 | * .rsor.def: The zone set of a segment is the union of the zones the | ||
| 72 | * segment occupies. | ||
| 73 | */ | ||
| 74 | |||
| 75 | ZoneSet ZoneSetOfSeg(Arena arena, Seg seg) | ||
| 76 | { | ||
| 77 | /* arena is checked by ZoneSetOfRange */ | ||
| 78 | AVERT(Seg, seg); | ||
| 79 | |||
| 80 | return ZoneSetOfRange(arena, SegBase(seg), SegLimit(seg)); | ||
| 81 | } | ||