I have two questions:
1. Is iocshRegisterCommon() defined to be idempotent (ie, safe to call repeatedly)?
2. Is what I'm trying to do below sane?
I am looking into creating a mechanism for dynamically loading EPICS support modules and it looks as if I need to add an xxx_registerRecordDeviceDriver.cpp file to each support module that I wish to be able to use so that I have a dbd registration function available to call.
Loading a dynamically generated support module requires the following steps:
1. Load the .so file.
2. Load the .dbd file (dbLoadDatabase seems to serve).
3. Register the dbd functionality.
Of course, step 3 is the tricky one. I've experimented by adding the appropriate <module>_registerRecordDeviceDriver.cpp to the support module's build and then dynamically invoking the generated <module>_registerRecordDeviceDriver function ... and everything seems to work, but I am worried by one small detail.
The generated code, generated by registerRecordDeviceDriver.pl from the module's .dbd file, is straightforward enough, but it always includes a call to iocshRegisterCommon() which gets called at C++ static constructor initialisation time ... which means if I'm generating register functions for every support module *and* for my base IOC this function will be called repeatedly. I imagine there's no particular guarantee that this function is idempotent, is there?
First of all, is this a sane approach for what I'm trying to achieve?
Secondly, is this safe at the moment? I've dug into iocshRegisterCommon and its calls, and its work seems to devolve to numerous calls to iocshRegister, which looks properly monotonic to me, so I'm encouraged to proceed.
Could we perhaps make the fact that iocshRegisterCommon can safely be called repeatedly more explicit by applying the following patch?
diff --git a/src/misc/iocshRegisterCommon.c b/src/misc/iocshRegisterCommon.c
index 3e027eb..838de43 100644
@@ -21,8 +21,14 @@
+static int initialised = 0;
void epicsShareAPI iocshRegisterCommon(void)
+ if (initialised)
+ initialised = 1;
iocshPpdbbase = &pdbbase;
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom
- Re: Registering DBD files and iocshRegisterCommon Andrew Johnson
- Navigate by Date:
RE: Initializing starting position on a Motor Mark Rivers
EPICS driver for E-517 Rau, Steffen
- Navigate by Thread:
RE: Initializing starting position on a Motor Tonia Batten
Re: Registering DBD files and iocshRegisterCommon Andrew Johnson