My Project
Loading...
Searching...
No Matches
Macros | Functions
omList.h File Reference

Go to the source code of this file.

Macros

#define OM_LIST_OFFSET(ptr, name_of_offset_field)    (ptr != NULL ? ((char*) &(ptr->name_of_offset_field)) - ((char*) ptr) : 0)
 
#define omListLength(ptr)    _omListLength(ptr, 0)
 
#define omListLast(ptr)    _omListLast(ptr, 0)
 
#define omListHasCycle(ptr)    _omListHasCycle(ptr, 0)
 
#define omIsOnList(ptr, addr)    _omIsOnList(ptr, 0, addr)
 
#define omRemoveFromList(ptr, addr)    _omRemoveFromList(ptr, 0, addr)
 
#define omFindInList(ptr, what, value)    _omFindInList(ptr, 0, OM_LIST_OFFSET(ptr, what), (unsigned long) value)
 
#define omInsertInSortedList(ptr, what, addr)    _omInsertInSortedList(ptr, 0, OM_LIST_OFFSET(ptr, what), addr)
 
#define omFindInSortedList(ptr, what, value)    _omFindInSortedList(ptr, 0, OM_LIST_OFFSET(ptr, what), value)
 
#define omRemoveFromSortedList(ptr, what, addr)    _omRemoveFromSortedList(ptr, 0, OM_LIST_OFFSET(ptr, what), addr)
 
#define omTestList(ptr, level)    _omCheckList(ptr, 0, level, omError_NoError, OM_FLR)
 
#define omCheckList(ptr, level, report, OM_FLR_VAL)    _omCheckList(ptr, 0, level, report, OM_FLR_VAL)
 
#define omCheckSortedList(ptr, what, level, report, OM_FLR_VAL)    _omCheckSortedList(ptr, 0, OM_LIST_OFFSET(ptr, what), level, report, OM_FLR_VAL)
 
#define omGListLength(ptr, next)    _omListLength(ptr, OM_LIST_OFFSET(ptr, next))
 
#define omGListLast(ptr, next)    _omListLast(ptr, OM_LIST_OFFSET(ptr, next))
 
#define omGListHasCycle(ptr, next)    _omListHasCycle(ptr, OM_LIST_OFFSET(ptr, next))
 
#define omIsOnGList(ptr, next, addr)    _omIsOnList(ptr, OM_LIST_OFFSET(ptr, next), addr)
 
#define omRemoveFromGList(ptr, next, addr)    _omRemoveFromList(ptr, OM_LIST_OFFSET(ptr, next), addr)
 
#define omFindInGList(ptr, next, what, value)    _omFindInList(ptr, OM_LIST_OFFSET(ptr, next), OM_LIST_OFFSET(ptr, what), (unsigned long) value)
 
#define omInsertInSortedGList(ptr, next, what, addr)    _omInsertInSortedList(ptr, OM_LIST_OFFSET(ptr, next), OM_LIST_OFFSET(ptr, what), addr)
 
#define omFindInSortedGList(ptr, next, what, value)    _omFindInSortedList(ptr, OM_LIST_OFFSET(ptr, next),OM_LIST_OFFSET(ptr,what),value)
 
#define omRemoveFromSortedGList(ptr, next, what, addr)    _omRemoveFromSortedList(ptr, OM_LIST_OFFSET(addr,next),OM_LIST_OFFSET(addr,what),addr)
 
#define omTestGList(ptr, next, level)    omCheckGList(ptr, next, level, omError_NoError, OM_FLR)
 
#define omCheckGList(ptr, next, level, report, OM_FLR_VAL)    _omCheckList(ptr, OM_LIST_OFFSET(ptr,next), level, report, OM_FLR_VAL)
 
#define omCheckSortedGList(ptr, next, what, level, report, OM_FLR_VAL)    _omCheckSortedList(ptr, OM_LIST_OFFSET(ptr,next), OM_LIST_OFFSET(ptr,what), level, report, OM_FLR_VAL)
 

Functions

int _omListLength (void *list, int next)
 
void * _omListLast (void *list, int next)
 
void * _omListHasCycle (void *list, int next)
 
void * _omIsOnList (void *list, int next, void *addr)
 
void * _omRemoveFromList (void *list, int next, void *addr)
 
void * _omFindInList (void *list, int next, int long_field, unsigned long what)
 
void * _omFindInSortedList (void *list, int next, int long_field, unsigned long what)
 
void * _omRemoveFromSortedList (void *list, int next, int long_field, void *addr)
 
void * _omInsertInSortedList (void *list, int next, int long_field, void *addr)
 
