iOS porting Issues

Aug 14, 2010 at 4:53 AM

Hi everyone,

I'm working on porting pstsdk to iOS and am having structure alignment/padding issues that seem to be different than what was found during the Mac port.  I'm looking for assistance on the right way to fix some of these in disk.h.  It almost looks like the ms_struct attribute isn't helping me all that much on this platform.  Can anyone give me some guidance on the first couple to get me going? 

A couple of examples:

Windows:  

bbt_leaf_entry<ulong> => Size = 12, size at offset 8, ref_count at offset 10

bbt_leaf_entry<ulonglong>  => Size = 24, size at offset 16, ref_count at offset 18

sub_leaf_entry<ulong> =>   Size = 12, data at offset 4, sub at offset 8

sub_leaf_entry<ulonglong> =>   Size = 24, data at offset 8, sub at offset 16

iOS:

bbt_leaf_entry<ulong> => Size = 12, size at offset 8, ref_count at offset 10

  bbt_leaf_entry<ulonglong>   => Size = 20, size at offset 16, ref_count at offset 18  (Four extra bytes at the end of the struct)

sub_leaf_entry<ulong>  =>   Size = 12, data at offset 4, sub at offset 8

sub_leaf_entry<ulonglong> =>   Size = 20, data at offset 4, sub at offset 12  (data did NOT get padded like it did on Windows)

 

Thanks in advance for your assistance. 

 

Thanks,

Mike

Coordinator
Aug 14, 2010 at 8:46 AM
Edited Aug 15, 2010 at 12:28 AM

If anyone ever wonders again why it's a bad idea to have structs defined to match on disk layouts and just blast bits between disk and memory should look at this project. It has it's advantages (namely, it's the simplest solution to implement and understand, and it's what most people want) but it simply doesn't scale. I'd do things differently if I had to do it again.

I'm a little surprised that you're having alignment issues on iOS, I would have figured GCC alignment there would be identical to OSX. Hmph.

I'll have to think about a long term solution. In the meantime if I were you I'd probably patch up things with #ifdef IOS specific padding members, or try to figure out the magic incantation to get their version of the compiler to layout structs the same as on OSX (which others have spent time getting to align the same as windows).

Also, if you do run into any runtime issues that you can trace back to layout differences let me know - I want the set of static_asserts to be broad enough that once you can get it to compile on another platform, everything works.