Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c > #1369

Re: Structure Packing.

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail
From Hans-Bernhard Bröker <HBBroeker@t-online.de>
Newsgroups comp.std.c
Subject Re: Structure Packing.
Date Tue, 12 Jun 2012 18:37:49 +0200
Lines 25
Message-ID <a3p9irFkgbU1@mid.dfncis.de> (permalink)
References <12b3df42-f6a0-4411-a5e5-136900f8255b@googlegroups.com> <jqovin$9sr$1@dont-email.me> <4FD6ABFA.72F52C75@bytecraft.com> <jr7fpp$eti$1@dont-email.me> <4FD7659E.89172310@bytecraft.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.dfncis.de jhnXyTHBiwjTNj+ne4MhlgxrQU9ej8zdhq5EkFymtJEjjqLyfKrrBuAAkim+HE7f8AtIopmg9Y
Cancel-Lock sha1:7HNp93XyHEL70UQFMajnh49Hjo4=
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120420 Thunderbird/12.0
In-Reply-To <4FD7659E.89172310@bytecraft.com>
Xref csiph.com comp.std.c:1369

Show key headers only | View raw


On 12.06.2012 17:51, Walter Banks wrote:

> I have resolved every issue in this specific processor except memcpy
> and memcmp both of which are rarely used in embedded systems.

I rather doubt the correctness of that assessment.  And even if it were 
correct, "rarely used" would not help you --- you would need "never 
used".  For tricks like the one you're considering to be viable, you 
would have to intercept not just every call of memcpy(), but worse, 
every single one of the roll-your-own implementations of it hidden 
somewhere in the code --- including those that aren't even written in C 
to begin with.  Danger, Will Robinson!

Sticking unrelated statics into the padding gaps might be viable for 
struct constants kept in ROM, but there's really no reliable way that 
can work in struct variables.

> I am uncomfortable even with packing the struct elements out of
> order.

You should be more than uncomfortable --- that's actually disallowed by 
the standard.  To quote C99 6.7.2.1#16:

> Within a structure object, the non-bit-field members and the units in which bit-fields
> reside have addresses that increase in the order in which they are declared.

Back to comp.std.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Structure Packing. John Kearney <dethrophes@googlemail.com> - 2012-06-06 17:27 -0700
  Re: Structure Packing. James Kuyper <jameskuyper@verizon.net> - 2012-06-06 21:19 -0400
    Re: Structure Packing. Walter Banks <walter@bytecraft.com> - 2012-06-11 22:39 -0400
      Re: Structure Packing. Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-12 09:21 -0400
        Re: Structure Packing. Walter Banks <walter@bytecraft.com> - 2012-06-12 11:51 -0400
          Re: Structure Packing. Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2012-06-12 18:37 +0200
            Re: Structure Packing. Walter Banks <walter@bytecraft.com> - 2012-06-12 15:06 -0400
              Re: Structure Packing. Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-12 16:22 -0400
                Re: Structure Packing. Walter Banks <walter@bytecraft.com> - 2012-06-12 17:44 -0400
                Re: Structure Packing. Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2012-06-13 15:53 +0200
                Re: Structure Packing. Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-06-18 12:37 +0300
        Re: Structure Packing. Martin Shobe <martin.shobe@yahoo.com> - 2012-06-12 16:22 +0000
          Re: Structure Packing. Walter Banks <walter@bytecraft.com> - 2012-06-12 15:24 -0400
            Re: Structure Packing. Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-12 16:33 -0400
              Re: Structure Packing. Walter Banks <walter@bytecraft.com> - 2012-06-12 17:17 -0400
  Re: Structure Packing. Keith Thompson <kst-u@mib.org> - 2012-06-06 18:35 -0700
    Re: Structure Packing. John Kearney <dethrophes@googlemail.com> - 2012-06-06 21:58 -0700
      Re: Structure Packing. Keith Thompson <kst-u@mib.org> - 2012-06-06 23:54 -0700
        Re: Structure Packing. John Kearney <dethrophes@googlemail.com> - 2012-06-07 07:47 -0700
          Re: Structure Packing. James Kuyper <jameskuyper@verizon.net> - 2012-06-07 12:39 -0400
    Re: Structure Packing. jacob navia <jacob@spamsink.net> - 2012-06-07 11:14 +0200
      Re: Structure Packing. Keith Thompson <kst-u@mib.org> - 2012-06-07 09:46 -0700
        Re: Structure Packing. John Kearney <dethrophes@googlemail.com> - 2012-06-07 11:57 -0700

csiph-web