annotate packages/kernel/current/include/llistt.hxx @ 3292:7f8e529b4d82 default tip

Fix FREESCALE_EDMA_NBYTES_MLOFFYES_MLOFF() so it works with negative offsets.
author vae
date Wed, 29 Apr 2015 23:31:48 +0000
parents 74dbf4c3f2e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
1 #ifndef CYGONCE_KERNEL_LLISTT_HXX
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
2 #define CYGONCE_KERNEL_LLISTT_HXX
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
3
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
4 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
5 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
6 // llistt.hxx
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
7 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
8 // Llistt linked list template class declarations
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
9 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
10 //==========================================================================
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
11 // ####ECOSGPLCOPYRIGHTBEGIN####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
12 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
13 // This file is part of eCos, the Embedded Configurable Operating System.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
14 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
15 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
16 // eCos is free software; you can redistribute it and/or modify it under
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
17 // the terms of the GNU General Public License as published by the Free
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
18 // Software Foundation; either version 2 or (at your option) any later
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
19 // version.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
20 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
21 // eCos is distributed in the hope that it will be useful, but WITHOUT
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
22 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
23 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
24 // for more details.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
25 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
26 // You should have received a copy of the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
27 // along with eCos; if not, write to the Free Software Foundation, Inc.,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
28 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
29 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
30 // As a special exception, if other files instantiate templates or use
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
31 // macros or inline functions from this file, or you compile this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
32 // and link it with other works to produce a work based on this file,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
33 // this file does not by itself cause the resulting work to be covered by
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
34 // the GNU General Public License. However the source code for this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
35 // must still be made available in accordance with section (3) of the GNU
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
36 // General Public License v2.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
37 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
38 // This exception does not invalidate any other reasons why a work based
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
39 // on this file might be covered by the GNU General Public License.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
40 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
41 // ####ECOSGPLCOPYRIGHTEND####
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
42 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
43 //#####DESCRIPTIONBEGIN####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
44 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
45 // Author(s): hmt
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
46 // Contributors: hmt
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
47 // Date: 1998-02-10
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
48 // Purpose: Define Llistt template class
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
49 // Description: The classes defined here provide the APIs for llistts.
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
50 // Usage: #include <cyg/kernel/llistt.hxx>
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
51 //
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
52 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
53 //####DESCRIPTIONEND####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
54 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
55 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
56
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
57 #include <cyg/kernel/ktypes.h>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
58 #include <cyg/infra/cyg_ass.h> // assertion macros
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
59 #include <cyg/kernel/thread.hxx>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
60
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
61 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
62 // A simple linked list template; each item also contains a pointer of type
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
63 // T, and you can search for a particular T* in a list.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
64 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
65 // It is intended that this list be amenable to the trick of using the
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
66 // address of the pointer that is the list head, cast to an item pointer,
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
67 // as the "zeroth" element of the list; prev of the first item is the
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
68 // address of the head pointer, and inserting before the first item works
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
69 // correctly. For this reason, a "getprev" is not provided; iteration may
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
70 // only be forwards, until a NULL is found.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
71 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
72 // It is expected that derived classes will be used to hold other
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
73 // information than just the T* but that is beyond our discussion here;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
74 // only the T* can be searched for using code provided here.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
75 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
76 // This module is NOT thread-safe; it is expected that all clients will be
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
77 // seeing that that themselves.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
78
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
79 template <class T>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
80 class Cyg_Llistt
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
81 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
82 private:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
83 Cyg_Llistt<T> *next, *prev;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
84 T *tptr;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
85
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
86 private:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
87 // make initialisation _without_ a T* impossible.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
88 Cyg_Llistt<T> &operator=(Cyg_Llistt<T> &);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
89 Cyg_Llistt(Cyg_Llistt<T> &);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
90 Cyg_Llistt();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
91
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
92 public:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
93
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
94 CYGDBG_DEFINE_CHECK_THIS
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
95
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
96 Cyg_Llistt( T *tvalue ) // Constructor
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
97 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
98 tptr = tvalue;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
99 next = prev = NULL;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
100 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
101
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
102 ~Cyg_Llistt() // Destructor
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
103 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
104 CYG_ASSERT( NULL == next, "bad item next - still in list" );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
105 CYG_ASSERT( NULL == prev, "bad item prev - still in list" );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
106 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
107
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
108 // iterator, basically.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
109 Cyg_Llistt<T> * getnext() { return next; }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
110
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
111 // get the value
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
112 T * getitem() { return tptr; }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
113
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
114 // look up a particular T value in the llist
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
115 static Cyg_Llistt<T> *
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
116 find( Cyg_Llistt<T> *list, T *tvalue )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
117 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
118 for ( ; list ; list = list->next ) {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
119 if ( list->tptr == tvalue )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
120 break;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
121 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
122 return list;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
123 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
124
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
125 // unlink an item from the list
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
126 void
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
127 unlink()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
128 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
129 CYG_ASSERT( prev, "not in a list" );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
130 prev->next = next;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
131 if ( next ) {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
132 next->prev = prev;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
133 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
134 next = prev = NULL;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
135 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
136
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
137 // insert a new item in the list after "this"
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
138 void
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
139 insertafter( Cyg_Llistt<T> *item )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
140 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
141 CYG_ASSERT( item, "null item" );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
142 CYG_ASSERT( NULL == item->next, "bad item next - already linked" );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
143 CYG_ASSERT( NULL == item->prev, "bad item prev - already linked" );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
144 item->next = next;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
145 item->prev = this;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
146 if ( next )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
147 next->prev = item;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
148 next = item;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
149 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
150
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
151 // insert a new item in the list before "this"
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
152 void
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
153 insertbefore( Cyg_Llistt<T> *item )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
154 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
155 CYG_ASSERT( prev, "this not in a list" );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
156 CYG_ASSERT( item, "null item" );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
157 CYG_ASSERT( NULL == item->next, "bad item next - already linked" );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
158 CYG_ASSERT( NULL == item->prev, "bad item prev - already linked" );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
159 item->prev = prev;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
160 item->next = this;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
161 prev->next = item;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
162 prev = item;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
163 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
164 };
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
165
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
166
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
167
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
168 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
169 #endif // ifndef CYGONCE_KERNEL_LLISTT_HXX
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
170 // EOF llistt.hxx