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 176 of file omList.c.

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

◆ _omCheckSortedList()

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

Definition at line 214 of file omList.c.

215 {
216  void* prev = NULL;
217 
218  if (level <= 1) return omError_NoError;
219 
220  if (level == 1)
221  {
222  while (list != NULL)
223  {
224  omCheckReturn(omCheckPtr(list, report, OM_FLR_VAL));
225  if (prev != NULL && VALUE(prev, long_field) > VALUE(list, long_field))
226  return omReportError(omError_SortedListError, report, OM_FLR_VAL,
227  "%d > %d", VALUE(prev, long_field), VALUE(list, long_field));
228  prev = list;
229  ITER(list);
230  }
231  }
232  else
233  {
234  void* l1 = list;
235  void* l2;
236  int l = 0, i;
237 
238  while (l1 != NULL)
239  {
240  omCheckReturn(omCheckPtr(l1, report, OM_FLR_VAL));
241  if (prev != NULL && VALUE(prev, long_field) > VALUE(l1, long_field))
242  return omReportError(omError_SortedListError, report, OM_FLR_VAL,
243  "%d > %d", VALUE(prev, long_field), VALUE(l1, long_field));
244  i = 0;
245  l2 = list;
246  while (l1 != l2)
247  {
248  i++;
249  ITER(l2);
250  }
252  prev = l1;
253  ITER(l1);
254  l++;
255  }
256  }
257  return omError_NoError;
258 }
omError_t omReportError(omError_t error, omError_t report_error, OM_FLR_DECL, const char *fmt,...)
Definition: omError.c:78
int level(const CanonicalForm &f)
#define omCheckReturnError(cond, error)
Definition: omDebug.h:172
#define omCheckReturn(cond)
Definition: omDebug.h:170
omError_t omCheckPtr(const void *ptr, omError_t report, OM_FLR_DECL)
Definition: omDebugCheck.c:136
int i
Definition: cfEzgcd.cc:123
#define VALUE(list, offset)
Definition: omList.c:14
#define NULL
Definition: omList.c:10
#define ITER(list)
Definition: omList.c:16
int l
Definition: cfEzgcd.cc:94

◆ _omFindInList()

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

Definition at line 98 of file omList.c.

99 {
100  while (list != NULL)
101  {
102  if (VALUE(list, long_field) == what) return list;
103  ITER(list);
104  }
105  return NULL;
106 }
#define VALUE(list, offset)
Definition: omList.c:14
#define NULL
Definition: omList.c:10
#define ITER(list)
Definition: omList.c:16

◆ _omFindInSortedList()

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

Definition at line 108 of file omList.c.

110 {
111  while (list != NULL)
112  {
113  if (VALUE(list, long_field) >= what)
114  {
115  if (VALUE(list, long_field) == what) return list;
116  return NULL;
117  }
118  ITER(list);
119  }
120  return NULL;
121 }
#define VALUE(list, offset)
Definition: omList.c:14
#define NULL
Definition: omList.c:10
#define ITER(list)
Definition: omList.c:16

◆ _omInsertInSortedList()

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

Definition at line 146 of file omList.c.

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

◆ _omIsOnList()

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

Definition at line 64 of file omList.c.

65 {
66  if (addr == NULL)
67  return (NULL);
68 
69  while (list != NULL)
70  {
71  if (addr == list) return addr;
72  ITER(list);
73  }
74  return 0;
75 }
#define NULL
Definition: omList.c:10
#define ITER(list)
Definition: omList.c:16

◆ _omListHasCycle()

void* _omListHasCycle ( void *  list,
int  next 
)

Definition at line 40 of file omList.c.

41 {
42  void* l1 = list;
43  void* l2;
44 
45  int l = 0, i;
46 
47  while (l1 != NULL)
48  {
49  i = 0;
50  l2 = list;
51  while (l1 != l2)
52  {
53  i++;
54  ITER(l2);
55  }
56  if (i != l) return l1;
57  ITER(l1);
58  l++;
59  }
60  return NULL;
61 }
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
#define ITER(list)
Definition: omList.c:16
int l
Definition: cfEzgcd.cc:94

◆ _omListLast()

void* _omListLast ( void *  list,
int  next 
)

Definition at line 30 of file omList.c.

31 {
32  if (list == NULL) return NULL;
33 
34  while (NEXT(list) != NULL) ITER(list);
35 
36  return list;
37 }
#define NULL
Definition: omList.c:10
#define ITER(list)
Definition: omList.c:16
#define NEXT(list)
Definition: omList.c:15

◆ _omListLength()

int _omListLength ( void *  list,
int  next 
)

Definition at line 18 of file omList.c.

19 {
20  int l = 0;
21  while (list != NULL)
22  {
23  l++;
24  ITER(list);
25  }
26  return l;
27 }
#define NULL
Definition: omList.c:10
#define ITER(list)
Definition: omList.c:16
int l
Definition: cfEzgcd.cc:94

◆ _omRemoveFromList()

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

Definition at line 77 of file omList.c.

78 {
79  void* nlist;
80  void* olist;
81 
82  if (list == NULL) return NULL;
83 
84  nlist = NEXT(list);
85  if (list == addr) return nlist;
86 
87  olist = list;
88  while (nlist != NULL && nlist != addr)
89  {
90  list = nlist;
91  ITER(nlist);
92  }
93 
94  if (nlist != NULL) NEXT(list) = NEXT(nlist);
95  return olist;
96 }
#define NULL
Definition: omList.c:10
#define ITER(list)
Definition: omList.c:16
#define NEXT(list)
Definition: omList.c:15

◆ _omRemoveFromSortedList()

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

Definition at line 123 of file omList.c.

124 {
125  void* nlist;
126  void* olist;
127  unsigned long what = VALUE(addr, long_field);
128 
129  if (list == NULL) return NULL;
130  nlist = NEXT(list);
131  if (list == addr) return nlist;
132  if (VALUE(list, long_field) > what) return list;
133 
134  olist = list;
135  while (nlist != NULL && nlist != addr)
136  {
137  if (VALUE(list, long_field) > what) return olist;
138  list = nlist;
139  ITER(nlist);
140  }
141 
142  if (nlist != NULL) NEXT(list) = NEXT(nlist);
143  return olist;
144 }
#define VALUE(list, offset)
Definition: omList.c:14
#define NULL
Definition: omList.c:10
#define ITER(list)
Definition: omList.c:16
#define NEXT(list)
Definition: omList.c:15