tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: in which we present an ugly hack to make sys/queue.h CIRCLEQ work



>Modulo some administrative details, it's just "no object in memory may
>be accessed using more than one type".

Ok ... I _think_ I see it.  But doesn't that mean that like 90% of the casts
used by C programmers are totally wrong? :-)

> > but doesn't that depend on how you use it?
>
>Not in this case; the problem is that the cast to struct headname
>causes it to read tqh_last from an item in memory that might be a
>queue head but is probably actually a queue element.

Alright, I think I understand.  If tqe_prev pointed to a queue entry
that would be the problem, because that memory already has a TAILQ_ENTRY
type.

So ... looking at this code ... it seems like the core problem is that
TAILQ_HEAD and TAILQ_ENTRY are two different types (even though they
literally the same structure layout).  So if TAILQ_HEAD and TAILQ_ENTRY
were the same structure, it wouldn't be an issue.  It doesn't quite leap
out to me how that would be possible without changing the API a bit.

--Ken


Home | Main Index | Thread Index | Old Index