aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code/ring.c
diff options
context:
space:
mode:
authorNick Barnes2001-10-31 14:40:56 +0000
committerNick Barnes2001-10-31 14:40:56 +0000
commit7acfca905d76140f4cc0b09c9a12de237de364cd (patch)
tree3ed8babfa3a73d30f29e08ca5d5adcda4ca4e826 /mps/code/ring.c
parentb7ce4893f9902d57cd67ac9a92fa6c3d5a8fc833 (diff)
downloademacs-7acfca905d76140f4cc0b09c9a12de237de364cd.tar.gz
emacs-7acfca905d76140f4cc0b09c9a12de237de364cd.zip
Branch imports for masters.
Copied from Perforce Change: 23678 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code/ring.c')
-rw-r--r--mps/code/ring.c122
1 files changed, 122 insertions, 0 deletions
diff --git a/mps/code/ring.c b/mps/code/ring.c
new file mode 100644
index 00000000000..67674c9fbc7
--- /dev/null
+++ b/mps/code/ring.c
@@ -0,0 +1,122 @@
1/* impl.c.ring: RING IMPLEMENTATION
2 *
3 * $HopeName$
4 * Copyright (C) 1995 Harlequin Limited. All rights reserved.
5 *
6 * .intro: This is a portable implementation of Rings.
7 *
8 * .purpose: Rings are used to manage potentially unbounded collections
9 * of things.
10 *
11 * .sources: design.mps.ring,
12 * item 6 of mail.richard_brooksby.1996-03-25.16-02
13 */
14
15#include "ring.h"
16#include "check.h"
17#include "misc.h"
18
19
20SRCID(ring, "$HopeName: MMsrc!ring.c(trunk.7) $");
21
22
23/* RingCheck, RingCheckSingle -- check the validity of a ring node
24 *
25 * RingCheck performs a consistency check on the ring node.
26 * RingCheckSingle performs the same check, but also checks that
27 * the ring node is a singleton (design.mps.ring.def.singleton).
28 */
29
30Bool RingCheck(Ring ring)
31{
32 CHECKL(ring != NULL);
33 CHECKL(ring->next != NULL);
34 CHECKL(ring->next->prev == ring);
35 CHECKL(ring->prev != NULL);
36 CHECKL(ring->prev->next == ring);
37 UNUSED(ring); /* impl.c.mpm.check.unused */
38 return TRUE;
39}
40
41Bool RingCheckSingle(Ring ring)
42{
43 CHECKL(RingCheck(ring));
44 CHECKL(ring->next == ring);
45 CHECKL(ring->prev == ring);
46 UNUSED(ring); /* impl.c.mpm.check.unused */
47 return TRUE;
48}
49
50Bool RingIsSingle(Ring ring)
51{
52 AVERT(Ring, ring);
53 return (ring->next == ring);
54}
55
56
57/* RingInit -- initialize a ring node
58 */
59
60void (RingInit)(Ring ring)
61{
62 RingInit(ring); /* impl.h.mpm.ring.init */
63}
64
65
66/* RingFinish -- finish a ring node
67 */
68
69void (RingFinish)(Ring ring)
70{
71 RingFinish(ring); /* impl.h.mpm.ring.finish */
72}
73
74
75/* RingAppend -- add a ring node to the end of a ring
76 */
77
78void (RingAppend)(Ring ring, Ring new)
79{
80 RingAppend(ring, new); /* impl.h.mpm.ring.append */
81}
82
83
84/* RingInsert -- add a ring node to the start of a ring
85 */
86
87void (RingInsert)(Ring ring, Ring new)
88{
89 RingInsert(ring, new); /* impl.h.mpm.ring.insert */
90}
91
92
93/* RingRemove -- remove a node from a ring
94 */
95
96void (RingRemove)(Ring old)
97{
98 RingRemove(old); /* impl.h.mpm.ring.remove */
99}
100
101
102/* RingNext -- get the next element of a ring
103 */
104
105Ring (RingNext)(Ring ring)
106{
107 return RingNext(ring); /* impl.h.mpm.ring.next */
108}
109
110
111/* RING_ELT -- get the ring element structure
112 *
113 * RING_ELT has no function (as it does not have function-like
114 * behaviour), and is defined in impl.h.mpm.ring.elt.
115 */
116
117
118/* RING_FOR -- ring iterator construct
119 *
120 * RING_FOR has no function (as it does not have function-like
121 * behaviour), and is defined in impl.h.mpm.ring.for.
122 */