Subject: Re: so what's happening...
To: Johnny Billquist <bqt@update.uu.se>
From: Olaf Seibert <rhialto@polderland.nl>
List: port-pdp10
Date: 07/05/2002 23:38:41
On Fri 05 Jul 2002 at 21:45:46 +0200, Johnny Billquist wrote:
> > Using byte addresses in vaddr_t will cause problems because
> > vaddr_t foo; struct bar *ka = (struct bar *)foo;
> > won't do any conversion and set ka to a funny pointer.
> 
> Hmmm. Reading my C ref manual (Harbison & Steele 2:nd ed) you could very
> well have special handling of conversions between different pointer types.

Yes - all pointers to structs must "smell the same" but need not be the
same as other pointers. (void *) must be essentially the same as (char
*), and be the "largest" pointer size since any object pointer must be
able to be converted to them - and back - and then still compare equal
to the original. Pointers to functions are different - there is no
requirement that you can convert between object pointers and function
pointers in any way, iirc. I presume one reason for this is to
accommodate things like Seperate I/D on the PDP-11. But it also allows
function pointers to be word pointers even if data pointers are byte
pointers.

> > Using word addresses in vaddr_t will cause other problems, it will then
> > get funny sizes in things like:
> > vaddr_t a, b, c; a = b + c + sizeof(struct foo);
> > (sizeof() gives number of bytes, vaddr_t's are in words).

> sizeof should return storage units. That *could* mean words on a PDP-10.
> If so, this would work just fine.

sizeof() works in units of char, which has CHAR_BITS bits. A char is by
definition the smallest addressable unit. So either all pointers are
word pointers, and a char is 36 bits, or pointers are based on chars of
9 bits (most likely) but then you have to be more careful about
conversions. I presume that the compiler will do that, and if an object
of size 4 is added to a word pointer, increase the pointer by 1 word.

But to make sure all this works ok, vaddr_t should probably be a (char
*), and not an integer type - or you'd have to do all this "by hand", if
that is even possible given the format of a byte pointer. It would
probably be nicer if a vaddr_t could be a word pointer but (without
knowing the details) I presume you cannot get away with it - since it
seems likely to me that there are places in the kernel where you want to
address units smaller than words in the kernel via vaddr_ts. Maybe if
such addresses are needed at most temporarily and need never be stored
in vaddr_ts, it could work with some extra conversions to char pointers
where needed...

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert - rhialto@       -- Woe betide the one who feels
\X/ polderland.nl  -- remorse without sin - Tom Poes, "Het boze oog", 4444.