[BusyBox] Re: [BusyBox-cvs] svn commit: trunk/busybox: include networking

Tito farmatito at tiscali.it
Wed Jul 27 16:04:17 UTC 2005


On Wednesday 27 July 2005 13:48, Rob Landley wrote:
> On Wednesday 27 July 2005 06:19, Rob Landley wrote:
> 
> > Lemme think about this.  Possibly we could #define a CONF_THING to be 0 or
> > 1 and leave the CONFIG_THING to be #ifdef or #ifndef.  (That's a little
> > more subtle than I'm quite comfortable with, but I could live with it and I
> > can't think of a better prefix off the top of my head.  The makefile magic
> > is still fairly simple, especially if we have bb_config.h #include
> > config.h...)
> >
> > Suggestions?
> >
> > Rob
> 
> The prefix "ENABLED_" wouldn't be a bad replacement for "CONFIG_" (less subtle 
> for something with different semantics).  The CONFIG_ version would be 
> #ifdef/#ifndef, and the ENABLED_ version of the same symbol would be 0 or 1.
> 
> This way, we don't have to worry about stupid compilers allocating space for 
> constants.
> 
> Comments?
> 
> Rob
> 
Lets go with one of the simplest solutions:

1) Let everything be as it was before. ( My preferred one)

2) Or use something like this:
/* in config.h */
#define CONFIG_FEATURE_CLEAN_UP

/* in busybox.h */
#ifdef CONFIG_FEATURE_CLEAN_UP
#define  CONFIG_FEATURE_CLEAN_UP_FREE(x)            free(x)
#define  CONFIG_FEATURE_CLEAN_UP_CLOSE(x)         close(x)
#define  CONFIG_FEATURE_CLEAN_UP_FCLOSE(x)        fclose(x)
#else
#define CONFIG_FEATURE_CLEAN_UP_FREE(x)
#define CONFIG_FEATURE_CLEAN_UP_CLOSE(x)
#define CONFIG_FEATURE_CLEAN_UP_FCLOSE(x)
#endif

or like Erik's proposal:

#ifdef CONFIG_FEATURE_CLEAN_UP
    static inline void clean_up_free(void *foo) { free(foo); }
#else
    static inline void clean_up_free(void *foo) { }
#endif

as this takes care of most of the  CONFIG_FEATURE_CLEAN_UP  #ifdefs' which are one liners
calling free, close or fclose and let us use #ifdefs directly in the code for complex
multiline blocks, so there wouldn't be an increase in size. 
 As the risk is to create something like

#ifdef CONFIG_FEATURE_BUFFERS_GO_ON_STACK
#define RESERVE_CONFIG_BUFFER(buffer,len)           char buffer[len]
#define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char buffer[len]
#define RELEASE_CONFIG_BUFFER(buffer)      ((void)0)
#else
#ifdef CONFIG_FEATURE_BUFFERS_GO_IN_BSS
#define RESERVE_CONFIG_BUFFER(buffer,len)  static          char buffer[len]
#define RESERVE_CONFIG_UBUFFER(buffer,len) static unsigned char buffer[len]
#define RELEASE_CONFIG_BUFFER(buffer)      ((void)0)
#else
#define RESERVE_CONFIG_BUFFER(buffer,len)           char *buffer=xmalloc(len)
#define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
#define RELEASE_CONFIG_BUFFER(buffer)      free (buffer)
#endif
#endif

that nobody likes to use.

Just my humble opinion.

Ciao,
Tito.



More information about the busybox mailing list