[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Byte alignment



Helt korrekt, men... et er plads noget andet er hastighed. 

Nu uden at have testet/målt dette, så antager jeg #1) er hurtigere en #2), 
og være målelig, ganske enkelt forbi den skal bruge færeste load fra 
memory. 

OK i små test kommer alt formodeltlig fra 1. level cache.

Hvis koden afvikles på en maskine med 32bit bus vil fetch af UInt32 fra 
memory vil i tilfælde #2) kræve 2 load og i tilfælde #1) 1 load.


#1)

typedef struct
{
     UInt32 file_size;
     UInt32 reserved;
     UInt32 data_offset;
     UInt8 signature[2];
 } Header;

#2)

typedef struct
{
  UInt8 signature[2];
  UInt32 file_size;
  UInt32 reserved;
  UInt32 data_offset;
} __attribute__ ((packed)) Header;



Thorbjoern Ravn Andersen wrote:

> "Lars H." <sslug@sslug> writes:
> 
>> Kender ingen compiler eller precompiler der kan lave denne ombytning. Men
>> har heller ikke checket op de seneste versioner.
> 
> gcc kan lidt af hvert.  Bortset fra det, saa vil den aligne uden
> hensyn til plads paa de platforme hvor dette gavner.



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *