Randolph Fritz wrote:
> >
> > But you're right. Even if most compilers allow it, by the books
> > it's not legal to do pointer arithmetic with void pointers.
>
> Not exactly...it's "undefined".
That's the same thing for most pratical purposes.
No, some environments (like gcc) define it. The problem is that it
only works in some environments and it cannot be counted on to work in
the same way in environments where it does work. "void *" does work
with gcc, whereas I'm not sure a "char *" version always will.
> That code is intended to improve virtual memory
> performance; such code is, unfortunately, system-dependent and belongs
> in the non-existant bottle we need to keep system-dependent stuff.
I can't find anything system-dependent in that code, other
than it may help more on some platforms than on others.
You have not had a youth wasted programming in too many weird
assembler languages! (At least, I hope not.) The "void *" version
only works if "void *" is the address of a byte in a contiguous
address space. That's actually not the case in some addressing models
on x86 machines, which is why the compiler rejects it. The "char *"
version depends on BYTES_WORD being correct. On, for instance, 64-bit
systems where "double" refers to a 128-bit quantity, it will allocate
a minimum of 16 bytes, rather than 8--a performance bug. More
seriously, one might encounter systems where the alignment requirement
is "long double" rather than "double", and future code which attempted
to cast the result of bmalloc() to "long double" would fail.
For the moment, I think, it is probably best to choose the type of
bposition with conditional compilation (wince), but I think in the
long run it's best to address the problem in a more general fashion; I
cannot enough stress how unreliable conditional compilation makes
cross-platform code.
Randolph, wishing he had more time to spend on Radiance
···
On Sun, Oct 03, 2004 at 08:12:56PM -0400, Georg Mischler wrote: