Add UC_TAILQ_CONTAINER. Fix spelling error

This commit is contained in:
Nils O. Selåsdal
2013-11-30 03:24:43 +01:00
parent f9ef8d620f
commit ad90215452
+12 -4
View File
@@ -2,8 +2,7 @@
#define UC_TAILQ_H_ #define UC_TAILQ_H_
#ifdef __GNUC__ #ifdef __GNUC__
//#define UC_INLINE __attribute__((always_inline,flatten)) #define UC_INLINE inline __attribute__((always_inline,flatten))
#define UC_INLINE inline
#else #else
#define UC_INLINE inline #define UC_INLINE inline
#endif #endif
@@ -43,6 +42,15 @@ struct TailQ {
#define UC_TAILQ_HEAD(name)\ #define UC_TAILQ_HEAD(name)\
struct TailQ name = UC_TAILQ_HEAD_INIT(name) struct TailQ name = UC_TAILQ_HEAD_INIT(name)
//given 'ptr' as a pointer to a struct 'member',
//find the struct that ptr is the member of, where
//'type' is the type of the containing struct
//This is basically UC_CONTAINER_OF in ucore/utils.h, this is here
//to make tailq.h a standalone header
#define UC_TAILQ_CONTAINER(ptr, type, member) ({\
typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)((void *)(unsigned char *)__mptr - offsetof(type, member) ); })
static UC_INLINE void uc_tailq_init(struct TailQ *head) static UC_INLINE void uc_tailq_init(struct TailQ *head)
{ {
@@ -112,7 +120,7 @@ static UC_INLINE void uc_tailq_remove(struct TailQ *entry)
static UC_INLINE void uc_tailq_move_head(struct TailQ *entry, struct TailQ *head) static UC_INLINE void uc_tailq_move_head(struct TailQ *entry, struct TailQ *head)
{ {
uc_tailq_link(entry->prev, entry->next); uc_tailq_link(entry->prev, entry->next);
uc_taiq_insert(entry, head, head->next); uc_tailq_insert(entry, head, head->next);
} }
/** Move entry from its current tailq to the tail of another tailq. /** Move entry from its current tailq to the tail of another tailq.
@@ -121,7 +129,7 @@ static UC_INLINE void uc_tailq_move_head(struct TailQ *entry, struct TailQ *head
static UC_INLINE void uc_tailq_move_tail(struct TailQ *entry, struct TailQ *head) static UC_INLINE void uc_tailq_move_tail(struct TailQ *entry, struct TailQ *head)
{ {
uc_tailq_link(entry->prev, entry->next); uc_tailq_link(entry->prev, entry->next);
uc_taiq_insert(entry, head->prev, head); uc_tailq_insert(entry, head->prev, head);
} }
//FIRST/NEXT/LAST/PREV macros similar to sys/queue.h //FIRST/NEXT/LAST/PREV macros similar to sys/queue.h