[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-ha-dev
Subject: Re: [Linux-ha-dev] libltdl changes question
From: Alan Robertson <alanr () unix ! sh>
Date: 2001-05-22 19:46:18
[Download RAW message or body]
Michael Moerz wrote:
>
> On Sun, May 20, 2001 at 10:36:38PM -0600, Alan Robertson wrote:
> > Michael Moerz wrote:
> > >
> [snip]
> >
> > These aren't real wonderful. They're way too long and not very
> > self-explanatory... They also hide the C syntax in a way that isn't helpful
> > - it's just obfuscantion.
> >
> O.k. I will not do it like that.
>
> > Why would you make it named hb_comm_module.h and not just hb_module.h? I
> > don't think these two files have to be different.
> >
> If we do it like you are suggesting, we definitly do not need further
> module headers.
>
> > As time goes on we're going to move everything to one uniform, simpler and
> > more powerful module loading interface...
> >
> > I'd like to change the linux-ha software so that everything is a module -
> > even the configuration parser. I won't do it by adding more module
> > interfaces, but instead by collapsing down to one.
> >
> Well that one might become tricky.
>
> [snip]
> >
> > I would do two things:
> >
> > Every function in a file has the same module name. I would make a single
> > #define MODULE, or HB_MODULE or something that the other macros used like a
> > global variable. This works just fine because you can never put more than
> > one module in a file... Then it might read more like this:
> >
> > #define MODULE_NAME "crc" /* Too bad we can't use __FILE__ here... */
> > #include <ha_modules.h>
> >
> > /* From ha_modules.h... */
> > #ifndef _HA_MODULES_H
> > #define _HA_MODULES_H
> >
> > /*
> > * SPECIAL NOTE:
> > * Must define MODULE_NAME *before* including this header if you
> > * want to use the EXPORT function.
> > */
> > ifdef __STDC__
> > # define CONC(x, y) x##y
> > # ifdef MODULE_NAME
> > # define EXPORT(name) MODULE_NAME##_LTX_##name
> > # endif
> > #else
> > # define CONC(x, y) x/**/y
> > # ifdef MODULE_NAME
> > # define EXPORT(name) MODULE_NAME/**/_LTX_/**/name
> > # endif
> > #endif
> > #endif /* _HA_MODULES_H */
> > /* End of ha_modules.h */
> >
> > int
> > EXPORT(hb_dev_init) (void) {
> > ...
> > }
> >
> That would define MODULE_NAME_LTX_hb_dev_init and not crc_LTX_hb_dev_init
> since the macro MODULE_NAME is not expanded. That's somewhat strange,
> isn't it?
> something like
> #define EXPORT(module, function) module##_LTX_##function
> works properly.
> As it seems we will have to live with that EXPORT(module, function)
> macro, but perhaps someone else has got an idea how to make the
> expansion work?
This is really weird...
#define MODULE foo
#define EXPORT2(module, function) module##__LTX__##function
#define EXPORT(function) EXPORT2( MODULE, function)
#define TEST(function) printf("%s %s", MODULE, function)
EXPORT(main)
EXPORT2(MODULE, main)
TEST(bar)
The preprocessor output from this is:
MODULE__LTX__main
MODULE__LTX__main
printf("%s %s", foo , bar )
I'll ask my local LUG...
Other opinions are much appreciated.
-- Alan Robertson
alanr@unix.sh
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.community.tummy.com
http://lists.community.tummy.com/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic