dynamically loaded drivers in R7B
Vance Shipley
vances@REDACTED
Sat Nov 25 04:13:32 CET 2000
I am putting together a dynamically linked and have seen some conflict
between the documentation and the header file erl_driver.h.
erl_driver.h:
typedef struct erl_drv_entry {
int (*init)(void); /* called at system start up for statically
linked drivers, and after loading for
dynamically loaded drivers */
...
That makes sense however the erl_ddll documentation says:
The init function in struct driver_entry is not used anymore. After the driver
is loaded, the function struct driver_entry *driver_init(void *) is called with
handle as argument. If the operating system loader cannot find a function called
driver_init, the driver will not be loaded.
Now even to further muddy the waters erl_driver.h has:
/*
* This macro is used to name a dynamic driver's init function in
* a way that doesn't lead to conflicts. This is crucial when using
* operating systems that has one namespace for all symbols
* (e.g. VxWorks). Example: if you have an dynamic driver C source
* file named echo_drv.c, you use the macro like this:
*
* DRIVER_INIT(echo_drv)
* {
* ....
* }
*
* This function well be called by the Erlang I/O system when the driver is load
ed.
* It must initialize a ErlDrvEntry structure and return a pointer to it.
*/
#if defined(VXWORKS)
# define DRIVER_INIT(DRIVER_NAME) ErlDrvEntry* DRIVER_NAME ## _init(void)
#elif defined(__WIN32__)
# define DRIVER_INIT(DRIVER_NAME) __declspec(dllexport) ErlDrvEntry* driver_i
nit(void)
#else
# define DRIVER_INIT(DRIVER_NAME) ErlDrvEntry* driver_init(void)
#endif
So which is it? What does myt function get named in my_drv.c and what
value do I give my_drv_entry.init?
-Vance
More information about the erlang-questions
mailing list