[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [DotGNU]stdio in pnetC ... some questions
From: |
Gopal V |
Subject: |
Re: [DotGNU]stdio in pnetC ... some questions |
Date: |
Mon, 26 Aug 2002 06:38:36 +0530 |
User-agent: |
Mutt/1.2.5i |
If memory serves me right, Rhys Weatherley wrote:
> > BEBAFECA
>
> You'll only get that on a little-endian machine. Big-endian
> will give you CAFEBABE. PDP-endian will give you BABECAFE.
> So, your code isn't portable at the momemt.
I didn't say I used that ... :-) ... I read bytes in order and
convert them (knowing that .class files are always Big Endian)
a = (fgetc(fp)<< 8) | fgetc(fp) ; is the way it is implemented
in jilc (and jdasm).
What I was talking about is the behaviour of compiled programs
of pnetC .. for example I compile jilc with pnetC on a little-endian
machine , and I copy the .exe to a big-endian machine ... For gcc it
is not much of an issue .. as binaries for one machine do not run easily
on others.
I write a program that freads int32's on Computer-1, I move the
data file and the .exe file to Computer-2 ... It is obvious that
the program may or may not behave properly on C2 due to endianess
issues .. User on C2 may not have the source code , but only
binaries (which in pnet's case run equally easily on C1 and C2) .
Other issue while freading are the byte padding in structs (to align
ints to word boundary).. etc .. On my box it behaves exactly like
gcc , but I really don't know how it might on a machine without
alignment.. (seems to be hardcoded as .size 8)
struct
{
char c;
int x;
}B;
so sizeof(B) will be 8
I find no solution but to ignore these issues , but making them
"known" (pun intended) issues might solve the problem :)
Gopal
PS: if you write portable code , ignore this mail :-)
--
The difference between insanity and genius is measured by success