Merge lp:~epics-core/epics-base/fixatomiclinkage into lp:~epics-core/epics-base/3.15
- fixatomiclinkage
- Merge into 3.15
Status: | Merged |
---|---|
Approved by: | Andrew Johnson |
Approved revision: | 12638 |
Merged at revision: | 12647 |
Proposed branch: | lp:~epics-core/epics-base/fixatomiclinkage |
Merge into: | lp:~epics-core/epics-base/3.15 |
Diff against target: |
1216 lines (+479/-197) 26 files modified
src/libCom/osi/compiler/clang/compilerSpecific.h (+6/-0) src/libCom/osi/compiler/clang/epicsAtomicCD.h (+1/-9) src/libCom/osi/compiler/default/compilerSpecific.h (+8/-0) src/libCom/osi/compiler/default/epicsAtomicCD.h (+3/-10) src/libCom/osi/compiler/gcc/compilerSpecific.h (+6/-0) src/libCom/osi/compiler/gcc/epicsAtomicCD.h (+5/-5) src/libCom/osi/compiler/msvc/compilerSpecific.h (+6/-0) src/libCom/osi/compiler/msvc/epicsAtomicCD.h (+8/-14) src/libCom/osi/compiler/solStudio/compilerSpecific.h (+44/-0) src/libCom/osi/compiler/solStudio/epicsAtomicCD.h (+1/-9) src/libCom/osi/epicsAtomic.h (+41/-60) src/libCom/osi/os/RTEMS/epicsAtomicOSD.h (+65/-0) src/libCom/osi/os/WIN32/epicsAtomicOSD.cpp (+0/-22) src/libCom/osi/os/WIN32/epicsAtomicOSD.h (+2/-0) src/libCom/osi/os/posix/epicsAtomicOSD.cpp (+11/-36) src/libCom/osi/os/posix/epicsAtomicOSD.h (+19/-0) src/libCom/osi/os/solaris/epicsAtomicOSD.h (+11/-7) src/libCom/osi/os/vxWorks/epicsAtomicOSD.cpp (+0/-21) src/libCom/osi/os/vxWorks/epicsAtomicOSD.h (+8/-4) src/libCom/test/Makefile (+8/-0) src/libCom/test/epicsAtomicTest.cpp (+78/-0) src/libCom/test/epicsInlineTest1.c (+64/-0) src/libCom/test/epicsInlineTest2.c (+28/-0) src/libCom/test/epicsInlineTest3.cpp (+27/-0) src/libCom/test/epicsInlineTest4.cpp (+27/-0) src/libCom/test/epicsRunLibComTests.c (+2/-0) |
To merge this branch: | bzr merge lp:~epics-core/epics-base/fixatomiclinkage |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrew Johnson | Approve | ||
mdavidsaver | Approve | ||
Ralph Lange | Pending | ||
Review via email: mp+251335@code.launchpad.net |
This proposal supersedes a proposal from 2015-02-24.
Commit message
Description of the change
To address lp:1425197 switch epicsAtomic functions to 'static inline', which should be consistent accross language and compiler.
Add EPICS_ALWAYS_INLINE macro to help with short wrappers like these.
Add an ISR safe defintion for epicsAtomicLock() for RTEMS.
Extend epicsAtomicTest to print some information about the conditionals effecting epicsAtomicCD and OSD
Add epicsInlineTest to check consistency of 'static inline'.
Also fix some empty argument lists.
mdavidsaver (mdavidsaver) wrote : Posted in a previous version of this proposal | # |
Ralph Lange (ralph-lange) wrote : Posted in a previous version of this proposal | # |
From looking at the code and running the test: yep.
I am even more restricted than Michael in testing envs, though.
Andrew Johnson (anj) wrote : Posted in a previous version of this proposal | # |
I thought you talked about wanting to fix this in 3.15, but this is branched off 3.16.
Tested on RHEL6.6, built OK for VxWorks but not tested yet.
My solaris-sparc build printed this and died:
"../../
I'll investigate further tomorrow (and run tests on VxWorks, Darwin and Windows), I have this afternoon off.
mdavidsaver (mdavidsaver) wrote : Posted in a previous version of this proposal | # |
> I thought you talked about wanting to fix this in 3.15, but this is branched off 3.16.
I do want to target 3.15. If it works with the necessary vxWorks versions (5.5?) then I'll switch to the 3.15 branch.
> Error: #error Not Solaris Studio.
This was all sight unseen, so clearly __SUNPRO_C isn't the correct macro name.
> I have this afternoon off.
Talk to you tomorrow then.
Andrew Johnson (anj) wrote : Posted in a previous version of this proposal | # |
The C++ compiler defines __SUNPRO_CC instead, the C builds were working fine. I committed a fix, assuming that C++ compiler has the same version restrictions on __attribute_
Built and tested (libCom/test only) on VxWorks 6.9 and 5.5.2, OK.
Build on Windows-x64 failed at epicsAtomicTest.cpp due to a typo in testClassify(), now fixed but it does now output "# OS dependent impl name undefined" which you might want to look at.
I also ran a few tests from a cross-built MinGW with no issues; this correctly outputs "# OS dependent impl name WIN32"
I think you could move this to the 3.15 branch instead of 3.16.
mdavidsaver (mdavidsaver) wrote : | # |
Rebase onto 3.15
mdavidsaver (mdavidsaver) wrote : | # |
> ... now output "# OS dependent impl name undefined"
As long as the compiler specific implementation is "MSVC-INTRINSIC" this is expected. This path doesn't include "epicsAtomicOSD.h".
mdavidsaver (mdavidsaver) wrote : | # |
ping
Andrew Johnson (anj) wrote : | # |
Built on RHEL 6.6, VxWorks 5.5, 6.8 and 6.9, RTEMS 4.10.2, Solaris-sparc.
Merging.
Preview Diff
1 | === modified file 'src/libCom/osi/compiler/clang/compilerSpecific.h' |
2 | --- src/libCom/osi/compiler/clang/compilerSpecific.h 2014-02-21 00:05:42 +0000 |
3 | +++ src/libCom/osi/compiler/clang/compilerSpecific.h 2015-02-27 22:38:25 +0000 |
4 | @@ -20,6 +20,12 @@ |
5 | # error compiler/clang/compilerSpecific.h is only for use with the clang compiler |
6 | #endif |
7 | |
8 | +#if __has_attribute(always_inline) |
9 | +#define EPICS_ALWAYS_INLINE __inline__ __attribute__((always_inline)) |
10 | +#else |
11 | +#define EPICS_ALWAYS_INLINE __inline__ |
12 | +#endif |
13 | + |
14 | #ifdef __cplusplus |
15 | |
16 | /* |
17 | |
18 | === modified file 'src/libCom/osi/compiler/clang/epicsAtomicCD.h' |
19 | --- src/libCom/osi/compiler/clang/epicsAtomicCD.h 2011-09-01 17:25:53 +0000 |
20 | +++ src/libCom/osi/compiler/clang/epicsAtomicCD.h 2015-02-27 22:38:25 +0000 |
21 | @@ -16,16 +16,8 @@ |
22 | #ifndef epicsAtomicCD_h |
23 | #define epicsAtomicCD_h |
24 | |
25 | -#if defined ( __cplusplus ) |
26 | -# define EPICS_ATOMIC_INLINE inline |
27 | -#else |
28 | -# define EPICS_ATOMIC_INLINE __inline__ |
29 | -#endif |
30 | +#define EPICS_ATOMIC_CMPLR_NAME "CLANG" |
31 | |
32 | -/* |
33 | - * we have an inline keyword so we can proceed |
34 | - * with an os specific inline instantiation |
35 | - */ |
36 | #include "epicsAtomicOSD.h" |
37 | |
38 | #endif /* epicsAtomicCD_h */ |
39 | |
40 | === modified file 'src/libCom/osi/compiler/default/compilerSpecific.h' |
41 | --- src/libCom/osi/compiler/default/compilerSpecific.h 2011-08-31 22:35:18 +0000 |
42 | +++ src/libCom/osi/compiler/default/compilerSpecific.h 2015-02-27 22:38:25 +0000 |
43 | @@ -15,6 +15,14 @@ |
44 | |
45 | #ifndef compilerSpecific_h |
46 | #define compilerSpecific_h |
47 | + |
48 | +/* The 'inline' key work, possibily with compiler |
49 | + * dependent flags to force inlineing where it would |
50 | + * otherwise not be done. |
51 | + * |
52 | + * Warning: Second guessing the compiler may result in larger code size |
53 | + */ |
54 | +#define EPICS_ALWAYS_INLINE inline |
55 | |
56 | #ifdef __cplusplus |
57 | |
58 | |
59 | === modified file 'src/libCom/osi/compiler/default/epicsAtomicCD.h' |
60 | --- src/libCom/osi/compiler/default/epicsAtomicCD.h 2011-09-01 17:25:53 +0000 |
61 | +++ src/libCom/osi/compiler/default/epicsAtomicCD.h 2015-02-27 22:38:25 +0000 |
62 | @@ -16,15 +16,8 @@ |
63 | #ifndef epicsAtomicCD_h |
64 | #define epicsAtomicCD_h |
65 | |
66 | -#if __STDC_VERSION__ >= 199901L || defined ( __cplusplus ) |
67 | -# define EPICS_ATOMIC_INLINE inline |
68 | - /* |
69 | - * We have already defined the public interface in epicsAtomic.h |
70 | - * so there is nothing more to implement if there isnt an inline |
71 | - * keyword available. Otherwise, if we have an inline keyword |
72 | - * we will proceed with an os specific inline implementation. |
73 | - */ |
74 | -# include "epicsAtomicOSD.h" |
75 | -#endif |
76 | +#define EPICS_ATOMIC_CMPLR_NAME "DEFAULT" |
77 | + |
78 | +#include "epicsAtomicOSD.h" |
79 | |
80 | #endif /* epicsAtomicCD_h */ |
81 | |
82 | === modified file 'src/libCom/osi/compiler/gcc/compilerSpecific.h' |
83 | --- src/libCom/osi/compiler/gcc/compilerSpecific.h 2014-02-21 00:05:42 +0000 |
84 | +++ src/libCom/osi/compiler/gcc/compilerSpecific.h 2015-02-27 22:38:25 +0000 |
85 | @@ -23,6 +23,12 @@ |
86 | #ifdef __clang__ |
87 | # error compiler/gcc/compilerSpecific.h is not for use with the clang compiler |
88 | #endif |
89 | + |
90 | +#if __GNUC__ > 2 |
91 | +# define EPICS_ALWAYS_INLINE __inline__ __attribute__((always_inline)) |
92 | +#else |
93 | +# define EPICS_ALWAYS_INLINE __inline__ |
94 | +#endif |
95 | |
96 | #ifdef __cplusplus |
97 | |
98 | |
99 | === modified file 'src/libCom/osi/compiler/gcc/epicsAtomicCD.h' |
100 | --- src/libCom/osi/compiler/gcc/epicsAtomicCD.h 2013-11-21 00:55:44 +0000 |
101 | +++ src/libCom/osi/compiler/gcc/epicsAtomicCD.h 2015-02-27 22:38:25 +0000 |
102 | @@ -20,7 +20,7 @@ |
103 | # error this header is only for use with the gnu compiler |
104 | #endif |
105 | |
106 | -#define EPICS_ATOMIC_INLINE __inline__ |
107 | +#define EPICS_ATOMIC_CMPLR_NAME "GCC" |
108 | |
109 | #define GCC_ATOMIC_CONCAT( A, B ) GCC_ATOMIC_CONCATR(A,B) |
110 | #define GCC_ATOMIC_CONCATR( A, B ) ( A ## B ) |
111 | @@ -69,7 +69,7 @@ |
112 | |
113 | #ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER |
114 | #define EPICS_ATOMIC_READ_MEMORY_BARRIER |
115 | -EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier () |
116 | +EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void) |
117 | { |
118 | __sync_synchronize (); |
119 | } |
120 | @@ -77,7 +77,7 @@ |
121 | |
122 | #ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER |
123 | #define EPICS_ATOMIC_WRITE_MEMORY_BARRIER |
124 | -EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier () |
125 | +EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void) |
126 | { |
127 | __sync_synchronize (); |
128 | } |
129 | @@ -88,7 +88,7 @@ |
130 | #ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER |
131 | #if GCC_ATOMIC_INTRINSICS_MIN_X86 |
132 | #define EPICS_ATOMIC_READ_MEMORY_BARRIER |
133 | -EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier () |
134 | +EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void) |
135 | { |
136 | asm("mfence;"); |
137 | } |
138 | @@ -98,7 +98,7 @@ |
139 | #ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER |
140 | #if GCC_ATOMIC_INTRINSICS_MIN_X86 |
141 | #define EPICS_ATOMIC_WRITE_MEMORY_BARRIER |
142 | -EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier () |
143 | +EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void) |
144 | { |
145 | asm("mfence;"); |
146 | } |
147 | |
148 | === modified file 'src/libCom/osi/compiler/msvc/compilerSpecific.h' |
149 | --- src/libCom/osi/compiler/msvc/compilerSpecific.h 2011-08-31 22:35:18 +0000 |
150 | +++ src/libCom/osi/compiler/msvc/compilerSpecific.h 2015-02-27 22:38:25 +0000 |
151 | @@ -20,6 +20,12 @@ |
152 | # error compiler/msvc/compilerSpecific.h is only for use with the Microsoft compiler |
153 | #endif |
154 | |
155 | +#if _MSC_VER >= 1200 |
156 | +#define EPICS_ALWAYS_INLINE __forceinline |
157 | +#else |
158 | +#define EPICS_ALWAYS_INLINE __inline |
159 | +#endif |
160 | + |
161 | #ifdef __cplusplus |
162 | |
163 | /* |
164 | |
165 | === modified file 'src/libCom/osi/compiler/msvc/epicsAtomicCD.h' |
166 | --- src/libCom/osi/compiler/msvc/epicsAtomicCD.h 2011-09-01 17:25:53 +0000 |
167 | +++ src/libCom/osi/compiler/msvc/epicsAtomicCD.h 2015-02-27 22:38:25 +0000 |
168 | @@ -24,18 +24,14 @@ |
169 | |
170 | #ifdef _MSC_EXTENSIONS |
171 | |
172 | +#define EPICS_ATOMIC_CMPLR_NAME "MSVC-INTRINSIC" |
173 | + |
174 | #include <intrin.h> |
175 | |
176 | -#if _MSC_VER >= 1200 |
177 | -# define EPICS_ATOMIC_INLINE __forceinline |
178 | -#else |
179 | -# define EPICS_ATOMIC_INLINE __inline |
180 | -#endif |
181 | - |
182 | #if defined ( _M_IX86 ) |
183 | # pragma warning( push ) |
184 | # pragma warning( disable : 4793 ) |
185 | - EPICS_ATOMIC_INLINE void epicsAtomicMemoryBarrier () |
186 | + EPICS_ATOMIC_INLINE void epicsAtomicMemoryBarrier (void) |
187 | { |
188 | long fence; |
189 | __asm { xchg fence, eax } |
190 | @@ -44,14 +40,14 @@ |
191 | #elif defined ( _M_X64 ) |
192 | # define MS_ATOMIC_64 |
193 | # pragma intrinsic ( __faststorefence ) |
194 | - EPICS_ATOMIC_INLINE void epicsAtomicMemoryBarrier () |
195 | + EPICS_ATOMIC_INLINE void epicsAtomicMemoryBarrier (void) |
196 | { |
197 | __faststorefence (); |
198 | } |
199 | #elif defined ( _M_IA64 ) |
200 | # define MS_ATOMIC_64 |
201 | # pragma intrinsic ( __mf ) |
202 | - EPICS_ATOMIC_INLINE void epicsAtomicMemoryBarrier () |
203 | + EPICS_ATOMIC_INLINE void epicsAtomicMemoryBarrier (void) |
204 | { |
205 | __mf (); |
206 | } |
207 | @@ -88,13 +84,13 @@ |
208 | #endif /* __cplusplus */ |
209 | |
210 | #define EPICS_ATOMIC_READ_MEMORY_BARRIER |
211 | -EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier () |
212 | +EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void) |
213 | { |
214 | epicsAtomicMemoryBarrier (); |
215 | } |
216 | |
217 | #define EPICS_ATOMIC_WRITE_MEMORY_BARRIER |
218 | -EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier () |
219 | +EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void) |
220 | { |
221 | epicsAtomicMemoryBarrier (); |
222 | } |
223 | @@ -108,9 +104,7 @@ |
224 | |
225 | #else /* ifdef _MSC_EXTENSIONS */ |
226 | |
227 | -#if defined ( __cplusplus ) |
228 | -# define EPICS_ATOMIC_INLINE inline |
229 | -#endif |
230 | +#define EPICS_ATOMIC_CMPLR_NAME "MSVC-DIRECT" |
231 | |
232 | /* |
233 | * if unavailable as an intrinsic we will try |
234 | |
235 | === added file 'src/libCom/osi/compiler/solStudio/compilerSpecific.h' |
236 | --- src/libCom/osi/compiler/solStudio/compilerSpecific.h 1970-01-01 00:00:00 +0000 |
237 | +++ src/libCom/osi/compiler/solStudio/compilerSpecific.h 2015-02-27 22:38:25 +0000 |
238 | @@ -0,0 +1,44 @@ |
239 | +/*************************************************************************\ |
240 | +* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne |
241 | +* National Laboratory. |
242 | +* Copyright (c) 2002 The Regents of the University of California, as |
243 | +* Operator of Los Alamos National Laboratory. |
244 | +* EPICS BASE is distributed subject to a Software License Agreement found |
245 | +* in file LICENSE that is included with this distribution. |
246 | +\*************************************************************************/ |
247 | + |
248 | +/* |
249 | + * Author: |
250 | + * Jeffrey O. Hill |
251 | + * johill@lanl.gov |
252 | + */ |
253 | + |
254 | +#ifndef compilerSpecific_h |
255 | +#define compilerSpecific_h |
256 | + |
257 | +#if !defined(__SUNPRO_C) && !defined (__SUNPRO_CC) |
258 | +# error Not Solaris Studio |
259 | +#endif |
260 | + |
261 | +#if (defined(__SUNPRO_C) && __SUNPRO_C < 0x590) || \ |
262 | + (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590) |
263 | +# define EPICS_ALWAYS_INLINE inline |
264 | +#else |
265 | +# define EPICS_ALWAYS_INLINE inline __attribute__((always_inline)) |
266 | +#endif |
267 | + |
268 | +#ifdef __cplusplus |
269 | + |
270 | +/* |
271 | + * CXX_PLACEMENT_DELETE - defined if compiler supports placement delete |
272 | + * CXX_THROW_SPECIFICATION - defined if compiler supports throw specification |
273 | + * |
274 | + * (our default guess is that the compiler implements the C++ 97 standard) |
275 | + */ |
276 | +#define CXX_THROW_SPECIFICATION |
277 | +#define CXX_PLACEMENT_DELETE |
278 | + |
279 | +#endif /* __cplusplus */ |
280 | + |
281 | + |
282 | +#endif /* ifndef compilerSpecific_h */ |
283 | |
284 | === modified file 'src/libCom/osi/compiler/solStudio/epicsAtomicCD.h' |
285 | --- src/libCom/osi/compiler/solStudio/epicsAtomicCD.h 2011-09-01 17:25:53 +0000 |
286 | +++ src/libCom/osi/compiler/solStudio/epicsAtomicCD.h 2015-02-27 22:38:25 +0000 |
287 | @@ -16,16 +16,8 @@ |
288 | #ifndef epicsAtomicCD_h |
289 | #define epicsAtomicCD_h |
290 | |
291 | -#if defined ( __cplusplus ) |
292 | -# define EPICS_ATOMIC_INLINE inline |
293 | -#else |
294 | -# define EPICS_ATOMIC_INLINE __inline |
295 | -#endif |
296 | +#define EPICS_ATOMIC_CMPLR_NAME "SOLSTUDIO" |
297 | |
298 | -/* |
299 | - * we have an inline keyword so we can proceed |
300 | - * with an os specific inline instantiation |
301 | - */ |
302 | #include "epicsAtomicOSD.h" |
303 | |
304 | #endif /* epicsAtomicCD_h */ |
305 | |
306 | === modified file 'src/libCom/osi/epicsAtomic.h' |
307 | --- src/libCom/osi/epicsAtomic.h 2013-11-20 17:51:14 +0000 |
308 | +++ src/libCom/osi/epicsAtomic.h 2015-02-27 22:38:25 +0000 |
309 | @@ -17,7 +17,9 @@ |
310 | |
311 | #include <stdlib.h> /* define size_t */ |
312 | |
313 | -#include "shareLib.h" |
314 | +#include "compilerSpecific.h" |
315 | + |
316 | +#define EPICS_ATOMIC_INLINE static EPICS_ALWAYS_INLINE |
317 | |
318 | #ifdef __cplusplus |
319 | extern "C" { |
320 | @@ -26,10 +28,10 @@ |
321 | typedef void * EpicsAtomicPtrT; |
322 | |
323 | /* load target into cache */ |
324 | -epicsShareFunc void epicsAtomicReadMemoryBarrier (); |
325 | +EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void); |
326 | |
327 | /* push cache version of target into target */ |
328 | -epicsShareFunc void epicsAtomicWriteMemoryBarrier (); |
329 | +EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void); |
330 | |
331 | /* |
332 | * lock out other smp processors from accessing the target, |
333 | @@ -37,8 +39,8 @@ |
334 | * to target, allow other smp processors to access the target, |
335 | * return new value of target as modified by this operation |
336 | */ |
337 | -epicsShareFunc size_t epicsAtomicIncrSizeT ( size_t * pTarget ); |
338 | -epicsShareFunc int epicsAtomicIncrIntT ( int * pTarget ); |
339 | +EPICS_ATOMIC_INLINE size_t epicsAtomicIncrSizeT ( size_t * pTarget ); |
340 | +EPICS_ATOMIC_INLINE int epicsAtomicIncrIntT ( int * pTarget ); |
341 | |
342 | /* |
343 | * lock out other smp processors from accessing the target, |
344 | @@ -46,8 +48,8 @@ |
345 | * to target, allow out other smp processors to access the target, |
346 | * return new value of target as modified by this operation |
347 | */ |
348 | -epicsShareFunc size_t epicsAtomicDecrSizeT ( size_t * pTarget ); |
349 | -epicsShareFunc int epicsAtomicDecrIntT ( int * pTarget ); |
350 | +EPICS_ATOMIC_INLINE size_t epicsAtomicDecrSizeT ( size_t * pTarget ); |
351 | +EPICS_ATOMIC_INLINE int epicsAtomicDecrIntT ( int * pTarget ); |
352 | |
353 | /* |
354 | * lock out other smp processors from accessing the target, |
355 | @@ -55,23 +57,23 @@ |
356 | * to target, allow other smp processors to access the target, |
357 | * return new value of target as modified by this operation |
358 | */ |
359 | -epicsShareFunc size_t epicsAtomicAddSizeT ( size_t * pTarget, size_t delta ); |
360 | -epicsShareFunc size_t epicsAtomicSubSizeT ( size_t * pTarget, size_t delta ); |
361 | -epicsShareFunc int epicsAtomicAddIntT ( int * pTarget, int delta ); |
362 | +EPICS_ATOMIC_INLINE size_t epicsAtomicAddSizeT ( size_t * pTarget, size_t delta ); |
363 | +EPICS_ATOMIC_INLINE size_t epicsAtomicSubSizeT ( size_t * pTarget, size_t delta ); |
364 | +EPICS_ATOMIC_INLINE int epicsAtomicAddIntT ( int * pTarget, int delta ); |
365 | |
366 | /* |
367 | * set cache version of target, flush cache to target |
368 | */ |
369 | -epicsShareFunc void epicsAtomicSetSizeT ( size_t * pTarget, size_t newValue ); |
370 | -epicsShareFunc void epicsAtomicSetIntT ( int * pTarget, int newValue ); |
371 | -epicsShareFunc void epicsAtomicSetPtrT ( EpicsAtomicPtrT * pTarget, EpicsAtomicPtrT newValue ); |
372 | +EPICS_ATOMIC_INLINE void epicsAtomicSetSizeT ( size_t * pTarget, size_t newValue ); |
373 | +EPICS_ATOMIC_INLINE void epicsAtomicSetIntT ( int * pTarget, int newValue ); |
374 | +EPICS_ATOMIC_INLINE void epicsAtomicSetPtrT ( EpicsAtomicPtrT * pTarget, EpicsAtomicPtrT newValue ); |
375 | |
376 | /* |
377 | * fetch target into cache, return new value of target |
378 | */ |
379 | -epicsShareFunc size_t epicsAtomicGetSizeT ( const size_t * pTarget ); |
380 | -epicsShareFunc int epicsAtomicGetIntT ( const int * pTarget ); |
381 | -epicsShareFunc EpicsAtomicPtrT epicsAtomicGetPtrT ( const EpicsAtomicPtrT * pTarget ); |
382 | +EPICS_ATOMIC_INLINE size_t epicsAtomicGetSizeT ( const size_t * pTarget ); |
383 | +EPICS_ATOMIC_INLINE int epicsAtomicGetIntT ( const int * pTarget ); |
384 | +EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicGetPtrT ( const EpicsAtomicPtrT * pTarget ); |
385 | |
386 | /* |
387 | * lock out other smp processors from accessing the target, |
388 | @@ -80,11 +82,11 @@ |
389 | * to access the target, return the original value stored in the |
390 | * target |
391 | */ |
392 | -epicsShareFunc size_t epicsAtomicCmpAndSwapSizeT ( size_t * pTarget, |
393 | +EPICS_ATOMIC_INLINE size_t epicsAtomicCmpAndSwapSizeT ( size_t * pTarget, |
394 | size_t oldVal, size_t newVal ); |
395 | -epicsShareFunc int epicsAtomicCmpAndSwapIntT ( int * pTarget, |
396 | +EPICS_ATOMIC_INLINE int epicsAtomicCmpAndSwapIntT ( int * pTarget, |
397 | int oldVal, int newVal ); |
398 | -epicsShareFunc EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT ( |
399 | +EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT ( |
400 | EpicsAtomicPtrT * pTarget, |
401 | EpicsAtomicPtrT oldVal, |
402 | EpicsAtomicPtrT newVal ); |
403 | @@ -111,119 +113,98 @@ |
404 | /* |
405 | * overloaded c++ interface |
406 | */ |
407 | -epicsShareFunc size_t increment ( size_t & v ); |
408 | -epicsShareFunc int increment ( int & v ); |
409 | -epicsShareFunc size_t decrement ( size_t & v ); |
410 | -epicsShareFunc int decrement ( int & v ); |
411 | -epicsShareFunc size_t add ( size_t & v, size_t delta ); |
412 | -epicsShareFunc int add ( int & v, int delta ); |
413 | -epicsShareFunc size_t subtract ( size_t & v, size_t delta ); |
414 | -epicsShareFunc int subtract ( int & v, int delta ); |
415 | -epicsShareFunc void set ( size_t & v , size_t newValue ); |
416 | -epicsShareFunc void set ( int & v, int newValue ); |
417 | -epicsShareFunc void set ( EpicsAtomicPtrT & v, |
418 | - EpicsAtomicPtrT newValue ); |
419 | -epicsShareFunc size_t get ( const size_t & v ); |
420 | -epicsShareFunc int get ( const int & v ); |
421 | -epicsShareFunc EpicsAtomicPtrT get ( const EpicsAtomicPtrT & v ); |
422 | -epicsShareFunc size_t compareAndSwap ( size_t & v, size_t oldVal, |
423 | - size_t newVal ); |
424 | -epicsShareFunc int compareAndSwap ( int & v, int oldVal, int newVal ); |
425 | -epicsShareFunc EpicsAtomicPtrT compareAndSwap ( EpicsAtomicPtrT & v, |
426 | - EpicsAtomicPtrT oldVal, |
427 | - EpicsAtomicPtrT newVal ); |
428 | |
429 | /************* incr ***************/ |
430 | -inline size_t increment ( size_t & v ) |
431 | +EPICS_ATOMIC_INLINE size_t increment ( size_t & v ) |
432 | { |
433 | return epicsAtomicIncrSizeT ( & v ); |
434 | } |
435 | |
436 | -inline int increment ( int & v ) |
437 | +EPICS_ATOMIC_INLINE int increment ( int & v ) |
438 | { |
439 | return epicsAtomicIncrIntT ( & v ); |
440 | } |
441 | |
442 | /************* decr ***************/ |
443 | -inline size_t decrement ( size_t & v ) |
444 | +EPICS_ATOMIC_INLINE size_t decrement ( size_t & v ) |
445 | { |
446 | return epicsAtomicDecrSizeT ( & v ); |
447 | } |
448 | |
449 | -inline int decrement ( int & v ) |
450 | +EPICS_ATOMIC_INLINE int decrement ( int & v ) |
451 | { |
452 | return epicsAtomicDecrIntT ( & v ); |
453 | } |
454 | |
455 | /************* add ***************/ |
456 | -inline size_t add ( size_t & v, size_t delta ) |
457 | +EPICS_ATOMIC_INLINE size_t add ( size_t & v, size_t delta ) |
458 | { |
459 | return epicsAtomicAddSizeT ( & v, delta ); |
460 | } |
461 | |
462 | -inline int add ( int & v, int delta ) |
463 | +EPICS_ATOMIC_INLINE int add ( int & v, int delta ) |
464 | { |
465 | return epicsAtomicAddIntT ( & v, delta ); |
466 | } |
467 | |
468 | /************* sub ***************/ |
469 | -inline size_t subtract ( size_t & v, size_t delta ) |
470 | +EPICS_ATOMIC_INLINE size_t subtract ( size_t & v, size_t delta ) |
471 | { |
472 | return epicsAtomicSubSizeT ( & v, delta ); |
473 | } |
474 | |
475 | -inline int subtract ( int & v, int delta ) |
476 | +EPICS_ATOMIC_INLINE int subtract ( int & v, int delta ) |
477 | { |
478 | return epicsAtomicAddIntT ( & v, -delta ); |
479 | } |
480 | |
481 | /************* set ***************/ |
482 | -inline void set ( size_t & v , size_t newValue ) |
483 | +EPICS_ATOMIC_INLINE void set ( size_t & v , size_t newValue ) |
484 | { |
485 | epicsAtomicSetSizeT ( & v, newValue ); |
486 | } |
487 | |
488 | -inline void set ( int & v, int newValue ) |
489 | +EPICS_ATOMIC_INLINE void set ( int & v, int newValue ) |
490 | { |
491 | epicsAtomicSetIntT ( & v, newValue ); |
492 | } |
493 | |
494 | -inline void set ( EpicsAtomicPtrT & v, EpicsAtomicPtrT newValue ) |
495 | +EPICS_ATOMIC_INLINE void set ( EpicsAtomicPtrT & v, EpicsAtomicPtrT newValue ) |
496 | { |
497 | epicsAtomicSetPtrT ( & v, newValue ); |
498 | } |
499 | |
500 | /************* get ***************/ |
501 | -inline size_t get ( const size_t & v ) |
502 | +EPICS_ATOMIC_INLINE size_t get ( const size_t & v ) |
503 | { |
504 | return epicsAtomicGetSizeT ( & v ); |
505 | } |
506 | |
507 | -inline int get ( const int & v ) |
508 | +EPICS_ATOMIC_INLINE int get ( const int & v ) |
509 | { |
510 | return epicsAtomicGetIntT ( & v ); |
511 | } |
512 | |
513 | -inline EpicsAtomicPtrT get ( const EpicsAtomicPtrT & v ) |
514 | +EPICS_ATOMIC_INLINE EpicsAtomicPtrT get ( const EpicsAtomicPtrT & v ) |
515 | { |
516 | return epicsAtomicGetPtrT ( & v ); |
517 | } |
518 | |
519 | /************* cas ***************/ |
520 | -inline size_t compareAndSwap ( size_t & v, |
521 | - size_t oldVal, size_t newVal ) |
522 | +EPICS_ATOMIC_INLINE size_t compareAndSwap ( size_t & v, |
523 | + size_t oldVal, size_t newVal ) |
524 | { |
525 | return epicsAtomicCmpAndSwapSizeT ( & v, oldVal, newVal ); |
526 | } |
527 | |
528 | -inline int compareAndSwap ( int & v, int oldVal, int newVal ) |
529 | +EPICS_ATOMIC_INLINE int compareAndSwap ( int & v, int oldVal, int newVal ) |
530 | { |
531 | return epicsAtomicCmpAndSwapIntT ( & v, oldVal, newVal ); |
532 | } |
533 | |
534 | -inline EpicsAtomicPtrT compareAndSwap ( EpicsAtomicPtrT & v, |
535 | - EpicsAtomicPtrT oldVal, |
536 | - EpicsAtomicPtrT newVal ) |
537 | +EPICS_ATOMIC_INLINE EpicsAtomicPtrT compareAndSwap ( EpicsAtomicPtrT & v, |
538 | + EpicsAtomicPtrT oldVal, |
539 | + EpicsAtomicPtrT newVal ) |
540 | { |
541 | return epicsAtomicCmpAndSwapPtrT ( & v, oldVal, newVal ); |
542 | } |
543 | |
544 | === added file 'src/libCom/osi/os/RTEMS/epicsAtomicOSD.h' |
545 | --- src/libCom/osi/os/RTEMS/epicsAtomicOSD.h 1970-01-01 00:00:00 +0000 |
546 | +++ src/libCom/osi/os/RTEMS/epicsAtomicOSD.h 2015-02-27 22:38:25 +0000 |
547 | @@ -0,0 +1,65 @@ |
548 | + |
549 | +/*************************************************************************\ |
550 | +* Copyright (c) 2011 LANS LLC, as Operator of |
551 | +* Los Alamos National Laboratory. |
552 | +* Copyright (c) 2011 UChicago Argonne LLC, as Operator of Argonne |
553 | +* National Laboratory. |
554 | +* EPICS BASE is distributed subject to a Software License Agreement found |
555 | +* in file LICENSE that is included with this distribution. |
556 | +\*************************************************************************/ |
557 | + |
558 | +/* |
559 | + * Author Jeffrey O. Hill |
560 | + * johill@lanl.gov |
561 | + */ |
562 | + |
563 | +#ifndef epicsAtomicOSD_h |
564 | +#define epicsAtomicOSD_h |
565 | + |
566 | +#include <shareLib.h> |
567 | +#include "epicsMMIO.h" |
568 | +#include "compilerSpecific.h" |
569 | +#include "epicsInterrupt.h" |
570 | + |
571 | +#define EPICS_ATOMIC_OS_NAME "RTEMS" |
572 | + |
573 | +typedef struct EpicsAtomicLockKey { |
574 | + int key; |
575 | +} EpicsAtomicLockKey; |
576 | + |
577 | +#ifdef __cplusplus |
578 | +extern "C" { |
579 | +#endif /* __cplusplus */ |
580 | + |
581 | +#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER |
582 | +EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void) |
583 | +{ |
584 | + epicsAtomicMemoryBarrierFallback(); |
585 | +} |
586 | +#endif |
587 | + |
588 | +#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER |
589 | +EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void) |
590 | +{ |
591 | + rwbarr(); |
592 | +} |
593 | +#endif |
594 | + |
595 | +EPICS_ATOMIC_INLINE void epicsAtomicLock ( struct EpicsAtomicLockKey * pkey ) |
596 | +{ |
597 | + pkey->key = epicsInterruptLock(); |
598 | +} |
599 | + |
600 | +EPICS_ATOMIC_INLINE void epicsAtomicUnlock ( struct EpicsAtomicLockKey * pkey ) |
601 | +{ |
602 | + epicsInterruptUnlock(pkey->key); |
603 | +} |
604 | + |
605 | +#ifdef __cplusplus |
606 | +} /* end of extern "C" */ |
607 | +#endif /* __cplusplus */ |
608 | + |
609 | +#include "epicsAtomicDefault.h" |
610 | + |
611 | +#endif /* epicsAtomicOSD_h */ |
612 | + |
613 | |
614 | === removed file 'src/libCom/osi/os/WIN32/epicsAtomicOSD.cpp' |
615 | --- src/libCom/osi/os/WIN32/epicsAtomicOSD.cpp 2011-09-01 17:25:53 +0000 |
616 | +++ src/libCom/osi/os/WIN32/epicsAtomicOSD.cpp 1970-01-01 00:00:00 +0000 |
617 | @@ -1,22 +0,0 @@ |
618 | - |
619 | -/*************************************************************************\ |
620 | -* Copyright (c) 2011 LANS LLC, as Operator of |
621 | -* Los Alamos National Laboratory. |
622 | -* EPICS BASE is distributed subject to a Software License Agreement found |
623 | -* in file LICENSE that is included with this distribution. |
624 | -\*************************************************************************/ |
625 | - |
626 | -/* |
627 | - * Author Jeffrey O. Hill |
628 | - * johill@lanl.gov |
629 | - */ |
630 | - |
631 | -#define epicsExportSharedSymbols |
632 | -#include "epicsAtomic.h" |
633 | - |
634 | -// if the compiler is unable to inline then instantiate out-of-line |
635 | -#ifndef EPICS_ATOMIC_INLINE |
636 | -# define EPICS_ATOMIC_INLINE |
637 | -# include "epicsAtomicOSD.h" |
638 | -#endif |
639 | - |
640 | |
641 | === modified file 'src/libCom/osi/os/WIN32/epicsAtomicOSD.h' |
642 | --- src/libCom/osi/os/WIN32/epicsAtomicOSD.h 2014-11-19 19:16:56 +0000 |
643 | +++ src/libCom/osi/os/WIN32/epicsAtomicOSD.h 2015-02-27 22:38:25 +0000 |
644 | @@ -16,6 +16,8 @@ |
645 | #ifndef epicsAtomicOSD_h |
646 | #define epicsAtomicOSD_h |
647 | |
648 | +#define EPICS_ATOMIC_OS_NAME "WIN32" |
649 | + |
650 | #ifdef VC_EXTRALEAN |
651 | # define VC_EXTRALEAN_DETECTED_epicsAtomicOSD_h |
652 | #else |
653 | |
654 | === added file 'src/libCom/osi/os/default/epicsAtomicOSD.c' |
655 | === modified file 'src/libCom/osi/os/posix/epicsAtomicOSD.cpp' |
656 | --- src/libCom/osi/os/posix/epicsAtomicOSD.cpp 2013-11-20 17:51:14 +0000 |
657 | +++ src/libCom/osi/os/posix/epicsAtomicOSD.cpp 2015-02-27 22:38:25 +0000 |
658 | @@ -19,14 +19,6 @@ |
659 | #include "epicsAssert.h" |
660 | #include "epicsAtomic.h" |
661 | |
662 | -// if the compiler is unable to inline then instantiate out-of-line |
663 | -#ifndef EPICS_ATOMIC_INLINE |
664 | -# define EPICS_ATOMIC_INLINE |
665 | -# include "epicsAtomicOSD.h" |
666 | -#endif |
667 | - |
668 | -#ifndef EPICS_ATOMIC_LOCK |
669 | - |
670 | /* |
671 | * Slow, but probably correct on all systems. |
672 | * Useful only if something more efficient isn`t |
673 | @@ -69,31 +61,14 @@ |
674 | assert ( status == 0 ); |
675 | } |
676 | |
677 | -#endif // ifndef EPICS_ATOMIC_LOCK |
678 | - |
679 | -#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER |
680 | -// Slow, but probably correct on all systems. |
681 | -// Useful only if something more efficient isn`t |
682 | -// provided based on knowledge of the compiler |
683 | -// or OS |
684 | -void epicsAtomicReadMemoryBarrier () |
685 | -{ |
686 | - EpicsAtomicLockKey key; |
687 | - epicsAtomicLock ( & key ); |
688 | - epicsAtomicUnlock ( & key ); |
689 | -} |
690 | -#endif |
691 | - |
692 | -#ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER |
693 | -// Slow, but probably correct on all systems. |
694 | -// Useful only if something more efficient isn`t |
695 | -// provided based on knowledge of the compiler |
696 | -// or OS |
697 | -void epicsAtomicWriteMemoryBarrier () |
698 | -{ |
699 | - EpicsAtomicLockKey key; |
700 | - epicsAtomicLock ( & key ); |
701 | - epicsAtomicUnlock ( & key ); |
702 | -} |
703 | -#endif |
704 | - |
705 | + |
706 | +// Slow, but probably correct on all systems. |
707 | +// Useful only if something more efficient isn`t |
708 | +// provided based on knowledge of the compiler |
709 | +// or OS |
710 | +void epicsAtomicMemoryBarrierFallback (void) |
711 | +{ |
712 | + EpicsAtomicLockKey key; |
713 | + epicsAtomicLock ( & key ); |
714 | + epicsAtomicUnlock ( & key ); |
715 | +} |
716 | |
717 | === modified file 'src/libCom/osi/os/posix/epicsAtomicOSD.h' |
718 | --- src/libCom/osi/os/posix/epicsAtomicOSD.h 2014-07-25 20:05:58 +0000 |
719 | +++ src/libCom/osi/os/posix/epicsAtomicOSD.h 2015-02-27 22:38:25 +0000 |
720 | @@ -16,14 +16,33 @@ |
721 | #ifndef epicsAtomicOSD_h |
722 | #define epicsAtomicOSD_h |
723 | |
724 | +#include <shareLib.h> |
725 | + |
726 | +#define EPICS_ATOMIC_OS_NAME "POSIX" |
727 | + |
728 | typedef struct EpicsAtomicLockKey {} EpicsAtomicLockKey; |
729 | |
730 | #ifdef __cplusplus |
731 | extern "C" { |
732 | #endif /* __cplusplus */ |
733 | |
734 | +#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER |
735 | +EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void) |
736 | +{ |
737 | + epicsAtomicMemoryBarrierFallback(); |
738 | +} |
739 | +#endif |
740 | + |
741 | +#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER |
742 | +EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void) |
743 | +{ |
744 | + epicsAtomicMemoryBarrierFallback(); |
745 | +} |
746 | +#endif |
747 | + |
748 | epicsShareFunc void epicsAtomicLock ( struct EpicsAtomicLockKey * ); |
749 | epicsShareFunc void epicsAtomicUnlock ( struct EpicsAtomicLockKey * ); |
750 | +epicsShareFunc void epicsAtomicMemoryBarrierFallback ( void ); |
751 | |
752 | #ifdef __cplusplus |
753 | } /* end of extern "C" */ |
754 | |
755 | === modified file 'src/libCom/osi/os/solaris/epicsAtomicOSD.h' |
756 | --- src/libCom/osi/os/solaris/epicsAtomicOSD.h 2014-09-11 14:10:44 +0000 |
757 | +++ src/libCom/osi/os/solaris/epicsAtomicOSD.h 2015-02-27 22:38:25 +0000 |
758 | @@ -13,9 +13,13 @@ |
759 | * johill@lanl.gov |
760 | */ |
761 | |
762 | +#include "shareLib.h" |
763 | + |
764 | #ifndef epicsAtomicOSD_h |
765 | #define epicsAtomicOSD_h |
766 | |
767 | +#define EPICS_ATOMIC_OS_NAME "Solaris" |
768 | + |
769 | #if defined ( __SunOS_5_10 ) |
770 | |
771 | /* |
772 | @@ -31,7 +35,7 @@ |
773 | |
774 | #ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER |
775 | #define EPICS_ATOMIC_READ_MEMORY_BARRIER |
776 | -EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier () |
777 | +EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void) |
778 | { |
779 | membar_consumer (); |
780 | } |
781 | @@ -39,7 +43,7 @@ |
782 | |
783 | #ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER |
784 | #define EPICS_ATOMIC_WRITE_MEMORY_BARRIER |
785 | -EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier () |
786 | +EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void) |
787 | { |
788 | membar_producer (); |
789 | } |
790 | @@ -47,7 +51,7 @@ |
791 | |
792 | #ifndef EPICS_ATOMIC_CAS_INTT |
793 | #define EPICS_ATOMIC_CAS_INTT |
794 | -EPICS_ATOMIC_INLINE int epicsAtomicCmpAndSwapIntT ( int * pTarget, |
795 | +EPICS_ATOMIC_INLINE int epicsAtomicCmpAndSwapIntT ( int * pTarget, |
796 | int oldVal, int newVal ) |
797 | { |
798 | STATIC_ASSERT ( sizeof ( int ) == sizeof ( unsigned ) ); |
799 | @@ -59,7 +63,7 @@ |
800 | |
801 | #ifndef EPICS_ATOMIC_CAS_SIZET |
802 | #define EPICS_ATOMIC_CAS_SIZET |
803 | -EPICS_ATOMIC_INLINE size_t epicsAtomicCmpAndSwapSizeT ( |
804 | +EPICS_ATOMIC_INLINE size_t epicsAtomicCmpAndSwapSizeT ( |
805 | size_t * pTarget, |
806 | size_t oldVal, size_t newVal ) |
807 | { |
808 | @@ -71,7 +75,7 @@ |
809 | |
810 | #ifndef EPICS_ATOMIC_CAS_PTRT |
811 | #define EPICS_ATOMIC_CAS_PTRT |
812 | -EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT ( |
813 | +EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT ( |
814 | EpicsAtomicPtrT * pTarget, |
815 | EpicsAtomicPtrT oldVal, |
816 | EpicsAtomicPtrT newVal ) |
817 | @@ -132,7 +136,7 @@ |
818 | |
819 | #ifndef EPICS_ATOMIC_ADD_SIZET |
820 | #define EPICS_ATOMIC_ADD_SIZET |
821 | -EPICS_ATOMIC_INLINE size_t epicsAtomicAddSizeT ( size_t * pTarget, |
822 | +EPICS_ATOMIC_INLINE size_t epicsAtomicAddSizeT ( size_t * pTarget, |
823 | size_t delta ) |
824 | { |
825 | STATIC_ASSERT ( sizeof ( ulong_t ) == sizeof ( size_t ) ); |
826 | @@ -143,7 +147,7 @@ |
827 | |
828 | #ifndef EPICS_ATOMIC_SUB_SIZET |
829 | #define EPICS_ATOMIC_SUB_SIZET |
830 | -EPICS_ATOMIC_INLINE size_t epicsAtomicSubSizeT ( size_t * pTarget, |
831 | +EPICS_ATOMIC_INLINE size_t epicsAtomicSubSizeT ( size_t * pTarget, |
832 | size_t delta ) |
833 | { |
834 | STATIC_ASSERT ( sizeof ( ulong_t ) == sizeof ( size_t ) ); |
835 | |
836 | === removed file 'src/libCom/osi/os/vxWorks/epicsAtomicOSD.cpp' |
837 | --- src/libCom/osi/os/vxWorks/epicsAtomicOSD.cpp 2011-09-01 17:25:53 +0000 |
838 | +++ src/libCom/osi/os/vxWorks/epicsAtomicOSD.cpp 1970-01-01 00:00:00 +0000 |
839 | @@ -1,21 +0,0 @@ |
840 | - |
841 | -/*************************************************************************\ |
842 | -* Copyright (c) 2011 LANS LLC, as Operator of |
843 | -* Los Alamos National Laboratory. |
844 | -* EPICS BASE is distributed subject to a Software License Agreement found |
845 | -* in file LICENSE that is included with this distribution. |
846 | -\*************************************************************************/ |
847 | - |
848 | -/* |
849 | - * Author Jeffrey O. Hill |
850 | - * johill@lanl.gov |
851 | - */ |
852 | - |
853 | -#define epicsExportSharedSymbols |
854 | -#include "epicsAtomic.h" |
855 | - |
856 | -// if the compiler is unable to inline then instantiate out-of-line |
857 | -#ifndef EPICS_ATOMIC_INLINE |
858 | -# define EPICS_ATOMIC_INLINE |
859 | -# include "epicsAtomicOSD.h" |
860 | -#endif |
861 | |
862 | === modified file 'src/libCom/osi/os/vxWorks/epicsAtomicOSD.h' |
863 | --- src/libCom/osi/os/vxWorks/epicsAtomicOSD.h 2011-09-07 15:59:11 +0000 |
864 | +++ src/libCom/osi/os/vxWorks/epicsAtomicOSD.h 2015-02-27 22:38:25 +0000 |
865 | @@ -32,13 +32,15 @@ |
866 | #include <limits.h> |
867 | #include <vxAtomicLib.h> |
868 | |
869 | +#define EPICS_ATOMIC_OS_NAME "VX-ATOMICLIB" |
870 | + |
871 | #ifdef __cplusplus |
872 | extern "C" { |
873 | #endif /* __cplusplus */ |
874 | |
875 | #ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER |
876 | #define EPICS_ATOMIC_READ_MEMORY_BARRIER |
877 | -EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier () |
878 | +EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void) |
879 | { |
880 | VX_MEM_BARRIER_R (); |
881 | } |
882 | @@ -46,7 +48,7 @@ |
883 | |
884 | #ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER |
885 | #define EPICS_ATOMIC_WRITE_MEMORY_BARRIER |
886 | -EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier () |
887 | +EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void) |
888 | { |
889 | VX_MEM_BARRIER_W (); |
890 | } |
891 | @@ -206,6 +208,8 @@ |
892 | #include "vxLib.h" |
893 | #include "intLib.h" |
894 | |
895 | +#define EPICS_ATOMIC_OS_NAME "VX-INTLIB" |
896 | + |
897 | #ifdef __cplusplus |
898 | extern "C" { |
899 | #endif /* __cplusplus */ |
900 | @@ -232,7 +236,7 @@ |
901 | * no need for memory barrior since prior to vxWorks 6.6 it is a single cpu system |
902 | * (we are not protecting against multiple access to memory mapped IO) |
903 | */ |
904 | -EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier () {} |
905 | +EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void) {} |
906 | #endif |
907 | |
908 | #ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER |
909 | @@ -241,7 +245,7 @@ |
910 | * no need for memory barrior since prior to vxWorks 6.6 it is a single cpu system |
911 | * (we are not protecting against multiple access to memory mapped IO) |
912 | */ |
913 | -EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier () {} |
914 | +EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void) {} |
915 | #endif |
916 | |
917 | #ifdef __cplusplus |
918 | |
919 | === modified file 'src/libCom/test/Makefile' |
920 | --- src/libCom/test/Makefile 2014-10-07 04:39:23 +0000 |
921 | +++ src/libCom/test/Makefile 2015-02-27 22:38:25 +0000 |
922 | @@ -22,6 +22,14 @@ |
923 | testHarness_SRCS += epicsTypesTest.cpp |
924 | TESTS += epicsTypesTest |
925 | |
926 | +TESTPROD_HOST += epicsInlineTest |
927 | +epicsInlineTest_SRCS += epicsInlineTest1.c |
928 | +epicsInlineTest_SRCS += epicsInlineTest2.c |
929 | +epicsInlineTest_SRCS += epicsInlineTest3.cpp |
930 | +epicsInlineTest_SRCS += epicsInlineTest4.cpp |
931 | +testHarness_SRCS += $(epicsInlineTest_SRCS) |
932 | +TESTS += epicsInlineTest |
933 | + |
934 | TESTPROD_HOST += epicsCalcTest |
935 | epicsCalcTest_SRCS += epicsCalcTest.cpp |
936 | testHarness_SRCS += epicsCalcTest.cpp |
937 | |
938 | === modified file 'src/libCom/test/epicsAtomicTest.cpp' |
939 | --- src/libCom/test/epicsAtomicTest.cpp 2012-06-07 18:38:11 +0000 |
940 | +++ src/libCom/test/epicsAtomicTest.cpp 2015-02-27 22:38:25 +0000 |
941 | @@ -248,11 +248,89 @@ |
942 | # pragma warning ( pop ) |
943 | #endif |
944 | |
945 | +static void testClassify() |
946 | +{ |
947 | + testDiag("Classify Build conditions"); |
948 | +#ifdef EPICS_ATOMIC_CMPLR_NAME |
949 | + testDiag("Compiler dependent impl name %s", EPICS_ATOMIC_CMPLR_NAME); |
950 | +#else |
951 | + testDiag("Compiler dependent impl name undefined"); |
952 | +#endif |
953 | +#ifdef EPICS_ATOMIC_OS_NAME |
954 | + testDiag("OS dependent impl name %s", EPICS_ATOMIC_OS_NAME); |
955 | +#else |
956 | + testDiag("OS dependent impl name undefined"); |
957 | +#endif |
958 | + |
959 | +#ifdef __GNUC__ |
960 | +#if GCC_ATOMIC_INTRINSICS_GCC4_OR_BETTER |
961 | + testDiag("GCC using atomic builtin memory barrier"); |
962 | +#else |
963 | + testDiag("GCC using asm memory barrier"); |
964 | +#endif |
965 | +#if GCC_ATOMIC_INTRINSICS_AVAIL_INT_T || GCC_ATOMIC_INTRINSICS_AVAIL_EARLIER |
966 | + testDiag("GCC use builtin for int"); |
967 | +#endif |
968 | +#if GCC_ATOMIC_INTRINSICS_AVAIL_SIZE_T || GCC_ATOMIC_INTRINSICS_AVAIL_EARLIER |
969 | + testDiag("GCC use builtin for size_t"); |
970 | +#endif |
971 | + |
972 | +#ifndef EPICS_ATOMIC_INCR_INTT |
973 | + testDiag("Use default epicsAtomicIncrIntT()"); |
974 | +#endif |
975 | +#ifndef EPICS_ATOMIC_INCR_SIZET |
976 | + testDiag("Use default epicsAtomicIncrSizeT()"); |
977 | +#endif |
978 | +#ifndef EPICS_ATOMIC_DECR_INTT |
979 | + testDiag("Use default epicsAtomicDecrIntT()"); |
980 | +#endif |
981 | +#ifndef EPICS_ATOMIC_DECR_SIZET |
982 | + testDiag("Use default epicsAtomicDecrSizeT()"); |
983 | +#endif |
984 | +#ifndef EPICS_ATOMIC_ADD_INTT |
985 | + testDiag("Use default epicsAtomicAddIntT()"); |
986 | +#endif |
987 | +#ifndef EPICS_ATOMIC_ADD_SIZET |
988 | + testDiag("Use default epicsAtomicAddSizeT()"); |
989 | +#endif |
990 | +#ifndef EPICS_ATOMIC_SUB_SIZET |
991 | + testDiag("Use default epicsAtomicSubSizeT()"); |
992 | +#endif |
993 | +#ifndef EPICS_ATOMIC_SET_INTT |
994 | + testDiag("Use default epicsAtomicSetIntT()"); |
995 | +#endif |
996 | +#ifndef EPICS_ATOMIC_SET_SIZET |
997 | + testDiag("Use default epicsAtomicSetSizeT()"); |
998 | +#endif |
999 | +#ifndef EPICS_ATOMIC_SET_PTRT |
1000 | + testDiag("Use default epicsAtomicSetPtrT()"); |
1001 | +#endif |
1002 | +#ifndef EPICS_ATOMIC_GET_INTT |
1003 | + testDiag("Use default epicsAtomicGetIntT()"); |
1004 | +#endif |
1005 | +#ifndef EPICS_ATOMIC_GET_SIZET |
1006 | + testDiag("Use default epicsAtomicGetSizeT()"); |
1007 | +#endif |
1008 | +#ifndef EPICS_ATOMIC_GET_PTRT |
1009 | + testDiag("Use default epicsAtomicGetPtrT()"); |
1010 | +#endif |
1011 | +#ifndef EPICS_ATOMIC_CAS_INTT |
1012 | + testDiag("Use default epicsAtomicCmpAndSwapIntT()"); |
1013 | +#endif |
1014 | +#ifndef EPICS_ATOMIC_CAS_SIZET |
1015 | + testDiag("Use default epicsAtomicCmpAndSwapSizeT()"); |
1016 | +#endif |
1017 | +#ifndef EPICS_ATOMIC_CAS_PTRT |
1018 | + testDiag("Use default epicsAtomicCmpAndSwapPtrT()"); |
1019 | +#endif |
1020 | +#endif /* __GNUC__ */ |
1021 | +} |
1022 | |
1023 | MAIN ( epicsAtomicTest ) |
1024 | { |
1025 | |
1026 | testPlan ( 31 ); |
1027 | + testClassify (); |
1028 | |
1029 | testIncrDecr < int > (); |
1030 | testIncrDecr < size_t > (); |
1031 | |
1032 | === added file 'src/libCom/test/epicsInlineTest1.c' |
1033 | --- src/libCom/test/epicsInlineTest1.c 1970-01-01 00:00:00 +0000 |
1034 | +++ src/libCom/test/epicsInlineTest1.c 2015-02-27 22:38:25 +0000 |
1035 | @@ -0,0 +1,64 @@ |
1036 | +/*************************************************************************\ |
1037 | +* Copyright (c) 2015 Brookhaven Science Associates, as Operator of |
1038 | +* Brookhaven National Laboratory. |
1039 | +* EPICS BASE is distributed subject to a Software License Agreement found |
1040 | +* in file LICENSE that is included with this distribution. |
1041 | +\*************************************************************************/ |
1042 | + |
1043 | +/* This test checks the variations on inline function defintions. |
1044 | + * |
1045 | + * "static inline int func(void) {...}" |
1046 | + * |
1047 | + * Consistent meaning in C89, C99, and C++ (98 and 11). |
1048 | + * If not inline'd results in a private symbol in each compilation unit. |
1049 | + * Thus the non-inline'd version is duplicated in each compilation unit. |
1050 | + * However, definitions in different compilation units may be different. |
1051 | + * |
1052 | + * "inline int func(void) {...}" |
1053 | + * Warning: Not consistent, avoid use in headers meant for C or C++ |
1054 | + * |
1055 | + * In C++ this may be safely defined in more than one compilation unit. |
1056 | + * Where not inlined it will result in a weak public symbol. |
1057 | + * Thus non-inline'd version isn't duplicated, but must be the same |
1058 | + * in all compilation units. |
1059 | + * |
1060 | + */ |
1061 | + |
1062 | +#include "compilerSpecific.h" |
1063 | +#include "epicsUnitTest.h" |
1064 | + |
1065 | +#include "testMain.h" |
1066 | + |
1067 | +static EPICS_ALWAYS_INLINE int epicsInlineTestFn1(void) |
1068 | +{ |
1069 | + return 1; |
1070 | +} |
1071 | + |
1072 | +/* Fails to link in C99 |
1073 | +inline int epicsInlineTestFn2(void) |
1074 | +{ |
1075 | + return 42; |
1076 | +} |
1077 | +*/ |
1078 | + |
1079 | +void epicsInlineTest1(void) |
1080 | +{ |
1081 | + testDiag("epicsInlineTest1()"); |
1082 | + testOk1(epicsInlineTestFn1()==1); |
1083 | + /*testOk1(epicsInlineTestFn2()==42);*/ |
1084 | +} |
1085 | + |
1086 | +void epicsInlineTest2(void); |
1087 | +void epicsInlineTest3(void); |
1088 | +void epicsInlineTest4(void); |
1089 | + |
1090 | +MAIN(epicsInlineTest) |
1091 | +{ |
1092 | + testPlan(6); |
1093 | + testDiag("Test variation on inline int func()"); |
1094 | + epicsInlineTest1(); |
1095 | + epicsInlineTest2(); |
1096 | + epicsInlineTest3(); |
1097 | + epicsInlineTest4(); |
1098 | + return testDone(); |
1099 | +} |
1100 | |
1101 | === added file 'src/libCom/test/epicsInlineTest2.c' |
1102 | --- src/libCom/test/epicsInlineTest2.c 1970-01-01 00:00:00 +0000 |
1103 | +++ src/libCom/test/epicsInlineTest2.c 2015-02-27 22:38:25 +0000 |
1104 | @@ -0,0 +1,28 @@ |
1105 | +/*************************************************************************\ |
1106 | +* Copyright (c) 2015 Brookhaven Science Associates, as Operator of |
1107 | +* Brookhaven National Laboratory. |
1108 | +* EPICS BASE is distributed subject to a Software License Agreement found |
1109 | +* in file LICENSE that is included with this distribution. |
1110 | +\*************************************************************************/ |
1111 | + |
1112 | +#include "compilerSpecific.h" |
1113 | +#include "epicsUnitTest.h" |
1114 | + |
1115 | +static EPICS_ALWAYS_INLINE int epicsInlineTestFn1(void) |
1116 | +{ |
1117 | + return 2; |
1118 | +} |
1119 | + |
1120 | +/* Fails to link in C99 |
1121 | +inline int epicsInlineTestFn2(void) |
1122 | +{ |
1123 | + return 42; |
1124 | +} |
1125 | +*/ |
1126 | + |
1127 | +void epicsInlineTest2(void) |
1128 | +{ |
1129 | + testDiag("epicsInlineTest2()"); |
1130 | + testOk1(epicsInlineTestFn1()==2); |
1131 | + /*testOk1(epicsInlineTestFn2()==42);*/ |
1132 | +} |
1133 | |
1134 | === added file 'src/libCom/test/epicsInlineTest3.cpp' |
1135 | --- src/libCom/test/epicsInlineTest3.cpp 1970-01-01 00:00:00 +0000 |
1136 | +++ src/libCom/test/epicsInlineTest3.cpp 2015-02-27 22:38:25 +0000 |
1137 | @@ -0,0 +1,27 @@ |
1138 | +/*************************************************************************\ |
1139 | +* Copyright (c) 2015 Brookhaven Science Associates, as Operator of |
1140 | +* Brookhaven National Laboratory. |
1141 | +* EPICS BASE is distributed subject to a Software License Agreement found |
1142 | +* in file LICENSE that is included with this distribution. |
1143 | +\*************************************************************************/ |
1144 | + |
1145 | +#include "compilerSpecific.h" |
1146 | +#include "epicsUnitTest.h" |
1147 | + |
1148 | +static EPICS_ALWAYS_INLINE int epicsInlineTestFn1(void) |
1149 | +{ |
1150 | + return 3; |
1151 | +} |
1152 | + |
1153 | +inline int epicsInlineTestFn2(void) |
1154 | +{ |
1155 | + return 42; |
1156 | +} |
1157 | + |
1158 | +extern "C" |
1159 | +void epicsInlineTest3(void) |
1160 | +{ |
1161 | + testDiag("epicsInlineTest3()"); |
1162 | + testOk1(epicsInlineTestFn1()==3); |
1163 | + testOk1(epicsInlineTestFn2()==42); |
1164 | +} |
1165 | |
1166 | === added file 'src/libCom/test/epicsInlineTest4.cpp' |
1167 | --- src/libCom/test/epicsInlineTest4.cpp 1970-01-01 00:00:00 +0000 |
1168 | +++ src/libCom/test/epicsInlineTest4.cpp 2015-02-27 22:38:25 +0000 |
1169 | @@ -0,0 +1,27 @@ |
1170 | +/*************************************************************************\ |
1171 | +* Copyright (c) 2015 Brookhaven Science Associates, as Operator of |
1172 | +* Brookhaven National Laboratory. |
1173 | +* EPICS BASE is distributed subject to a Software License Agreement found |
1174 | +* in file LICENSE that is included with this distribution. |
1175 | +\*************************************************************************/ |
1176 | + |
1177 | +#include "compilerSpecific.h" |
1178 | +#include "epicsUnitTest.h" |
1179 | + |
1180 | +static EPICS_ALWAYS_INLINE int epicsInlineTestFn1(void) |
1181 | +{ |
1182 | + return 4; |
1183 | +} |
1184 | + |
1185 | +inline int epicsInlineTestFn2(void) |
1186 | +{ |
1187 | + return 42; |
1188 | +} |
1189 | + |
1190 | +extern "C" |
1191 | +void epicsInlineTest4(void) |
1192 | +{ |
1193 | + testDiag("epicsInlineTest4()"); |
1194 | + testOk1(epicsInlineTestFn1()==4); |
1195 | + testOk1(epicsInlineTestFn2()==42); |
1196 | +} |
1197 | |
1198 | === modified file 'src/libCom/test/epicsRunLibComTests.c' |
1199 | --- src/libCom/test/epicsRunLibComTests.c 2014-10-07 04:39:23 +0000 |
1200 | +++ src/libCom/test/epicsRunLibComTests.c 2015-02-27 22:38:25 +0000 |
1201 | @@ -44,6 +44,7 @@ |
1202 | int epicsTimerTest(void); |
1203 | int epicsTimeTest(void); |
1204 | int epicsTypesTest(void); |
1205 | +int epicsInlineTest(void); |
1206 | int macDefExpandTest(void); |
1207 | int macLibTest(void); |
1208 | int ringBytesTest(void); |
1209 | @@ -92,6 +93,7 @@ |
1210 | runTest(epicsThreadPrivateTest); |
1211 | runTest(epicsTimeTest); |
1212 | runTest(epicsTypesTest); |
1213 | + runTest(epicsInlineTest); |
1214 | runTest(macDefExpandTest); |
1215 | runTest(macLibTest); |
1216 | runTest(ringBytesTest); |
I think this is complete. However, I can only test with GCC on Linux and RTEMS.