Subject: Re: xosview and machine/cpu.h problems
To: Brian C. Grayson <bgrayson@ece.utexas.edu>
From: Bill Studenmund <wrstuden@loki.stanford.edu>
List: port-mac68k
Date: 12/30/1997 10:58:14
>   I received notice recently (PR#4731, by Steve Allen) that
> xosview-1.5.1 will not compile on macs, due to want_resched and
> astpending being multiply defined.  After a bit of digging,
> it appears that including /usr/include/sys/sysctl.h in a C file
> will pull in /usr/include/machine/pmap.h, which on mac68k pulls
> in /usr/include/machine/cpu.h, which contains the following:
> 
> int     astpending;     /* need to trap before returning to user mode */
> int     want_resched;   /* resched() was called */
> 
>   Two different files (memmeter.cc and pagemeter.cc) in the
> xosview-1.5.1 NetBSD tree pull in /usr/include/sys/sysctl.h, so
> at link time, the linker sees multiple astpendings and want_rescheds.

Are you sure the error's "multiply defined variables?" I ask as
a lot of files in the kernel include machine/cpu.h, and they
don't get errors.

It's my understanding that such a reference in a file just adds a
reference to the variable, and saying something like astpending=1; in
the body of the code would actually allocate the storage. So I
think the messages should be "<symbol> referenced from text" or 
something like that.

>   I have no idea what I'm talking about, but should those be
> declared differently?  Under i386 and alpha, the declarations of
> want_resched etc. are protected by #ifdef _KERNEL (in a
> roundabout way under i386).  Should the mac version have similar
> protections?  What about the other ports?  (I didn't check all of
> them.)

Probably. The program doesn't actually use these variables, does
it?

Take care,

Bill