Subject: process list within p_emuldata
To: None <tech-kern@netbsd.org>
From: Emmanuel Dreyfus <manu@netbsd.org>
List: tech-kern
Date: 07/04/2002 23:33:13
While it's more a C language question than a kernel question, I don't see a
better place for this question.

In order to emulate IRIX share groups, I'd like to maintain an emulation
specific process list:

struct irix_emuldata {
        LIST_ENTRY(proc) ied_list;
}

For an IRIX process, p->p_emuldata points to a struct irix_emuldata. Hence I
can reach the list link like this:

(struct irix_emuldata *)(p->p_emuldata)->ied_list

Now I want ot use LIST_FOREACH on this...

struct proc *pp;
LIST_HEAD(isg_head, proc) isg_head; 
LIST_FOREACH(pp, &isg_head, p_emuldata->ied_list)

This won't work because I am dereferencing a (void *) pointer. 

Things like this won't work either:
LIST_FOREACH(pp, &isg_head, (struct irix_emuldata *)p_emuldata->ied_list)
The macro expands into 
 pp = (pp->((struct irix_emuldata *)p_emuldata)->ie_list.le_next))
and I just get a "parse error before `('"

Now the questions: how should I do it? Is there a mysterious C syntax to get
the work done? If not, should I define custom list operation macros? Or should
I do a struct irix_emuldata list, with a pointer to struct proc in struct
irix_emuldata so that I can get the struct proc?

-- 
Emmanuel Dreyfus
manu@netbsd.org