Move the internal types toye the internal namespace
This commit is contained in:
1 parent
e4955e6851
commit
df79c306d9
1 file changed
+31
-31
+31
-31
@@ -39,7 +39,7 @@
|
|||||||
} tmp_str_t;
|
} tmp_str_t;
|
||||||
*/
|
*/
|
||||||
#define ILIST_INTERFACE(name, type) \
|
#define ILIST_INTERFACE(name, type) \
|
||||||
struct m_ilist_head_s name
|
struct m_il1st_head_s name
|
||||||
|
|
||||||
|
|
||||||
/* Define a doubly-linked intrusive list of a given type.
|
/* Define a doubly-linked intrusive list of a given type.
|
||||||
@@ -75,10 +75,10 @@
|
|||||||
/********************************** INTERNAL ************************************/
|
/********************************** INTERNAL ************************************/
|
||||||
|
|
||||||
/* Define the basic structure to be added in all objects. */
|
/* Define the basic structure to be added in all objects. */
|
||||||
typedef struct m_ilist_head_s {
|
typedef struct m_il1st_head_s {
|
||||||
struct m_ilist_head_s *next;
|
struct m_il1st_head_s *next;
|
||||||
struct m_ilist_head_s *prev;
|
struct m_il1st_head_s *prev;
|
||||||
} m_ilist_head_ct;
|
} m_il1st_head_ct;
|
||||||
|
|
||||||
/* Indirection call to allow expanding all arguments */
|
/* Indirection call to allow expanding all arguments */
|
||||||
#define M_IL1ST_OPLIST_P1(arg) M_IL1ST_OPLIST_P2 arg
|
#define M_IL1ST_OPLIST_P1(arg) M_IL1ST_OPLIST_P2 arg
|
||||||
@@ -164,7 +164,7 @@ typedef struct m_ilist_head_s {
|
|||||||
/* Define the list as a structure containing pointers \
|
/* Define the list as a structure containing pointers \
|
||||||
* to the front & back nodes */ \
|
* to the front & back nodes */ \
|
||||||
typedef struct M_C(name, _s) { \
|
typedef struct M_C(name, _s) { \
|
||||||
struct m_ilist_head_s name; \
|
struct m_il1st_head_s name; \
|
||||||
} list_t[1]; \
|
} list_t[1]; \
|
||||||
\
|
\
|
||||||
/* Define internal types pointers to such a list */ \
|
/* Define internal types pointers to such a list */ \
|
||||||
@@ -173,10 +173,10 @@ typedef struct m_ilist_head_s {
|
|||||||
\
|
\
|
||||||
/* Define iterator of such a list */ \
|
/* Define iterator of such a list */ \
|
||||||
typedef struct M_C(name, _it_s) { \
|
typedef struct M_C(name, _it_s) { \
|
||||||
struct m_ilist_head_s *head; \
|
struct m_il1st_head_s *head; \
|
||||||
struct m_ilist_head_s *previous; \
|
struct m_il1st_head_s *previous; \
|
||||||
struct m_ilist_head_s *current; \
|
struct m_il1st_head_s *current; \
|
||||||
struct m_ilist_head_s *next; \
|
struct m_il1st_head_s *next; \
|
||||||
} it_t[1]; \
|
} it_t[1]; \
|
||||||
\
|
\
|
||||||
/* Define types used by oplist */ \
|
/* Define types used by oplist */ \
|
||||||
@@ -199,11 +199,11 @@ typedef struct m_ilist_head_s {
|
|||||||
M_C(name, _reset)(list_t list) \
|
M_C(name, _reset)(list_t list) \
|
||||||
{ \
|
{ \
|
||||||
M_IL1ST_CONTRACT(name, list); \
|
M_IL1ST_CONTRACT(name, list); \
|
||||||
for(struct m_ilist_head_s *it = list->name.next, *next ; \
|
for(struct m_il1st_head_s *it = list->name.next, *next ; \
|
||||||
it != &list->name; it = next) { \
|
it != &list->name; it = next) { \
|
||||||
/* Cannot check node contract as previous node may be deleted */ \
|
/* Cannot check node contract as previous node may be deleted */ \
|
||||||
type *obj = M_TYPE_FROM_FIELD(type, it, \
|
type *obj = M_TYPE_FROM_FIELD(type, it, \
|
||||||
struct m_ilist_head_s, name); \
|
struct m_il1st_head_s, name); \
|
||||||
/* Read next now before the object is destroyed */ \
|
/* Read next now before the object is destroyed */ \
|
||||||
next = it->next; \
|
next = it->next; \
|
||||||
M_ASSERT (next != NULL); \
|
M_ASSERT (next != NULL); \
|
||||||
@@ -265,7 +265,7 @@ typedef struct m_ilist_head_s {
|
|||||||
M_IL1ST_CONTRACT(name, list); \
|
M_IL1ST_CONTRACT(name, list); \
|
||||||
size_t s = 0; \
|
size_t s = 0; \
|
||||||
/* Scan the full list to count the number of elements */ \
|
/* Scan the full list to count the number of elements */ \
|
||||||
for(const struct m_ilist_head_s *it = list->name.next ; \
|
for(const struct m_il1st_head_s *it = list->name.next ; \
|
||||||
it != &list->name; it = it->next) { \
|
it != &list->name; it = it->next) { \
|
||||||
M_IL1ST_NODE_CONTRACT(it); \
|
M_IL1ST_NODE_CONTRACT(it); \
|
||||||
s++; \
|
s++; \
|
||||||
@@ -278,7 +278,7 @@ typedef struct m_ilist_head_s {
|
|||||||
{ \
|
{ \
|
||||||
M_IL1ST_CONTRACT(name, list); \
|
M_IL1ST_CONTRACT(name, list); \
|
||||||
M_ASSERT (obj != NULL); \
|
M_ASSERT (obj != NULL); \
|
||||||
struct m_ilist_head_s *prev = list->name.prev; \
|
struct m_il1st_head_s *prev = list->name.prev; \
|
||||||
list->name.prev = &obj->name; \
|
list->name.prev = &obj->name; \
|
||||||
obj->name.prev = prev; \
|
obj->name.prev = prev; \
|
||||||
obj->name.next = &list->name; \
|
obj->name.next = &list->name; \
|
||||||
@@ -291,7 +291,7 @@ typedef struct m_ilist_head_s {
|
|||||||
{ \
|
{ \
|
||||||
M_IL1ST_CONTRACT(name, list); \
|
M_IL1ST_CONTRACT(name, list); \
|
||||||
M_ASSERT (obj != NULL); \
|
M_ASSERT (obj != NULL); \
|
||||||
struct m_ilist_head_s *next = list->name.next; \
|
struct m_il1st_head_s *next = list->name.next; \
|
||||||
list->name.next = &obj->name; \
|
list->name.next = &obj->name; \
|
||||||
obj->name.next = next; \
|
obj->name.next = next; \
|
||||||
obj->name.prev = &list->name; \
|
obj->name.prev = &list->name; \
|
||||||
@@ -305,7 +305,7 @@ typedef struct m_ilist_head_s {
|
|||||||
M_ASSERT (obj_pos != NULL && obj != NULL); \
|
M_ASSERT (obj_pos != NULL && obj != NULL); \
|
||||||
/* We don't have the list, so we have no contract at list level */ \
|
/* We don't have the list, so we have no contract at list level */ \
|
||||||
M_IL1ST_NODE_CONTRACT(&obj_pos->name); \
|
M_IL1ST_NODE_CONTRACT(&obj_pos->name); \
|
||||||
struct m_ilist_head_s *next = obj_pos->name.next; \
|
struct m_il1st_head_s *next = obj_pos->name.next; \
|
||||||
obj_pos->name.next = &obj->name; \
|
obj_pos->name.next = &obj->name; \
|
||||||
obj->name.next = next; \
|
obj->name.next = next; \
|
||||||
obj->name.prev = &obj_pos->name; \
|
obj->name.prev = &obj_pos->name; \
|
||||||
@@ -327,8 +327,8 @@ typedef struct m_ilist_head_s {
|
|||||||
M_ASSERT (obj != NULL); \
|
M_ASSERT (obj != NULL); \
|
||||||
/* We don't have the list, so we have no contract at list level */ \
|
/* We don't have the list, so we have no contract at list level */ \
|
||||||
M_IL1ST_NODE_CONTRACT(&obj->name); \
|
M_IL1ST_NODE_CONTRACT(&obj->name); \
|
||||||
struct m_ilist_head_s *next = obj->name.next; \
|
struct m_il1st_head_s *next = obj->name.next; \
|
||||||
struct m_ilist_head_s *prev = obj->name.prev; \
|
struct m_il1st_head_s *prev = obj->name.prev; \
|
||||||
next->prev = prev; \
|
next->prev = prev; \
|
||||||
prev->next = next; \
|
prev->next = next; \
|
||||||
/* Note: not really needed, but safer */ \
|
/* Note: not really needed, but safer */ \
|
||||||
@@ -342,7 +342,7 @@ typedef struct m_ilist_head_s {
|
|||||||
M_IL1ST_CONTRACT(name, list); \
|
M_IL1ST_CONTRACT(name, list); \
|
||||||
M_ASSERT(!M_C(name, _empty_p)(list)); \
|
M_ASSERT(!M_C(name, _empty_p)(list)); \
|
||||||
return M_TYPE_FROM_FIELD(type, list->name.prev, \
|
return M_TYPE_FROM_FIELD(type, list->name.prev, \
|
||||||
struct m_ilist_head_s, name); \
|
struct m_il1st_head_s, name); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static inline type * \
|
static inline type * \
|
||||||
@@ -351,7 +351,7 @@ typedef struct m_ilist_head_s {
|
|||||||
M_IL1ST_CONTRACT(name, list); \
|
M_IL1ST_CONTRACT(name, list); \
|
||||||
M_ASSERT(!M_C(name, _empty_p)(list)); \
|
M_ASSERT(!M_C(name, _empty_p)(list)); \
|
||||||
return M_TYPE_FROM_FIELD(type, list->name.next, \
|
return M_TYPE_FROM_FIELD(type, list->name.next, \
|
||||||
struct m_ilist_head_s, name); \
|
struct m_il1st_head_s, name); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static inline type * \
|
static inline type * \
|
||||||
@@ -362,7 +362,7 @@ typedef struct m_ilist_head_s {
|
|||||||
M_IL1ST_NODE_CONTRACT(&obj->name); \
|
M_IL1ST_NODE_CONTRACT(&obj->name); \
|
||||||
return obj->name.next == &list->name ? NULL : \
|
return obj->name.next == &list->name ? NULL : \
|
||||||
M_TYPE_FROM_FIELD(type, obj->name.next, \
|
M_TYPE_FROM_FIELD(type, obj->name.next, \
|
||||||
struct m_ilist_head_s, name); \
|
struct m_il1st_head_s, name); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static inline type * \
|
static inline type * \
|
||||||
@@ -373,7 +373,7 @@ typedef struct m_ilist_head_s {
|
|||||||
M_IL1ST_NODE_CONTRACT(&obj->name); \
|
M_IL1ST_NODE_CONTRACT(&obj->name); \
|
||||||
return obj->name.prev == &list->name ? NULL : \
|
return obj->name.prev == &list->name ? NULL : \
|
||||||
M_TYPE_FROM_FIELD(type, obj->name.prev, \
|
M_TYPE_FROM_FIELD(type, obj->name.prev, \
|
||||||
struct m_ilist_head_s, name); \
|
struct m_il1st_head_s, name); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static inline void \
|
static inline void \
|
||||||
@@ -486,7 +486,7 @@ typedef struct m_ilist_head_s {
|
|||||||
M_ASSERT (it->current->prev == it->previous); \
|
M_ASSERT (it->current->prev == it->previous); \
|
||||||
M_ASSERT (!M_C(name, _end_p)(it)); \
|
M_ASSERT (!M_C(name, _end_p)(it)); \
|
||||||
return M_TYPE_FROM_FIELD(type, it->current, \
|
return M_TYPE_FROM_FIELD(type, it->current, \
|
||||||
struct m_ilist_head_s, name); \
|
struct m_il1st_head_s, name); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static inline type const * \
|
static inline type const * \
|
||||||
@@ -503,7 +503,7 @@ typedef struct m_ilist_head_s {
|
|||||||
M_IL1ST_NODE_CONTRACT(it->current); \
|
M_IL1ST_NODE_CONTRACT(it->current); \
|
||||||
(void)list; /* list param is not used */ \
|
(void)list; /* list param is not used */ \
|
||||||
type *obj = M_TYPE_FROM_FIELD(type, it->current, \
|
type *obj = M_TYPE_FROM_FIELD(type, it->current, \
|
||||||
struct m_ilist_head_s, name); \
|
struct m_il1st_head_s, name); \
|
||||||
M_C(name, _unlink)(obj); \
|
M_C(name, _unlink)(obj); \
|
||||||
M_CALL_CLEAR(oplist, obj); \
|
M_CALL_CLEAR(oplist, obj); \
|
||||||
M_IF_METHOD(DEL, oplist)(M_CALL_DEL(oplist, obj), (void) 0); \
|
M_IF_METHOD(DEL, oplist)(M_CALL_DEL(oplist, obj), (void) 0); \
|
||||||
@@ -557,8 +557,8 @@ typedef struct m_ilist_head_s {
|
|||||||
{ \
|
{ \
|
||||||
M_IL1ST_CONTRACT(name, list1); \
|
M_IL1ST_CONTRACT(name, list1); \
|
||||||
M_IL1ST_CONTRACT(name, list2); \
|
M_IL1ST_CONTRACT(name, list2); \
|
||||||
struct m_ilist_head_s *midle1 = list1->name.prev; \
|
struct m_il1st_head_s *midle1 = list1->name.prev; \
|
||||||
struct m_ilist_head_s *midle2 = list2->name.next; \
|
struct m_il1st_head_s *midle2 = list2->name.next; \
|
||||||
midle1->next = midle2; \
|
midle1->next = midle2; \
|
||||||
midle2->prev = midle1; \
|
midle2->prev = midle1; \
|
||||||
list1->name.prev = list2->name.prev; \
|
list1->name.prev = list2->name.prev; \
|
||||||
@@ -596,11 +596,11 @@ typedef struct m_ilist_head_s {
|
|||||||
/* npos may be end */ \
|
/* npos may be end */ \
|
||||||
(void) olist, (void) nlist; \
|
(void) olist, (void) nlist; \
|
||||||
type *obj = M_C(name, _ref)(opos); \
|
type *obj = M_C(name, _ref)(opos); \
|
||||||
struct m_ilist_head_s *ref = npos->current; \
|
struct m_il1st_head_s *ref = npos->current; \
|
||||||
/* Remove object */ \
|
/* Remove object */ \
|
||||||
M_C(name, _unlink)(obj); \
|
M_C(name, _unlink)(obj); \
|
||||||
/* Push 'obj' after 'ref' */ \
|
/* Push 'obj' after 'ref' */ \
|
||||||
struct m_ilist_head_s *next = ref->next; \
|
struct m_il1st_head_s *next = ref->next; \
|
||||||
ref->next = &obj->name; \
|
ref->next = &obj->name; \
|
||||||
obj->name.next = next; \
|
obj->name.next = next; \
|
||||||
obj->name.prev = ref; \
|
obj->name.prev = ref; \
|
||||||
@@ -620,8 +620,8 @@ typedef struct m_ilist_head_s {
|
|||||||
{ \
|
{ \
|
||||||
M_IL1ST_CONTRACT(name, d); \
|
M_IL1ST_CONTRACT(name, d); \
|
||||||
M_IL1ST_CONTRACT(name, e); \
|
M_IL1ST_CONTRACT(name, e); \
|
||||||
struct m_ilist_head_s *d_item = d->name.next; \
|
struct m_il1st_head_s *d_item = d->name.next; \
|
||||||
struct m_ilist_head_s *e_item = e->name.next; \
|
struct m_il1st_head_s *e_item = e->name.next; \
|
||||||
/* it is more complicated than other swap functions since \
|
/* it is more complicated than other swap functions since \
|
||||||
we need to detect "cyclic" loop */ \
|
we need to detect "cyclic" loop */ \
|
||||||
d->name.next = e_item == &e->name ? &d->name : e_item; \
|
d->name.next = e_item == &e->name ? &d->name : e_item; \
|
||||||
@@ -642,7 +642,7 @@ typedef struct m_ilist_head_s {
|
|||||||
M_C(name, _reverse)(list_t list) \
|
M_C(name, _reverse)(list_t list) \
|
||||||
{ \
|
{ \
|
||||||
M_IL1ST_CONTRACT(name, list); \
|
M_IL1ST_CONTRACT(name, list); \
|
||||||
struct m_ilist_head_s *next, *it; \
|
struct m_il1st_head_s *next, *it; \
|
||||||
for(it = list->name.next ; it != &list->name; it = next) { \
|
for(it = list->name.next ; it != &list->name; it = next) { \
|
||||||
next = it->next; \
|
next = it->next; \
|
||||||
it->next = it->prev; \
|
it->next = it->prev; \
|
||||||
|
|||||||
Reference in new issue
Block a user