www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/28/12:38:27

From: Thomas Demmer <demmer AT LSTM DOT Ruhr-UNI-Bochum DOT De>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Optimization
Date: Thu, 28 Nov 1996 14:59:04 +0100
Organization: Lehrstuhl fuer Stroemungsmechanik
Lines: 41
Message-ID: <329D9AA8.167E@LSTM.Ruhr-UNI-Bochum.De>
References: <Pine DOT SUN DOT 3 DOT 90 DOT 961127125213 DOT 12832A-100000 AT coop10> <19961128 DOT 160329 DOT 4455 DOT 4 DOT chambersb AT juno DOT com>
NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Benjamin D Chambers wrote:
[...]
> ***** Warning, though, if you get a 32-bit DWord aligned wrong, you COULD
> actually end up with code that's less than half the speed it should be.
> I *believe* (I'm not sure) the way to make sure it's aligned properly is
> to use
> _PACKED_.
> ^^^^^^^^ Somebody check me here.  I could be wrong...
... and you are.
__PACKED__ and #pragma packed
allow to override the builtin alignment mechanism. E.g. if you have
struct
{  char foo;
   int  bar;
}
a dummy will be inserted to keep bar DWORD aligned. So the
size of this struct will be 8.
OTH if you have
#pragma packed
struct
{  char foo;
   int  bar;
}
the size of the struct will be 5, with the penalty of bar
no longer aligned to a DWORD boundary. 

-- 
Ciao
Tom

*************************************************************
* Thomas Demmer                                             *
* Lehrstuhl fuer Stroemungsmechanik                         *
* Ruhr-Uni-Bochum                                           *
* Universitaetsstr. 150                                     *
* D-44780  Bochum                                           *
* Tel: +49 234 700 6434                                     *
* Fax: +49 234 709 4162                                     *
* Voice/Fax Box: +49 2561 91371 2056                        *
* http://www.lstm.ruhr-uni-bochum.de/~demmer                *
*************************************************************

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019