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


Groups > comp.std.c > #1370

Re: Structure Packing.

Path csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail
From Walter Banks <walter@bytecraft.com>
Newsgroups comp.std.c
Subject Re: Structure Packing.
Date Tue, 12 Jun 2012 15:06:16 -0400
Organization Aioe.org NNTP Server
Lines 48
Message-ID <4FD79328.A040F7B8@bytecraft.com> (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> <a3p9irFkgbU1@mid.dfncis.de>
NNTP-Posting-Host pYfNRVqDKlDwIHKbefPq2Q.user.speranza.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=iso-8859-1
Content-Transfer-Encoding 8bit
X-Complaints-To abuse@aioe.org
X-Mailer Mozilla 4.79 [en]C-CCK-MCD NSCPCD479 (Windows NT 5.0; U)
X-Accept-Language en
X-Notice Filtered by postfilter v. 0.8.2
Xref csiph.com comp.std.c:1370

Show key headers only | View raw



Hans-Bernhard Bröker wrote:

> 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!

That isn't going to happen the  memcpy and memcmp related issues
would be a show stopper.

> > 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.

I  represented Canada at ISO working on C99 and am aware of the
wording and know the reasons. It is the reason I am so uncomfortable.

We have never done it and this is a case where a struct empty space
sometime exceeds the amount of ram space used. Arrays of structs
are a disaster in some cases.

Something that I just thought of that might work is to add an create an
information message as part of the listing summary that identifies teh
struct and a better data order declaration. The hardware in this case
is imposing the constraints.

The current implementation allocates next fit for each structure element.

As the day goes on I am getting convinced that it is a bad idea.

Walter Banks

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