Date: Sat, 28 May 2005 18:15:33 +0200 From: Jachym Holecek Subject: Re: [nanogui] Pending patches/bug/requests ... list available on the FTP ---------------- another solution for the 20050427-optional_FBLIN_support.txt ---------------- Hello, > I'd like to see this one go in, I was about to start writing the same kind of > patch. Another option would be to have all drivers register themselves. > So in each driver file something like > > static void register_me() __attribute__ ((constructor)) > { > global_driver_table_append(&my_driver_struct); > } > > Then the driver selection code in fb.c would turn from a big switch to an > iteration over the list of drivers and choose the matching one. This would > get rid of the ifdefs in this file. > > Would you consider this a better option ? In case portability is of concern, you can avoid the __attribute__ quite easily: * Have each driver contain "DEFDRIVER(my_driver_struct)", where DEFDRIVER is a no-op macro. * At compile time, scan all the driver sources for DEFDRIVER() and have a tiny sed+awk/whatever script construct a .c file with the driver table. That's what I do in a private project of mine, and it works reasonable well. If people think this would be a good way, I'd volunteer to implement it. Regards, -- Jachym Holecek --------------------------------------------------------------------- To unsubscribe, e-mail: nanogui-unsubscribe@linuxhacker.org For additional commands, e-mail: nanogui-help@linuxhacker.org