blob: 09f358fd618b6f8db1c6d5d6e51fb954102c2d09 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#pragma once
#include <stdlib.h>
#define OFFSET(type, attr) ((size_t) &((type *)0)->attr)
#define UPCAST(ptr, type) ({ \
const typeof( ((type *)0)->link ) *__mptr = (ptr); \
(type *)( (char *)__mptr - OFFSET(type, link) ); })
#define LIST_HEAD ((struct link) { .prev = NULL, .next = NULL })
struct link {
struct link *prev, *next;
};
int list_len(struct link *list);
struct link* list_back(struct link *list);
void link_push_back(struct link *list, struct link *link);
void link_prepend(struct link *list, struct link *link);
void link_append(struct link *list, struct link *link);
void link_pop(struct link *link);
|