On Aug 21, 2013, at 11:57 AM, erik quanstrom <[email protected]> wrote:
>> You're casting a large int into a small int and this seems right.
>> Just as (uchar)0x1234 => 0x34
>>
>>> marshalling a 64-bit pointer in this way will lay down the
>>> bytes with the hi and lo reversed.
>>
>> Perhaps you meant to do *(uchar*)&x?
Incidentally, on a little endian machine you'd still get
0xef out of 0x0123456789abcdefull!
>
> you're right. what was i thinking. still, pointers are marshaled wrong.
> compiled on mips, this program
>
> #include <u.h>
> #include <libc.h>
>
> void
> main(void)
> {
> char *p;
>
> p = malloc(100);
> print("%p\n", p);
> }
> does this
> ; 6.crash
> 6.crash 203443: suicide: sys: trap: #SS pc=0x2048f2
How %p is treated is really upto the implementation but
it should not crash since p is never dereferenced. Does
this work?
uintptr q;
print("%p", q);