linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Mariano Moreyra" <moremari@aca.org.ar>
To: 'Massimiliano Cialdi' <cialdi@firenze.net>,
	'linux-c-programming' <linux-c-programming@vger.kernel.org>
Cc: 'wwp' <subscript@free.fr>
Subject: RE: bitfield array
Date: Mon, 12 Jan 2004 10:40:23 -0300	[thread overview]
Message-ID: <000001c3d911$a179eea0$0c81640a@aca.org.ar> (raw)
In-Reply-To: <20040112115643.0000382e.cialdi@firenze.net>

Maybe you should use a 2-byte variable, and access each bit with a mask.
In this case, if you only need 10 one bit flags, there will be 6 unused
bits, but you may use those bits with future flags...
Anyway...you will be using only 2 bytes...and not 10 bytes... you still gain
some memory.


-----Mensaje original-----
De: linux-c-programming-owner@vger.kernel.org
[mailto:linux-c-programming-owner@vger.kernel.org]En nombre de
Massimiliano Cialdi
Enviado el: Lunes, 12 de Enero de 2004 07:57
Para: linux-c-programming
CC: wwp
Asunto: Re: bitfield array


On Mon, 12 Jan 2004 11:29:26 +0100
wwp <subscript@free.fr> wrote:

> AFAIK, bitfields are stored in memory block which can only be
> allocated with 1-byte minimum.. Try to allocate 1 bit in memory,
> sounds not possible :-).
I know but I don't want to allocate a single bit. Since I need an array
of binary flag, I thought that the compiler could help me. 10 bits could
be placed in 2 bytes. Else I need 10 bytes (80% of space lost).

> IOW, if you use a 1-bit bitfield, it will still be require an amount
> of memory counted in bytes. That's partly why bitfields are not so
> used for optimization, 'cause following the compiler you don't gaim
> memory space not cpu time.
I work with a (very) limited memory embedded system. I need to save
memory, no matter in cpu time.

thanks

--
Massimiliano Cialdi
cialdi@firenze.net
m.cialdi@oksys.it
-
To unsubscribe from this list: send the line "unsubscribe
linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  reply	other threads:[~2004-01-12 13:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-12 10:10 bitfield array Massimiliano Cialdi
2004-01-12 10:29 ` wwp
2004-01-12 10:56   ` Massimiliano Cialdi
2004-01-12 13:40     ` Mariano Moreyra [this message]
2004-01-13  1:02     ` James Stevenson
2004-01-12 21:06 ` Glynn Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000001c3d911$a179eea0$0c81640a@aca.org.ar' \
    --to=moremari@aca.org.ar \
    --cc=cialdi@firenze.net \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=mariano_moreyra@aca.org.ar \
    --cc=subscript@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).