Padding issues between Sparc and Intel


 
Thread Tools Search this Thread
Top Forums Programming Padding issues between Sparc and Intel
# 8  
Old 08-01-2011
Padding issues between Sparc and Intel

Hi all,

Thank you all for posting. I have dealt with all endianess issues successfully. The thing is that part of code with the nested structs is quite old so writing it is probably the best thing to do. I will re-arrange the structure so that the largest elements are first, as achenle suggests and if this does not work I will try to break the struct to seperate parts
# 9  
Old 08-02-2011
Also, whatever compiler you're using, look at "#pragma align ...." and "#pragma pack ...", as they're both very useful here.

And watch your compilation options, especially those regarding optimizations. One common optimization is placing fields on the "best" alignment, which could easily be different on different hardware. In particular, the Sun/Oracle Studio compiler suite has the "-fast" optimization option, and that implicitly changes data structure alignment and packing.

The quickest way to check if you have a problem is simply to check the size of the structure using sizeof(). If you get different results on SPARC than you do on x86, obviously the structures aren't aligned the same. If you arrange the elements largest-to-smallest and get the same sizes, you almost certainly have an identical layout on both.
# 10  
Old 09-05-2011
Thanks achenle.

I solved my problem in 2 different ways: (1) by inserting, for the INTEL architecture, some extra 32-bit padding members in my struct and (2) by re-aligining my struct members from largest (64-bit) to smallest (8-bit).

I observed that only SPARC performed padding. It was interesting to see that INTEL did not perform any padding at all... This is why I inserted the extra padding in the INTEL struct!
# 11  
Old 09-05-2011
Sorry, but you are still missing the point. You cannot safely pass structures between disparate platforms. You may get away with it on occasion between two particular platforms with two particular compilers but the way you intend doing it is not portable and will come back to bite you.

As other have suggested, check out serialization/deserialization and marshalling/unmarshalling techniques.
# 12  
Old 09-05-2011
Quote:
Originally Posted by fpmurphy
Sorry, but you are still missing the point. You cannot safely pass structures between disparate platforms. You may get away with it on occasion between two particular platforms with two particular compilers but the way you intend doing it is not portable and will come back to bite you.

As other have suggested, check out serialization/deserialization and marshalling/unmarshalling techniques.
You sure can - if you know what you're doing.

Else things wouldn't work - say, like the ENTIRE internet.

What's a TCP packet? A structure. Passed between multiple types of platforms. From the bulk of the available evidence, quite successfully, too.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Solaris

Running Solaris SPARC on Intel Hardware????

Hello friends, I hope everyone is fine and doing well. I want to learn Assembly language for SPARC architecture. Is there any emulator available for 64 bit SPARC on which one can install Oracle Solaris 11 SPARC version. And ofcourse on my intel laptop computer??? Thanks! (4 Replies)
Discussion started by: gabam
4 Replies

2. Ubuntu

Sudo issues with Ubuntu 7.10 Running on a Ultra SPARC Machine

I have a Sun Blade 1000 machine that I installed Ubuntu 7.10 SPARC onto. The only user configured (configure during install) cannot use sudo. When I try to issue a command using sudo (ex. sudo apt-get install) it asks me for my password and returns the error "user not found in sudoers file". I need... (4 Replies)
Discussion started by: swilso
4 Replies

3. UNIX for Dummies Questions & Answers

can I emulate solaris/sparc on virtualbox? Or other emulator to run solaris for sparc in my win7 PC?

Hi Gurus can I emulate solaris/sparc on virtualbox? Or other emulator to run solaris for sparc in my win7 PC? regards, Israel. (9 Replies)
Discussion started by: iga3725
9 Replies

4. Shell Programming and Scripting

fixed length text file padding issues in AIX

Hi, I have a fixed length text file that needs to be cut into individual files in aix and facing padding issues. If I have multiple blank spaces in the file it is just making it one while cutting the files.. Eg:- $ - blank space filename:file.txt ... (2 Replies)
Discussion started by: techmoris
2 Replies

5. UNIX for Dummies Questions & Answers

Zero padding dates

I have a file with records containing dates like: SMPBR|DUP-DO NOT USE|NEW YORK||16105|BA5270715|2007-6-6|MWERNER|109||||JOHN||SMITH|MD|72211118||||||74559|21 WILMINGTON RD||D|2003-11-6|SL# MD CONTACT-LIZ RICHARDS|||0|Y|N||1411458| How can I get the date fields in each of my records to be... (1 Reply)
Discussion started by: ChicagoBlues
1 Replies

6. UNIX for Dummies Questions & Answers

Padding

Hi Can anyone tell me how to pad zeroes on the left side to a numeric string in unix shell scripting Your answer is very much appreciated Thanks Vijay (2 Replies)
Discussion started by: vijaygopalsk
2 Replies

7. UNIX for Advanced & Expert Users

Padding issues

Hello, Structure padding & structure size are different on Compaq & HP UNIX. When structures are transfered via netfork from Compaq to HP will this be a problem? If yes, what can be the solution? Thanks, shilpa (2 Replies)
Discussion started by: informshilpa
2 Replies

8. UNIX for Dummies Questions & Answers

Sparc vs Intel performance

Hello all, I have been trying to find any data that states what platform would garner better overall performance in an Oracle Cluster. The scenario: This is a high traffic e-commerce site with IIS and Commerce server on the front end. The backend consists of a Sun Solaris hardware/software... (7 Replies)
Discussion started by: kmgrady01
7 Replies
Login or Register to Ask a Question