Re: porting solaris/SPARC app to Solaris/x86 questions
From: Shea Martin (smartin_at_arcis.com)
Date: 12/13/04
- Next message: dragoncoder: "Re: Socket Server... Why two?"
- Previous message: Shea Martin: "Re: porting solaris/SPARC app to Solaris/x86 questions"
- In reply to: Jens.Toerring_at_physik.fu-berlin.de: "Re: porting solaris/SPARC app to Solaris/x86 questions"
- Next in thread: joe durusau: "Re: porting solaris/SPARC app to Solaris/x86 questions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 13 Dec 2004 15:55:42 -0700
Jens.Toerring@physik.fu-berlin.de wrote:
> Shea Martin <smartin@arcis.com> wrote:
>
>> As you have guessed, there are 5+
>>years of files written out in "carefree mode". Adapting code
>>specifically for the x86 version is the route we will have to go. How
>>do I know how a struct is padded etc? Do i have to reverse engineer it;
>>frwrite a struct, then hex-dump the file to see how it is actually padded?
>
>
> The simplest way is probably writing a short program where you define
> a structure like the one in the real program and than calculate the
> offsets of the members, e.g. something like
>
> struct s_t {
> int x;
> int y;
> float z;
> float a;
> int b;
> u_longlong_t address;
> } s;
>
> printf( "total length of structure: %lu\n", ( unsigned long ) sizeof s );
> printf( "offset of y: %lu\n", ( unsigned long ) offsetof( struct s_t, y ) );
> printf( "offset of z: %lu\n", ( unsigned long ) offsetof( struct s_t, z ) );
>
> You can then use the offsets on the new machine in order to extract
> the fields from the raw data you have read into a buffer (you don't
> need that for the first element since it is guaranteed to be exactly
> at the start of the structure). What I would be worried about a bit
> more is if the representation of floats on both architectures is
> the same. And I hope you're not really storing addresses in the
> structure as the name of the last member might indicate...
>
> Regards, Jens
Thanks,
I was unfamiliar with the offsetof macro. This looks exactly like what
I must do.
As for the address, you are correct, it is storing an fseek number, the
header acts as an index for the LARGE binary file. But it is only
needed when randomly accessing the file, it is not used for sequential
access, so we should be alright.
Thanks,
~S
- Next message: dragoncoder: "Re: Socket Server... Why two?"
- Previous message: Shea Martin: "Re: porting solaris/SPARC app to Solaris/x86 questions"
- In reply to: Jens.Toerring_at_physik.fu-berlin.de: "Re: porting solaris/SPARC app to Solaris/x86 questions"
- Next in thread: joe durusau: "Re: porting solaris/SPARC app to Solaris/x86 questions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|