Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / lib / cpu / src / SS_Chain.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: SS_Chain.h
5* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
7*
8* The above named program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public
10* License version 2 as published by the Free Software Foundation.
11*
12* The above named program is distributed in the hope that it will be
13* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this work; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20*
21* ========== Copyright Header End ============================================
22*/
23
24#ifndef __SS_Chain_h__
25#define __SS_Chain_h__
26
27// SS_Chain is node element of a basic cyclic double linked list
28// data structure.
29
30class SS_Chain
31{
32 public:
33 SS_Chain() : prev(this), next(this) {}
34
35 // The SS_Chanin class is used in "nasty" pointer arithmetic and
36 // this union is for makeing this struction 16 bytes in size in
37 // v8plus compilation mode.
38
39 union
40 {
41 SS_Chain* prev;
42 uint64_t align0;
43 };
44
45 union
46 {
47 SS_Chain* next;
48 uint64_t align1;
49 };
50
51 // clean() turns this node into a single element cyclio
52 // double linked list.
53 void clean()
54 {
55 prev = next = this;
56 }
57
58 // unlink() removes this chian node from the cyclic double
59 // linked list.
60 void unlink()
61 {
62 next->prev = prev;
63 prev->next = next;
64 }
65
66 // insert_after() inserts this after that node in the cyclic
67 // doule linked list.
68 void insert_after( SS_Chain* node )
69 {
70 next = node->next;
71 next->prev = this;
72 prev = node;
73 node->next = this;
74 }
75};
76
77
78#endif