Did the test and compiled the attached programs to assembly without any
optimization flags.
The result was as you said, the code for accessing the bit field was so huge
that it wasn't worth it. The programs used equal CPU time though.
With the -Os flag, the code generated for the bit field varian
I usually use bitfields when there are a lot of items (for example
st glyph could be a good case for them). In other cases you waste
more memory with the access code that the space you save compacting
the bits in the struct.
> I should check generated code, but usually a mov is faster than mov+a
I should check generated code, but usually a mov is faster than mov+and+mov for
setting a bit.
On Jul 14, 2013, at 23:22, Markus Teich wrote:
> Since this is just uncommon syntax (at least I haven't seen it before) and it
> is just used in the declaration I would be ok with it, if an additiona
Since this is just uncommon syntax (at least I haven't seen it before)
and it is just used in the declaration I would be ok with it, if an
additional comment explains it. It's not a strong opinion though, just
an idea.
--Markus
Am 2013-07-14 21:32, schrieb Anselm R Garbe:
On 7 July 2013 16:
On 7 July 2013 16:49, koneu wrote:
> In Xdefs.h, Bool is typedef'd as int (= at least 2 bytes, sometimes more,
> depending on the implementation), of which we set the last bit to 1 or 0.
> In the Monitor and Client structures dwm uses, we can instead use char bit
> fields, storing up to 8 Bool v
On Mon, Jul 08, 2013 at 09:47:10AM +0200, Kurt Van Dijck wrote:
> Hello,
>
> I just remembered this thing from an embedded 16bit CPU.
>
> Why would you do
> unsigned char XXX :1
> and not
> unsigned int XXX :1
>
> I think the latter may benefit code size (a tiny bit)
> because it av
Hello,
I just remembered this thing from an embedded 16bit CPU.
Why would you do
unsigned char XXX :1
and not
unsigned int XXX :1
I think the latter may benefit code size (a tiny bit)
because it avoids an integer promotion, at least on some platforms.
Kind regards,
Kurt
On Sun,
this will be useful for running dwm on my pdp-11.
On Sun, Jul 7, 2013 at 10:49 AM, koneu wrote:
> In Xdefs.h, Bool is typedef'd as int (= at least 2 bytes, sometimes more,
> depending on the implementation), of which we set the last bit to 1 or 0.
> In the Monitor and Client structures dwm uses,
In Xdefs.h, Bool is typedef'd as int (= at least 2 bytes, sometimes more,
depending on the implementation), of which we set the last bit to 1 or 0.
In the Monitor and Client structures dwm uses, we can instead use char bit
fields, storing up to 8 Bool values in 1 byte.
diff --git a/dwm.c b/dwm.c