lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [task #7213] Add a lwip_init function


From: Frédéric Bernon
Subject: [lwip-devel] [task #7213] Add a lwip_init function
Date: Wed, 15 Aug 2007 21:57:41 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6

URL:
  <http://savannah.nongnu.org/task/?7213>

                 Summary: Add a lwip_init function
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: fbernon
            Submitted on: mercredi 15.08.2007 à 23:57
                Category: None
         Should Start On: mercredi 15.08.2007 à 00:00
   Should be Finished on: mercredi 15.08.2007 à 00:00
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
        Percent Complete: 0%
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
                  Effort: 0.00

    _______________________________________________________

Details:

We have chat on the IRC channel about the fact to define a lwip_init function
to centralized some init, and add some sanity check at runtime ...

Since the task is a idea from "task #7142 : Sanity check user-configurable
values", I prefer to copy/paste the IRC log to provide the background of the
idea...

[17:26] <fbernon> I would like to add at the end of opt.h some of the checks
about "task #7142 : Sanity check user-configurable values" 
[17:26] <fbernon> Since they can avoid some questions
[17:27] <fbernon> is it ok for you ?
[17:36] <jifl> Sure, fire away
[17:37] <jifl> I'd probably put some demarcation and say "no user edittable
stuff below this line"
[17:37] <jifl> So users don't think it's stuff they need to change
[17:39] <fbernon> if they copy/paste opt.h to create their lwipopts.h ?
[17:44] <fbernon> or we could include a "optcheck.h" at the end of opt.h ?
[17:47] <jifl> if i were a user, i would copy/paste opt.h to make lwipopts.h.

[17:47] <jifl> (personally)
[17:47] <jifl> optcheck.h might be an idea. I'm fine with that.
[17:48] <fbernon> ok
[17:48] <fbernon> is there any standard preprocessor instruction, like
#error, but to only display a message ?
[17:49] <fbernon> which is C ANSI, of course...
[17:49] <jifl> no
[17:50] <jifl> I think #warning might be in C99
[17:50] <jifl> but not C90
[17:50] <jifl> so that would not be portable
[17:50] <jifl> for any warnings, I was going to check those at runtime
[17:50] <jifl> Put them in a #if LWIP_DEBUG block in sys_init() or something
like that
[17:51] <fbernon> If we had a lwip_init, it would be the good place
[17:51] <fbernon> Jared say me on MSN he join us in a moment...
[17:54] <fbernon> is there any standard define like "__cplusplus" to know if
the compiler is C99 compliant ?
[17:56] <jifl> Yes
[17:56] <jifl> I'll dig it up
[17:57] <jifl> __STDC_VERSION__
[17:58] <jifl> This will be 199901L for C99
[17:59] <fbernon> So, we can do "warning" check in a "#if __STDC_VERSION__ /
#endif" block ?
[17:59] <jifl> C90 doesn't define it
[18:00] <fbernon> ok, old compiler won't do these checks, but it's just a
"helper" after all...
[18:01] <jifl> I'm not sure that would work. I think the preprocessor still
expects to be able to parse lines beginning with '#'
[18:01] <jifl> Or at least, not work portably
[18:01] <jifl> I still think it's better to check for things to warn about at
runtime in one of the init functions
[18:03] <fbernon> problem: if you don't activate LWIP_DEBUG, you don't have
these check
[18:03] <jifl> That's true.
[18:05] <jifl> I was going to suggest that LWIP_DEBUG be on by default. But I
see something more odd - LWIP_DEBUG isn't in opt.h at all.
[18:05] <fbernon> yes
[18:06] <fbernon> most of time, it is checked by #ifdef and not #if 
[18:06] <fbernon> same for LWIP_NOASSERT
[18:06] <jifl> It should probably be in opt.h, so people know it exists to
change in lwipopt.h
[18:06] <jifl> lwipopts.h
[18:06] <fbernon> I don't  find that very nice
[18:07] <jifl> Even if commented out
[18:07] <fbernon> replace in debug.h the #ifdef LWIP_DEBUG... by a #if
LWIP_DEBUG will be better
[18:08] <fbernon> but it's another port-breakage
[18:08] <jifl> I agree. Although 1.3.0 is about port breakage :-)
[18:09] <fbernon> yes
[18:09] <fbernon> before change that, I will post the change on task #7142

[18:21] <fbernon> we are talking about put LWIp_DEBUG and LWIP_NOASSERT in
opt.h, with a change in debug.h
[18:21] <fbernon> but it cause another port-breakage
[18:22] <fbernon> this idea is to get LWIP_DEBUG per default, and to do all
sanity check at runtime in sys_init (or any other)
[18:23] <jaredgrubb> ok
[18:23] <fbernon> I talk about task #7142
[18:23] <jaredgrubb> i havent used the debug in lwip at all... so i may not
be much help there
[18:23] <jifl> it doesn't make much difference if everything works :-)
[18:24] <fbernon> and of course, all works fine at the first try with lwIP
;)
[18:24] <jifl> All the individual modules to be debugged have their debug
output set at LWIP_DBG_OFF
[18:24] <jifl> (by default)
[18:25] <fbernon> yes, but even like this, you add the code of the LWIP_DEBUG
macro
[18:25] <jifl> Sort of - for a disabled module, the macro would become
something like:
[18:26] <jifl> do { if ((((0) & 0x80U) && ......
[18:26] <fbernon> the code won't do anything, since you got a if (0), but,
except some good compiler/linker, the code is here
[18:26] <jifl> any optimising compiler will get rid of that
[18:27] <fbernon> I'm agree
[18:28] <fbernon> so, ok to use LWIP_DEBUG. Now, where? sys_init is not the
best place if NO_SYS=1
[18:29] <jifl> mem_init is used everywhere, and would be near the start of
init sequence
[18:30] <jifl> (like you I would prefer a big lwip_init function, but I think
that might be hard to sort out now for 1.3)
[18:30] <fbernon> yes, which not
[18:31] <fbernon> in fact, for tcpip.c users, I think that tcpip_init should
do most of init calls
[18:32] <fbernon> if it don't help all the users, it help lot of sequential
users
[18:32] <fbernon> and if one day, we add a lwip_init, we could place this
call in tcpip_init
[18:34] <jifl> sure
[18:36] <fbernon> finally, since 1.3.0 do lot of "port-breakage", adding a
lwip.c could be finally be a good solution?
[18:36] <jifl> I think so. I guess Kieran gets to decide.

[18:50] <fbernon> so, saying that, if Kieran is ok, we could add a lwip.c
file, in this file, got a  lwip_init function, where we can do with some
LWIP_DEBUG (enabled per default) all the sanity checkings, and where we can
call all "_init" functions for mem, memp, netif, etc.. ?
[18:53] <jifl> i'd love that

[18:55] <fbernon> since there is no standard #warning, we can't only use the
preprocessor
[18:56] <fbernon>      #if LWIP_STATS
[18:56] <fbernon>      stats_init      ();
[18:56] <fbernon>      #endif /* STATS */
[18:56] <fbernon>      #if (NO_SYS == 0)
[18:56] <fbernon>      sys_init        ();
[18:56] <fbernon>      #endif /* (NO_SYS == 0) */
[18:56] <fbernon>      mem_init        ();
[18:56] <fbernon>      memp_init       ();
[18:56] <fbernon>      pbuf_init       ();
[18:56] <fbernon>      etharp_init     ();
[18:56] <fbernon>      netif_init      ();
[18:56] <fbernon>      lwip_socket_init();     
[18:56] <fbernon> this is what I mainly used
[18:57] <jifl> Not everyone would want etharp_init
[18:57] <fbernon> "socket_init" and even "etharp_init" should be include with
a #if LWIP_SOCKET & #if LWIP_ARP
[18:57] <jifl> There would need to be some test for that
[18:58] <jifl> ok then
[18:58] <jaredgrubb> i have to run to a meeting... but that looks good. def
makes init easier.
[18:58] <fbernon> LWIP_SOCKET is not yet defined, but there is lot of case
where it could help^
[19:01] <jifl> Yes I agree - I think there were some things in
api_lib.c/api_msg.c that can only ever be used by the sockets API
[19:01] <fbernon> yes





    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/task/?7213>

_______________________________________________
  Message posté via/par Savannah
  http://savannah.nongnu.org/





reply via email to

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