From: <jc...@fe...> - 2003-02-07 14:49:20
|
On Wednesday 05 February 2003 16:55, Jo=E3o Cardoso wrote: | On Wednesday 05 February 2003 13:55, Rafael Laboissiere wrote: | | * Rafael Laboissiere <lab...@ps...> [2003-02-04 22:37]: | | > c) At build time (not configuration time), a small C program | | > dlopen the <driver>.c files, get the symbols described above and | | > write the associated device entries in <driver>.rc (or whichever | | > name). | | | | Just to make things a bit more concrete, here is the design that I | | have in mind. I will take the ps.c driver as an example. The | | following global variables will be defined in the driver source: | | | | char* DEVICES_ps =3D "ps:psc"; | | | | char* DESCRIPTION_ps =3D "PostScript File (monochrome)"; | | int TYPE_ps =3D plDevType_FileOriented; | | int SEQNUM_ps =3D 29; | | char* SYMTAG_ps =3D "psm"; | | | | char* DESCRIPTION_psc =3D "PostScript File (color)"; | | int TYPE_psc =3D plDevType_FileOriented; | | int SEQNUM_psc =3D 30; | | char* SYMTAG_psc =3D "psc"; | | | | Of course, these variables should be used in the | | plD_dispatch_init_* functions. In the case of ps.c: | | | | ps_dispatch_init_helper( pdt, | | DESCRIPTION_ps, "ps", | | TYPE_ps, SEQNUM_ps, | | (plD_init_fp) plD_init_psm ); | | | | ps_dispatch_init_helper( pdt, | | DESCRIPTION_psc, "psc", | | TYPE_psc, SEQNUM_psc, | | (plD_init_fp) plD_init_psc ); | | | | This will insure that things are not defined twice in different | | places (like with the current DEVICE_INFO_* variable). | | | | The small C program that will generate the <driver>.rc file from | | the <driver>.la file, would do: (1) dlopen the module; (2) get the | | DEVICES_* symbol and parse its device components (in the ps.c | | exemple, that would be "ps" and "psc"); (3) for each one of the | | devices found, get the symbols DESCRIPTION_<dev>, TYPE_<dev>, | | SEQNUM_<dev>, and SYMTAG_<dev>; (4) create the temp file that is | | parsed by Geoff's code. (This could be improved along Joao's | | suggestion of creating a structure instead of writing the | | information in a temp file.) | | | | We have to decide first whether it is not worth abandoning the | | current approach and adopting this "cached info" approach above. Now that HEAD is working again. lets continue. I measure the time that your code in plInitDispatchTable() takes to load=20 all drivers, and it is only 20ms (wall clock) for all 33 drivers, on a=20 P3@700MHz (with a small but continuous load of 1). It looks like it is=20 pretty efficient. Your concerns that dlopen() would load all libraries that a driver needs=20 does not apply, as this would only happens if some drivers code is=20 executed, which is not the case. As libtool's info says: "Unresolved symbols in the module are resolved using its dependency libraries" As the symbols you are looking for are in the modules, no further=20 loading will occur. Thus, given that the current implementation is efficient enough, avoids=20 the need of another program to build the drivers.rc file, is fully=20 dynamic because if more drivers are added to the directory they will be=20 recognized without further intervention,... lets keep it as is. Joao | | I decided to give it a try but got a seg fault: | | [jcard@feup] gdb x01c | (gdb) run -dev xwin | Starting program: /usr/local/test/lib/plplot5.2.0/examples/c/x01c | -dev xwin | | Program received signal SIGSEGV, Segmentation fault. | 0x0806a46e in lt_dlsym (handle=3D0x807b0e0, | symbol=3D0xbfffef50 "DEVICE_INFO_pstex") at ltdl.c:3330 | 3330 lensym =3D LT_STRLEN (symbol) + LT_STRLEN | (handle->loader->sym_prefix) | (gdb) where | #0 0x0806a46e in lt_dlsym (handle=3D0x807b0e0, | symbol=3D0xbfffef50 "DEVICE_INFO_pstex") at ltdl.c:3330 | #1 0x08053d38 in plInitDispatchTable () at plcore.c:1638 | #2 0x08049b9d in plMergeOpts (options=3D0x8073500, | name=3D0x11 <Address 0x11 out of bounds>, notes=3D0x11) at | plargs.c:699 #3 0x08049362 in main () | #4 0x400674a2 in __libc_start_main () from /lib/libc.so.6 | | | There is also Joao's suggestion for dynamically building the | | drivers.db, but I am too lazy to implement that (and I am not sure | | it is a superior approach). | | | | What do you think? I accept suggestions for better variable names. | | ------------------------------------------------------- | This SF.NET email is sponsored by: | SourceForge Enterprise Edition + IBM + LinuxWorld | http://www.vasoftware.com | _______________________________________________ | Plplot-devel mailing list | Plp...@li... | https://lists.sourceforge.net/lists/listinfo/plplot-devel |