[lcdproc] Configuration File Syntax (proposed)
Fri, 21 Sep 2001 11:43:05 -0600
--- email@example.com wrote ---
> Joris Robijn wrote:
> > No. Different modules should exist that have the same name defined. You
> > just dynamically load the ones you need. The functions are stored as
> > pointers at loading.
> That is what #2 said which you clipped... except you still can only have
> ONE dynamic library for each function.
> If I need to call lcd_init(), which driver do I call? The dynamic
> library loading mechanism, as I understand it, only loads the FIRST one
> it finds - which is why libsafe.so can operate and take over the
> functions like strcpy and others, while the GNU glibc versions of these
> go unused.
> Thus, if one makes a call to lcd_init(), then the FIRST library found by
> ld.so (the dynamic linker) will be used to complete the call.
> If "another" lcd_init() call is supposed to be made, it won't be done.
Huh? My dlopen() man page says:
void * dlopen(const char *pathname, int mode);
The dlopen() function makes an executable object file avail-
able to a running process. It returns to the process a han-
dle which the process may use on subsequent calls to dlsym()
and dlclose(). The value of this handle should not be inter-
preted in any way by the process. The pathname argument is
the path name of the object to be opened.
Thus, you're specifying what file to open up. Not relying on the linker to
sort it out for you. So in the case of multiple device drivers, you'd do
void * firstdevice;
void * seconddevice;
void *() firstinit;
void *() secondinit;
/* back off, I'm still sketchy on my pointers-to-functions :) */
/* we'll assume the above works */
firstdevice = dlopen("/usr/lib/libmtxorb.so", RTLD_LOCAL);
seconddevice = dlopen("/usr/lib/libcfontz.so", RTLD_LOCAL);
firstinit = dlsym(firstdevice, "lcd_init");
secondinit = dlsym(seconddevice, "lcd_init");
> So I call init(). Which one gets used? joy.so? keyboard.so?
> MtxOrb.so? All three?
> You can't have multiple input drivers with separate dynamically loaded
> libraries for each driver.
Yeah you can. Lookit the above code. You have to keep a linked list of the
drivers you've got loaded (and a list of pointers to their functions), but
it can be done fairly easily.
> Personally, I believe that multiple input drivers are probably required,
> especially since one can have something like this MatrixOrbital LK202-25
> display with multiple Infrared Remotes and such like. It would be a
> difficult time creating a CD Player screen if you couldn't use multiple
> input devices.
> Another thing - unless input and output drivers are _physically_ split,
> then one can't load multiple input drivers - since they'd be tied to
> output drivers. Worse yet, if you load a driver that had output but no
> input - then you'd have no input sources at all.
> I think that if anything, a specialized loader will be needed, instead
> of the standard dynamic loader. This also would have the advantage of
> working in environments without the UNIX dynamic loader.
dlopen() works on Solaris, Linux, and cygwin at least, and I believe there
are equivalent functions available on other Unices.
To unsubscribe from this list send a blank message to