omError_t _omCheckList (void *list, int next, int level, omError_t report, OM_FLR_DECL)
 
omError_t _omCheckSortedList (void *list, int next, int long_field, int level, omError_t report, OM_FLR_DECL)
 

Macro Definition Documentation

◆ OM_LIST_OFFSET

#define OM_LIST_OFFSET (   ptr,
  name_of_offset_field 
)     (ptr != NULL ? ((char*) &(ptr->name_of_offset_field)) - ((char*) ptr) : 0)

Definition at line 11 of file omList.h.

◆ omCheckGList

#define omCheckGList (   ptr,
  next,
  level,
  report,
  OM_FLR_VAL 
)     _omCheckList(ptr, OM_LIST_OFFSET(ptr,next), level, report, OM_FLR_VAL)

Definition at line 115 of file omList.h.

◆ omCheckList

#define omCheckList (   ptr,
  level,
  report,
  OM_FLR_VAL 
)     _omCheckList(ptr, 0, level, report, OM_FLR_VAL)

Definition at line 83 of file omList.h.

◆ omCheckSortedGList

#define omCheckSortedGList (   ptr,
  next,
  what,
  level,
  report,
  OM_FLR_VAL 
)     _omCheckSortedList(ptr, OM_LIST_OFFSET(ptr,next), OM_LIST_OFFSET(ptr,what), level, report, OM_FLR_VAL)

Definition at line 117 of file omList.h.

◆ omCheckSortedList

#define omCheckSortedList (   ptr,
  what,
  level,
  report,
  OM_FLR_VAL 
)     _omCheckSortedList(ptr, 0, OM_LIST_OFFSET(ptr, what), level, report, OM_FLR_VAL)

Definition at line 85 of file omList.h.

◆ omFindInGList

#define omFindInGList (   ptr,
  next,
  what,
  value 
)     _omFindInList(ptr, OM_LIST_OFFSET(ptr, next), OM_LIST_OFFSET(ptr, what), (unsigned long) value)

Definition at line 104 of file omList.h.

◆ omFindInList

#define omFindInList (   ptr,
  what,
  value 
)     _omFindInList(ptr, 0, OM_LIST_OFFSET(ptr, what), (unsigned long) value)

Definition at line 72 of file omList.h.

◆ omFindInSortedGList

#define omFindInSortedGList (   ptr,
  next,
  what,
  value 
)     _omFindInSortedList(ptr, OM_LIST_OFFSET(ptr, next),OM_LIST_OFFSET(ptr,what),value)

Definition at line 108 of file omList.h.

◆ omFindInSortedList

#define omFindInSortedList (   ptr,
  what,
  value 
)     _omFindInSortedList(ptr, 0, OM_LIST_OFFSET(ptr, what), value)

Definition at line 76 of file omList.h.

◆ omGListHasCycle

#define omGListHasCycle (   ptr,
  next 
)     _omListHasCycle(ptr, OM_LIST_OFFSET(ptr, next))

Definition at line 98 of file omList.h.

◆ omGListLast

#define omGListLast (   ptr,
  next 
)     _omListLast(ptr, OM_LIST_OFFSET(ptr, next))

Definition at line 96 of file omList.h.

◆ omGListLength

#define omGListLength (   ptr,
  next 
)     _omListLength(ptr, OM_LIST_OFFSET(ptr, next))

Definition at line 94 of file omList.h.

◆ omInsertInSortedGList

#define omInsertInSortedGList (   ptr,
  next,
  what,
  addr 
)     _omInsertInSortedList(ptr, OM_LIST_OFFSET(ptr, next), OM_LIST_OFFSET(ptr, what), addr)

Definition at line 106 of file omList.h.

◆ omInsertInSortedList

#define omInsertInSortedList (   ptr,
  what,
  addr 
)     _omInsertInSortedList(ptr, 0, OM_LIST_OFFSET(ptr, what), addr)

Definition at line 74 of file omList.h.

◆ omIsOnGList

#define omIsOnGList (   ptr,
  next,
  addr 
)     _omIsOnList(ptr, OM_LIST_OFFSET(ptr, next), addr)

Definition at line 100 of file omList.h.

◆ omIsOnList

#define omIsOnList (   ptr,
  addr 
)     _omIsOnList(ptr, 0, addr)

Definition at line 68 of file omList.h.

◆ omListHasCycle

#define omListHasCycle (   ptr)     _omListHasCycle(ptr, 0)

Definition at line 66 of file omList.h.

◆ omListLast

#define omListLast (   ptr)     _omListLast(ptr, 0)

Definition at line 64 of file omList.h.

◆ omListLength

