I just add code in list.h:
Quote:
#define LIST_POISON1 ((void *) 0x00100100)
#define LIST_POISON2 ((void *) 0x00200200)
#define prefectch(x) 1
#define smp_wmb(x) 1
#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE*)0)->MEMBER)
#define container_of(ptr, type, member)({ \
const typeof(((type*) 0)->member)*__mptr=(ptr); \
(type*)((char*)__mpt-offsetof(type, member));})
|
my test code is
Quote:
struct kool_list{
int to;
struct list_head list;
};
int print_string_init(void)
{
char ret[256];
struct kool_list *tmp;
struct list_head *pos, *q;
unsigned int i;
unsigned int j = 10;
struct kool_list mylist;
INIT_LIST_HEAD(&mylist.list);
for(i = 5; i!=0; --i){
tmp = (struct kool_list *)malloc(sizeof(struct kool_list));
tmp->to = j;
list_add(&(tmp->list), &(mylist.list));
j--;
}
printf("traversing the list using list_for_each().");
list_for_each(pos, &mylist.list){
tmp = list_entry(pos, struct kool_list, list);
sprintf(ret, "to = %d", tmp->to);
printf(ret);
}
|
I get compiler error message in line
tmp = list_entry(pos, (struct kool_list), list);
syntex error: '{'
syntex error: ')'
syntex error: ')'
syntex error: missing ':' before ')'
syntex error: missing ')' before string
'__mpt': undeclared identifier
..........