on 32 bit box, a void* has 3 values which are illegal/unaligned;
void* ptr;
if (ptr & 0x00) {
/* ok */
} else {
/* some exceptional situation */
}
is there any concievable use of this which doesnt interfere with
legitimate bus-errors (ie existing unaligned pointer handling) ?
struct bigstruct* bp; could have many more 'reserved' misaligments
You're looking to encode data in the low X bits (where X is 2 or 4
for 32 or 64 bit machines), right? It's a clever thing to do, but one
I admit I mistrust. Either it means we have to check every pointer
that might be encoded before we use it or wedge into the system
SIGBUS handler, which is non-trivial in many places. It's also rather
a portability problem. (And potential security problem, alas)
A cool idea, but I don't think we can do it.
--
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk
> pardon the lack of clue I reveal here, but..
>
> on 32 bit box, a void* has 3 values which are illegal/unaligned;
>
> void* ptr;
> if (ptr & 0x00) {
ITYM if(!(ptr & 0x3))
> /* ok */
> } else {
> /* some exceptional situation */
> }
> is there any concievable use of this which doesnt interfere with
> legitimate bus-errors (ie existing unaligned pointer handling) ?
IMHO it's a little dodgy, besides, someone's eventually going to find a
system (toaster?) that doesn't care about alignment or aligns such that
ptr % 4 == 3 or something.
Dave
Isa. 40:31
> At 7:35 AM -0500 12/31/02, Jim Cromie wrote:
>
>> pardon the lack of clue I reveal here, but..
>>
>>
>> on 32 bit box, a void* has 3 values which are illegal/unaligned;
>>
>> void* ptr;
>> if (ptr & 0x00) {
>> /* ok */
>> } else {
>> /* some exceptional situation */
>> }
>>
>> is there any concievable use of this which doesnt interfere with
>> legitimate bus-errors (ie existing unaligned pointer handling) ?
>
>
> You're looking to encode data in the low X bits (where X is 2 or 4 for
> 32 or 64 bit machines), right?
yes- precisely!
> It's a clever thing to do, but one I admit I mistrust. Either it means
> we have to check every pointer that might be encoded before we use it
> or wedge into the system SIGBUS handler, which is non-trivial in many
> places. It's also rather a portability problem. (And potential
> security problem, alas)
>
> A cool idea, but I don't think we can do it.
thats what I thought - but had to ask on the off-chance it could benefit.
IIRC - I saw it once as a feature of some old Motorola ?? DMA controller
- I think it was used to signal some scatter/gather ops
Lisp systems have done this on and off for decades. (Emacs did it for
ages with the high bits, which is why there was a 4M buffer size
limit for so long) It works best if you have control over the
hardware, because then you could rope in MMU and page fault support
to do Interesting Things.
Believe me, I'd be *thrilled* to be able to leverage this for GC
purposes, amongst other things. It's really platform-dependent,
though, and requires kernel level access to leverage. (So it's really
sensitive to dodgy code, too) Unfortunately rules it out for us.