Merge ~dirk.zimoch/epics-base:dynamicVxWorksVmeFunctionBinding into ~epics-core/epics-base/+git/epics-base:7.0

Proposed by Dirk Zimoch
Status: Merged
Approved by: Andrew Johnson
Approved revision: 251304e280c023ed72031d25981d6db4bd0b73d4
Merged at revision: 220a27bdec2492f9938ccf2a275ba7d04f06cf30
Proposed branch: ~dirk.zimoch/epics-base:dynamicVxWorksVmeFunctionBinding
Merge into: ~epics-core/epics-base/+git/epics-base:7.0
Diff against target: 110 lines (+31/-17)
1 file modified
modules/libcom/src/osi/os/vxWorks/devLibVMEOSD.c (+31/-17)
Reviewer Review Type Date Requested Status
Andrew Johnson Approve
Review via email: mp+367253@code.launchpad.net

Description of the change

Use dynamic binding for vxWorks BSP functions because some BSPs don't provide them.

To post a comment you must log in.
Revision history for this message
Andrew Johnson (anj) wrote :

Why not just replace the #if lines with if (...) { and leave the bodies of the functions untouched? That would make it easier for reviewers to confirm that you aren't changing the logic at all. As it is we have to understand both the original logic and what you've replaced it with and convince ourselves that their behavior will be the same, but using run-time detection instead of compile-time. Modern compilers should generate the same code for both versions so human readability is more important than conciseness.

I know that some people don't like having multiple return statements in a function; personally I disagree with that position, especially in simple cases like these where there are no resources that need releasing.

Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :

New version as suggested.

Revision history for this message
Andrew Johnson (anj) wrote :

Thanks.

review: Approve
Revision history for this message
mdavidsaver (mdavidsaver) wrote :
Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :

The problem here was that not every vxWorks system has a VME bus and thus loading EPICS base failed with unresolved symbols. This applies to each library/module that has vxWorks support for VME mixed with code for other useful stuff. At the moment if you want the other stuff you must have VME. So yes, that may apply to devLib2 as well.

However so far I only had one such system, that is an old CompactRIO fom NI. And on that system I do not use devLib2. So I have not noticed a problem.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/modules/libcom/src/osi/os/vxWorks/devLibVMEOSD.c b/modules/libcom/src/osi/os/vxWorks/devLibVMEOSD.c
2index 82bec60..93d30fc 100644
3--- a/modules/libcom/src/osi/os/vxWorks/devLibVMEOSD.c
4+++ b/modules/libcom/src/osi/os/vxWorks/devLibVMEOSD.c
5@@ -110,7 +110,21 @@ static long vxDevWriteProbe (unsigned wordSize, volatile void *ptr, const void *
6
7 static void *devA24Malloc(size_t size);
8 static void devA24Free(void *pBlock);
9-static long devInit(void) { return 0;}
10+
11+/* We don't know which functions are implemented in the BSP */
12+static int (*sysIntEnableFunc)(int) = NULL;
13+static int (*sysIntDisableFunc)(int) = NULL;
14+static int (*sysIntEnablePICFunc)(int) = NULL;
15+static int (*sysIntDisablePICFunc)(int) = NULL;
16+
17+static long devInit(void)
18+{
19+ sysIntEnableFunc = epicsFindSymbol ("sysIntEnable");
20+ sysIntDisableFunc = epicsFindSymbol ("sysIntDisable");
21+ sysIntDisablePICFunc = epicsFindSymbol ("sysIntDisablePIC");
22+ sysIntEnablePICFunc = epicsFindSymbol ("sysIntEnablePIC");
23+ return 0;
24+}
25
26 static long vxDevConnectInterruptVME (
27 unsigned vectorNumber,
28@@ -214,16 +228,16 @@ static long vxDevDisconnectInterruptVME (
29 */
30 static long vxDevEnableInterruptLevelVME (unsigned level)
31 {
32-# if CPU_FAMILY != I80X86
33+ if (sysIntEnableFunc) {
34 int s;
35- s = sysIntEnable (level);
36+ s = sysIntEnableFunc (level);
37 if (s!=OK) {
38 return S_dev_intEnFail;
39 }
40 return 0;
41-# else
42+ } else {
43 return S_dev_intEnFail;
44-# endif
45+ }
46 }
47
48 /*
49@@ -231,16 +245,16 @@ static long vxDevEnableInterruptLevelVME (unsigned level)
50 */
51 long devEnableInterruptLevelISA (unsigned level)
52 {
53-# if CPU_FAMILY == I80X86
54+ if (sysIntEnablePICFunc) {
55 int s;
56- s = sysIntEnablePIC (level);
57+ s = sysIntEnablePICFunc (level);
58 if (s!=OK) {
59 return S_dev_intEnFail;
60 }
61 return 0;
62-# else
63+ } else {
64 return S_dev_intEnFail;
65-# endif
66+ }
67 }
68
69 /*
70@@ -248,15 +262,15 @@ long devEnableInterruptLevelISA (unsigned level)
71 */
72 long devDisableInterruptLevelISA (unsigned level)
73 {
74-# if CPU_FAMILY == I80X86
75+ if (sysIntDisablePICFunc) {
76 int s;
77- s = sysIntDisablePIC (level);
78+ s = sysIntDisablePICFunc (level);
79 if (s!=OK) {
80 return S_dev_intEnFail;
81 }
82-# else
83+ } else {
84 return S_dev_intEnFail;
85-# endif
86+ }
87
88 return 0;
89 }
90@@ -266,16 +280,16 @@ long devDisableInterruptLevelISA (unsigned level)
91 */
92 static long vxDevDisableInterruptLevelVME (unsigned level)
93 {
94-# if CPU_FAMILY != I80X86
95+ if (sysIntDisableFunc) {
96 int s;
97- s = sysIntDisable (level);
98+ s = sysIntDisableFunc (level);
99 if (s!=OK) {
100 return S_dev_intDissFail;
101 }
102 return 0;
103-# else
104+ } else {
105 return S_dev_intEnFail;
106-# endif
107+ }
108 }
109
110 /*

Subscribers

People subscribed via source and target branches