lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-devel] PPP LCP Phases Not Enum in 2.0.0 Beta


From: Sylvain Rochet
Subject: Re: [lwip-devel] PPP LCP Phases Not Enum in 2.0.0 Beta
Date: Tue, 2 Aug 2016 00:57:19 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

Hi,

On Tue, Aug 02, 2016 at 12:40:47AM +0200, Sylvain Rochet wrote:
> On Tue, Aug 02, 2016 at 12:22:11AM +0200, Sylvain Rochet wrote:
> > On Mon, Aug 01, 2016 at 09:50:30PM +0000, Greg Smith wrote:
> > > Hello.
> > > 
> > > In Lwip 1.4.1, the PPP LCP states (phases) were all defined as an enum 
> > > (typedef LinkPhase).  This made seeing the state in a debugger really 
> > > nice -- it would show "PHASE_DEAD", for example. In 2.0.0 Beta1, they 
> > > have been converted to #define macros.  Now the debugger only shows a 
> > > number (0, for example), which isn't as convenient.
> > > 
> > > So:
> > > 
> > > 1) I'd like to understand why this change was made.
> > 
> > In C, an enum type is always an int, which is a 4-byte value on 32-bit 
> > systems (also 4-byte on LP64, LLP64, and 8-byte on ILP64, but we are a 
> > bit outside lwIP targets here). So this is to save 3 (or 7) bytes of RAM 
> > per state value, and it matters.
> 
> To add a little bit information here, you made me curious about this 
> subject, so, I now know about gcc -fshort-enums dangerous compilation 
> option, enum __attribute__ ((__packed__)) foo, and the ":0; enum bar;
> :0;" hack in struct (at least on > C90 because <= C90 only allows int 
> types for bitfields).
> 
> None of them sound very appealing for me, and most of them don't even 
> work, at least on gcc which I tried :-)

I obviously forgot one test, the following enum type declaration works 
with gcc:

enum totopacked {
        TOTO_ = 0,
        TITI_
} __attribute__ ((__packed__));

I'm not sure this is widely supported though... even with #pragma for 
pragma-based compilers (erk!) in the same way we are doing for struct. 
The benefit is close to zero in my opinion so that's probably not even 
worth trying.


Sylvain

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]