#define omListLength (   ptr)     _omListLength(ptr, 0)

Definition at line 62 of file omList.h.

◆ omRemoveFromGList

#define omRemoveFromGList (   ptr,
  next,
  addr 
)     _omRemoveFromList(ptr, OM_LIST_OFFSET(ptr, next), addr)

Definition at line 102 of file omList.h.

◆ omRemoveFromList

#define omRemoveFromList (   ptr,
  addr 
)     _omRemoveFromList(ptr, 0, addr)

Definition at line 70 of file omList.h.

◆ omRemoveFromSortedGList

#define omRemoveFromSortedGList (   ptr,
  next,
  what,
  addr 
)     _omRemoveFromSortedList(ptr, OM_LIST_OFFSET(addr,next),OM_LIST_OFFSET(addr,what),addr)

Definition at line 110 of file omList.h.

◆ omRemoveFromSortedList

#define omRemoveFromSortedList (   ptr,
  what,
  addr 
)     _omRemoveFromSortedList(ptr, 0, OM_LIST_OFFSET(ptr, what), addr)

Definition at line 78 of file omList.h.

◆ omTestGList

#define omTestGList (   ptr,
  next,
  level 
)     omCheckGList(ptr, next, level, omError_NoError, OM_FLR)

Definition at line 113 of file omList.h.

◆ omTestList

#define omTestList (   ptr,
  level 
)     _omCheckList(ptr, 0, level, omError_NoError, OM_FLR)

Definition at line 81 of file omList.h.

Function Documentation

◆ _omCheckList()

omError_t _omCheckList ( void *  list,
int  next,
int  level,
omError_t  report,
OM_FLR_DECL   
)

Definition at line 178 of file omList.c.

179{
180 if (level < 1) return omError_NoError;
181
182 if (level == 1)
183 {
184 while (list != NULL)
185 {
186 omCheckReturn(omCheckPtr(list, report, OM_FLR_VAL));
187 ITER(list);
188 }
189 }
190 else
191 {
192 void* l1 = list;
193 void* l2;
194 int l = 0, i;
195
196 l1 = list;
197 while (l1 != NULL)
198 {
199 omCheckReturn(omCheckPtr(l1, report, OM_FLR_VAL));
200 i = 0;
201 l2 = list;
202 while (l1 != l2)
203 {
204 i++;
205 ITER(l2);
206 }
207 if (i != l)
208 return omReportError(omError_ListCycleError, report, OM_FLR_VAL, "");
209 ITER(l1);
210 l++;
211 }
212 }
213 return omError_NoError;
214}
int level(const CanonicalForm &f)
int l
Definition: cfEzgcd.cc:100
int i
Definition: cfEzgcd.cc:132
omError_t omCheckPtr(const void *ptr, omError_t report, OM_FLR_DECL)
Definition: omDebugCheck.c:136
#define omCheckReturn(cond)
Definition: omDebug.h:170
omError_t omReportError(omError_t error, omError_t report_error, OM_FLR_DECL, const char *fmt,...)
Definition: omError.c:80
@ omError_ListCycleError
Definition: omError.h:34
@ omError_NoError
Definition: omError.h:18
#define NULL
Definition: omList.c:12
#define ITER(list)
Definition: omList.c:18

◆ _omCheckSortedList()

omError_t _omCheckSortedList ( void *  list,
int  next,
int  long_field,
int  level,
omError_t  report,
OM_FLR_DECL   
)

Definition at line 216 of file omList.c.

217{
218 void* prev = NULL;
219
220 if (level <= 1) return omError_NoError;
221
222 if (level == 1)
223 {
224 while (list != NULL)
225 {
226 omCheckReturn(omCheckPtr(list, report, OM_FLR_VAL));
227 if (prev != NULL && VALUE(prev, long_field) > VALUE(list, long_field))
228 return omReportError(omError_SortedListError, report, OM_FLR_VAL,
229 "%d > %d", VALUE(prev, long_field), VALUE(list, long_field));
230 prev = list;
231 ITER(list);
232 }
233 }
234 else
235 {
236 void* l1 = list;
237 void* l2;
238 int l = 0, i;
239
240 while (l1 != NULL)
241 {
242 omCheckReturn(omCheckPtr(l1, report, OM_FLR_VAL));
243 if (prev != NULL && VALUE(prev, long_field) > VALUE(l1, long_field))
244 return omReportError(omError_SortedListError, report, OM_FLR_VAL,
245 "%d > %d", VALUE(prev, long_field), VALUE(l1, long_field));
246 i = 0;
247 l2 = list;
248 while (l1 != l2)
249 {
250 i++;
251 ITER(l2);
252 }
254 prev = l1;
255 ITER(l1);
256 l++;
257 }
258 }
259 return omError_NoError;
260}
#define omCheckReturnError(cond, error)
Definition: omDebug.h:172
@ omError_SortedListError
Definition: omError.h:35
#define VALUE(list, offset)
Definition: omList.c:16

