Subject: kqemu: QUEUE(9) question
To: None <tech-kern@netbsd.org>
From: Oliver Gould <ogould@olix0r.net>
List: tech-kern
Date: 04/19/2007 14:31:45
--sdtB3X0nJg68CQEu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hello-

On 2007-04-16 20:27 -0500, Oliver Gould wrote:
> I'm trying to wrap up my work on KQEMU.
> ...

I now have a question regarding QUEUE(9).

I wrote a prototypical LKM that behaves like the KQEMU LKM should (sans
everything QEMU, though).  In this prototype, I mimick bpf(4)'s use of
LIST_* to store instances.

  /usr/src/sys/net/bpf.c:122:LIST_HEAD(, bpf_d) bpf_list;
  /usr/src/sys/net/bpf.c:374:     LIST_INIT(&bpf_list);
  /usr/src/sys/net/bpf.c:405:     LIST_INSERT_HEAD(&bpf_list, d, bd_list);
  /usr/src/sys/net/bpf.c:436:     LIST_REMOVE(d, bd_list);
  /usr/src/sys/net/bpf.c:1572:    for (d = LIST_FIRST(&bpf_list); d != NULL; d = LIST_NEXT(d, bd_list)) {
  /usr/src/sys/net/bpf.c:1739:    LIST_FOREACH(dp, &bpf_list, bd_list) {
  /usr/src/sys/net/bpfdesc.h:94:  LIST_ENTRY(bpf_d) bd_list;      /* list of all BPF's */

  src/lkm_zed/lkm_zed.c:65:       LIST_ENTRY(zed_instance) *zi_list;
  src/lkm_zed/lkm_zed.c:67:static LIST_HEAD(,zed_instance) zed_inlist;
  src/lkm_zed/lkm_zed.c:90:       LIST_INIT(&zed_inlist);
  src/lkm_zed/lkm_zed.c:109:      zs= LIST_FIRST(&zed_inlist);
  src/lkm_zed/lkm_zed.c:112:              zs= LIST_NEXT(zs, zi_list);
  src/lkm_zed/lkm_zed.c:154:      LIST_INSERT_HEAD(&zed_inlist, zs, zi_list);
  src/lkm_zed/lkm_zed.c:228:      LIST_REMOVE(zs, zi_list);

'zed_instance' is a structure defined with a LIST_ENTRY member in the
same way that 'bpf_d' is declared.

I can, of course, provide more context for this, but my point is to
show that (I believe) I am doing the same thing- at least as far as the
compiler should be concerned- that bpf(4) does.

I, however, get the following compile errors:

  #   compile  lkm_zed/lkm_zed.o
  cc -O2 -ffreestanding  -fno-strict-aliasing -Wno-pointer-sign  -Werror
  -nostdinc -I. -I/home/ver/src/lkm_zed -isystem /usr/src/sys -isystem
  /usr/src/sys/arch -isystem /usr/src/sys/../common/include -D_KERNEL
  -D_LKM  -c    lkm_zed.c
  lkm_zed.c: In function 'zed_lkmunload':
  lkm_zed.c:112: error: request for member 'le_next' in something not a
  structure or union
  lkm_zed.c: In function 'zed_cdev_open':
  lkm_zed.c:154: error: request for member 'le_next' in something not a
  structure or union
  lkm_zed.c:154: error: request for member 'le_prev' in something not a
  structure or union
  lkm_zed.c:154: error: request for member 'le_next' in something not a
  structure or union
  lkm_zed.c:154: error: request for member 'le_prev' in something not a
  structure or union
  lkm_zed.c: In function 'zed_destroy':
  [... same errors; different line numbers ...]
  *** Error code 1

Does anyone have a guess at what I'm doing wrong?

Thanks,
 - Oliver

--sdtB3X0nJg68CQEu
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (NetBSD)

iQEVAwUBRie1kfBcMTqzwkq9AQKFvQf9EjUgnMPjwPVtXrbznlhDMosVJtyP+Ot5
YBBTL+/fYPq6Q7nhFcDuWdnCb+SYGRF9r0DnJkNetHliQxULlz+qLV+f3QOMUXtG
RhsCQU61v/oZlbWtezEGIjGBZRkDNhptKZd1moJ+eg8AGAQw/sl+78HG0RcfPJP2
37XCax5fZZpxUJAUG8jrRWHNBnMmXypN2oMlDvN5d5eRpGKvcFyqCAFdu41oyksf
cT0HJXqVUMXBT28TxJpcX4U35DIjpKKyAi2zhlkSobxuA8RKZB+YEamhiKvD6cRl
1Zr6ZYdaZUTOlB1mE5V25iXEvFxORJaHJ4cDkgQ3PnBWVlh9dTpdBg==
=8QEZ
-----END PGP SIGNATURE-----

--sdtB3X0nJg68CQEu--