13 #define OUT(fmt, ...) do { \
14 fprintf(stdout, "%s: " fmt, __func__, ## __VA_ARGS__); \
19 const char *vals[] = {
20 "zero",
"one",
"two",
"three",
"four",
"five",
"six",
21 "seven",
"eight",
"nine",
"ten",
"eleven",
"twelve"
25 OUT(
"list_add_tail: ");
27 struct item *e = malloc(
sizeof(
struct item));
30 fprintf(stdout,
"%s ", vals[i]);
32 fprintf(stdout,
"\n");
52 OUT(
"removing 'twelve' and 'zero'\n");
68 OUT(
"moving 'one' to the tail\n");
76 OUT(
"list_for_each_entry: ");
80 fprintf(stdout,
"\n");
82 OUT(
"list_for_each_entry_reverse: ");
86 fprintf(stdout,
"\n");
88 OUT(
"delete all entries\n");
93 OUT(
"list_empty: %s\n",
list_empty(&test_list) ?
"yes" :
"no");
103 OUT(
"delete all entries\n");
109 OUT(
"list_empty: %s\n",
list_empty(&test_list) ?
"yes" :
"no");
#define list_for_each_entry_reverse(p, h, field)
static void list_move_tail(struct list_head *entry, struct list_head *head)
#define LIST_HEAD_INIT(name)
static bool list_is_first(const struct list_head *list, const struct list_head *head)
static void list_add_tail(struct list_head *_new, struct list_head *head)
#define list_for_each_entry_safe(p, n, h, field)
#define list_for_each_entry(p, h, field)
static bool list_empty(const struct list_head *head)
static void list_del(struct list_head *entry)
static bool list_is_last(const struct list_head *list, const struct list_head *head)
#define list_first_entry(ptr, type, field)
#define list_last_entry(ptr, type, field)
static void test_while_list_empty()
static void init_list(struct list_head *list)
static void test_basics()