◆ _omFindInList()

void * _omFindInList ( void *  list,
int  next,
int  long_field,
unsigned long  what 
)

Definition at line 100 of file omList.c.

101{
102 while (list != NULL)
103 {
104 if (VALUE(list, long_field) == what) return list;
105 ITER(list);
106 }
107 return NULL;
108}

◆ _omFindInSortedList()

void * _omFindInSortedList ( void *  list,
int  next,
int  long_field,
unsigned long  what 
)

Definition at line 110 of file omList.c.

112{
113 while (list != NULL)
114 {
115 if (VALUE(list, long_field) >= what)
116 {
117 if (VALUE(list, long_field) == what) return list;
118 return NULL;
119 }
120 ITER(list);
121 }
122 return NULL;
123}

◆ _omInsertInSortedList()

void * _omInsertInSortedList ( void *  list,
int  next,
int  long_field,
void *  addr 
)

Definition at line 148 of file omList.c.

149{
150 unsigned long what = VALUE(addr, long_field);
151
152 if (list == NULL || what <= VALUE(list, long_field))
153 {
154 NEXT(addr) = list;
155 return addr;
156 }
157 else
158 {
159 void* prev = list;
160 void* curr = NEXT(list);
161
162 while (curr != NULL && VALUE(curr, long_field) < what)
163 {
164 prev = curr;
165 ITER(curr);
166 }
167 NEXT(prev) = addr;
168 NEXT(addr) = curr;
169 return list;
170 }
171}
#define NEXT(list)
Definition: omList.c:17

◆ _omIsOnList()

void * _omIsOnList ( void *  list,
int  next,
void *  addr 
)

Definition at line 66 of file omList.c.

67{
68 if (addr == NULL)
69 return (NULL);
70
71 while (list != NULL)
72 {
73 if (addr == list) return addr;
74 ITER(list);
75 }
76 return 0;
77}

◆ _omListHasCycle()

void * _omListHasCycle ( void *  list,
int  next 
)

Definition at line 42 of file omList.c.

43{
44 void* l1 = list;
45 void* l2;
46
47 int l = 0, i;
48
49 while (l1 != NULL)
50 {
51 i = 0;
52 l2 = list;
53 while (l1 != l2)
54 {
55 i++;
56 ITER(l2);
57 }
58 if (i != l) return l1;
59 ITER(l1);
60 l++;
61 }
62 return NULL;
63}

◆ _omListLast()

void * _omListLast ( void *  list,
int  next 
)

Definition at line 32 of file omList.c.

33{
34 if (list == NULL) return NULL;
35
36 while (NEXT(list) != NULL) ITER(list);
37
38 return list;
39}

◆ _omListLength()

int _omListLength ( void *  list,
int  next 
)

Definition at line 20 of file omList.c.

21{
22 int l = 0;
23 while (list != NULL)
24 {
25 l++;
26 ITER(list);
27 }
28 return l;
29}

◆ _omRemoveFromList()

void * _omRemoveFromList ( void *  list,
int  next,
void *  addr 
)

Definition at line 79 of file omList.c.

80{
81 void* nlist;
82 void* olist;
83
84 if (list == NULL) return NULL;
85
86 nlist = NEXT(list);
87 if (list == addr) return nlist;
88
89 olist = list;
90 while (nlist != NULL && nlist != addr)
91 {
92 list = nlist;
93 ITER(nlist);
94 }
95
96 if (nlist != NULL) NEXT(list) = NEXT(nlist);
97 return olist;
98}

◆ _omRemoveFromSortedList()

void * _omRemoveFromSortedList ( void *  list,
int  next,
int  long_field,
void *  addr 
)

Definition at line 125 of file omList.c.

126{
127 void* nlist;
128 void* olist;
129 unsigned long what = VALUE(addr, long_field);
130
131 if (list == NULL) return NULL;
132 nlist = NEXT(list);
133 if (list == addr) return nlist;
134 if (VALUE(list, long_field) > what) return list;
135
136 olist = list;
137 while (nlist != NULL && nlist != addr)
138 {
139 if (VALUE(list, long_field) > what) return olist;
140 list = nlist;
141 ITER(nlist);
142 }
143
144 if (nlist != NULL) NEXT(list) = NEXT(nlist);
145 return olist;
146}