I have the following problem while building a compat layer for compiling linux drivers on FreeBSD: a piece of code (let's restrict to a kld if it makes things simpler) needs to register some information to the system calling a function: usb_register(&some_data) where some_data is a structure containing various info (callbacks etc) for the code. The problem is, i need to hook the argument of usb_register() to the kld. If i write /* in linux_module_header.h */ extern void *my_module_info; #define usb_register(p) my_module_info = p /* in linux_driver_stub.c, linked together with the rest of the code */ #include "linux_module_header.h" void *my_module_info; I get what i want, but then my_module_info is present in all modules compiled with the same trick, so what happens when the modules are kldloaded ? Does this symbol conflict (i.e. is this equivalent to RTLD_GLOBAL) or each one sees its own symbols (i.e. like RTLD_LOCAL) ? And besides, this would almost surely fail if i compile these things not as modules but as part of the kernel. The other trick i can think of is using some preprocessor-magic to create unique names for the symbol, e.g. compile each kld with -DDRIVER_NAME=pwc, -DDRIVER_NAME=gspca, -DDRIVER_NAME=dvb and then have /* in linux_module_header.h */ #define MODINFO_NAME module_ ## DRIVER_NAME ## _info extern void *MODINFO_NAME; #define usb_register(p) MODINFO_NAME = p /* in linux_driver_stub.c, linked together with the rest of the code */ #include "linux_module_header.h" void *MODINFO_NAME; This way each module has a different symbol and there are no conflict. Other ideas ? cheers luigiReceived on Wed Jan 24 2007 - 10:12:17 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:05 UTC