Merge lp:~epics-core/epics-base/fixatomiclinkage into lp:~epics-core/epics-base/3.16

Proposed by mdavidsaver
Status: Superseded
Proposed branch: lp:~epics-core/epics-base/fixatomiclinkage
Merge into: lp:~epics-core/epics-base/3.16
Diff against target: 1249 lines (+484/-201)
27 files modified
configure/RULES_BUILD (+5/-4)
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
Reviewer Review Type Date Requested Status
Andrew Johnson Approve
Ralph Lange Approve
mdavidsaver Approve
Review via email: mp+250813@code.launchpad.net

This proposal has been superseded by a proposal from 2015-02-27.

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.

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

I think this is complete. However, I can only test with GCC on Linux and RTEMS.

review: Approve
Revision history for this message
Ralph Lange (ralph-lange) wrote :

From looking at the code and running the test: yep.

I am even more restricted than Michael in testing envs, though.

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

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:

"../../../src/libCom/osi/compiler/solStudio/compilerSpecific.h", line 20: Error: #error Not Solaris Studio.

I'll investigate further tomorrow (and run tests on VxWorks, Darwin and Windows), I have this afternoon off.

review: Needs Fixing
Revision history for this message
mdavidsaver (mdavidsaver) wrote :

> 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.

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

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__((always_inline)).

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.

review: Approve
12632. By mdavidsaver

add EPICS_ALWAYS_INLINE

12633. By mdavidsaver

libCom/test: Add epicsInlineTest

12634. By mdavidsaver

epicsAtomic: fix C linkage

With gcc -std=gnu99 (present default) functions qualified
with plain 'inline' emit strong public symbols (nm says 'T')
in every compilation unit the definition appears.
This causes linking to fail in all cases where executable
are statically linked, and many where dynamic linking is used.

12635. By mdavidsaver

epicsAtomicTest: include some information about build conditions

Give some idea which implementations are being used

12636. By mdavidsaver

epicsAtomic: RTEMS ISR safe impl. for epicsAtomicLock()

12637. By mdavidsaver

Fix for Solaris C++ compiler

12638. By mdavidsaver

Fix typo in epicsAtomicTest.cpp testClassify()

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'configure/RULES_BUILD'
--- configure/RULES_BUILD 2015-02-04 17:39:26 +0000
+++ configure/RULES_BUILD 2015-02-27 22:36:36 +0000
@@ -94,7 +94,7 @@
94# Read dependency files94# Read dependency files
9595
96ifneq (,$(strip $(HDEPENDS_FILES)))96ifneq (,$(strip $(HDEPENDS_FILES)))
97$(filter-out $(wildcard *$(DEP)), $(HDEPENDS_FILES)): $(COMMON_INC)97$(filter-out $(wildcard *$(DEP)), $(HDEPENDS_FILES)): | $(COMMON_INC)
98-include $(HDEPENDS_FILES)98-include $(HDEPENDS_FILES)
99endif99endif
100100
@@ -215,15 +215,16 @@
215%.o : %.cc215%.o : %.cc
216%.o : %.cpp216%.o : %.cpp
217217
218%$(OBJ): %.c $(COMMON_INC) $(INSTALL_INC)218# Include files are order-only prerequisites for compilation:
219%$(OBJ): %.c | $(COMMON_INC) $(INSTALL_INC)
219 @$(RM) $@220 @$(RM) $@
220 $(COMPILE.c) -c $<221 $(COMPILE.c) -c $<
221222
222%$(OBJ): %.cc $(COMMON_INC) $(INSTALL_INC)223%$(OBJ): %.cc | $(COMMON_INC) $(INSTALL_INC)
223 @$(RM) $@224 @$(RM) $@
224 $(COMPILE.cpp) -c $<225 $(COMPILE.cpp) -c $<
225226
226%$(OBJ): %.cpp $(COMMON_INC) $(INSTALL_INC)227%$(OBJ): %.cpp | $(COMMON_INC) $(INSTALL_INC)
227 @$(RM) $@228 @$(RM) $@
228 $(COMPILE.cpp) -c $<229 $(COMPILE.cpp) -c $<
229230
230231
=== modified file 'src/libCom/osi/compiler/clang/compilerSpecific.h'
--- src/libCom/osi/compiler/clang/compilerSpecific.h 2014-02-21 00:05:42 +0000
+++ src/libCom/osi/compiler/clang/compilerSpecific.h 2015-02-27 22:36:36 +0000
@@ -20,6 +20,12 @@
20# error compiler/clang/compilerSpecific.h is only for use with the clang compiler20# error compiler/clang/compilerSpecific.h is only for use with the clang compiler
21#endif21#endif
2222
23#if __has_attribute(always_inline)
24#define EPICS_ALWAYS_INLINE __inline__ __attribute__((always_inline))
25#else
26#define EPICS_ALWAYS_INLINE __inline__
27#endif
28
23#ifdef __cplusplus29#ifdef __cplusplus
2430
25/*31/*
2632
=== modified file 'src/libCom/osi/compiler/clang/epicsAtomicCD.h'
--- src/libCom/osi/compiler/clang/epicsAtomicCD.h 2011-09-01 17:25:53 +0000
+++ src/libCom/osi/compiler/clang/epicsAtomicCD.h 2015-02-27 22:36:36 +0000
@@ -16,16 +16,8 @@
16#ifndef epicsAtomicCD_h16#ifndef epicsAtomicCD_h
17#define epicsAtomicCD_h17#define epicsAtomicCD_h
1818
19#if defined ( __cplusplus )19#define EPICS_ATOMIC_CMPLR_NAME "CLANG"
20# define EPICS_ATOMIC_INLINE inline
21#else
22# define EPICS_ATOMIC_INLINE __inline__
23#endif
2420
25/*
26 * we have an inline keyword so we can proceed
27 * with an os specific inline instantiation
28 */
29#include "epicsAtomicOSD.h"21#include "epicsAtomicOSD.h"
3022
31#endif /* epicsAtomicCD_h */23#endif /* epicsAtomicCD_h */
3224
=== modified file 'src/libCom/osi/compiler/default/compilerSpecific.h'
--- src/libCom/osi/compiler/default/compilerSpecific.h 2011-08-31 22:35:18 +0000
+++ src/libCom/osi/compiler/default/compilerSpecific.h 2015-02-27 22:36:36 +0000
@@ -15,6 +15,14 @@
1515
16#ifndef compilerSpecific_h16#ifndef compilerSpecific_h
17#define compilerSpecific_h17#define compilerSpecific_h
18
19/* The 'inline' key work, possibily with compiler
20 * dependent flags to force inlineing where it would
21 * otherwise not be done.
22 *
23 * Warning: Second guessing the compiler may result in larger code size
24 */
25#define EPICS_ALWAYS_INLINE inline
18 26
19#ifdef __cplusplus27#ifdef __cplusplus
2028
2129
=== modified file 'src/libCom/osi/compiler/default/epicsAtomicCD.h'
--- src/libCom/osi/compiler/default/epicsAtomicCD.h 2011-09-01 17:25:53 +0000
+++ src/libCom/osi/compiler/default/epicsAtomicCD.h 2015-02-27 22:36:36 +0000
@@ -16,15 +16,8 @@
16#ifndef epicsAtomicCD_h16#ifndef epicsAtomicCD_h
17#define epicsAtomicCD_h17#define epicsAtomicCD_h
1818
19#if __STDC_VERSION__ >= 199901L || defined ( __cplusplus )19#define EPICS_ATOMIC_CMPLR_NAME "DEFAULT"
20# define EPICS_ATOMIC_INLINE inline20
21 /*21#include "epicsAtomicOSD.h"
22 * We have already defined the public interface in epicsAtomic.h
23 * so there is nothing more to implement if there isnt an inline
24 * keyword available. Otherwise, if we have an inline keyword
25 * we will proceed with an os specific inline implementation.
26 */
27# include "epicsAtomicOSD.h"
28#endif
2922
30#endif /* epicsAtomicCD_h */23#endif /* epicsAtomicCD_h */
3124
=== modified file 'src/libCom/osi/compiler/gcc/compilerSpecific.h'
--- src/libCom/osi/compiler/gcc/compilerSpecific.h 2014-02-21 00:05:42 +0000
+++ src/libCom/osi/compiler/gcc/compilerSpecific.h 2015-02-27 22:36:36 +0000
@@ -23,6 +23,12 @@
23#ifdef __clang__23#ifdef __clang__
24# error compiler/gcc/compilerSpecific.h is not for use with the clang compiler24# error compiler/gcc/compilerSpecific.h is not for use with the clang compiler
25#endif25#endif
26
27#if __GNUC__ > 2
28# define EPICS_ALWAYS_INLINE __inline__ __attribute__((always_inline))
29#else
30# define EPICS_ALWAYS_INLINE __inline__
31#endif
26 32
27#ifdef __cplusplus33#ifdef __cplusplus
2834
2935
=== modified file 'src/libCom/osi/compiler/gcc/epicsAtomicCD.h'
--- src/libCom/osi/compiler/gcc/epicsAtomicCD.h 2013-11-21 00:55:44 +0000
+++ src/libCom/osi/compiler/gcc/epicsAtomicCD.h 2015-02-27 22:36:36 +0000
@@ -20,7 +20,7 @@
20# error this header is only for use with the gnu compiler20# error this header is only for use with the gnu compiler
21#endif21#endif
2222
23#define EPICS_ATOMIC_INLINE __inline__23#define EPICS_ATOMIC_CMPLR_NAME "GCC"
2424
25#define GCC_ATOMIC_CONCAT( A, B ) GCC_ATOMIC_CONCATR(A,B)25#define GCC_ATOMIC_CONCAT( A, B ) GCC_ATOMIC_CONCATR(A,B)
26#define GCC_ATOMIC_CONCATR( A, B ) ( A ## B )26#define GCC_ATOMIC_CONCATR( A, B ) ( A ## B )
@@ -69,7 +69,7 @@
6969
70#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER70#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER
71#define EPICS_ATOMIC_READ_MEMORY_BARRIER71#define EPICS_ATOMIC_READ_MEMORY_BARRIER
72EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier ()72EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void)
73{73{
74 __sync_synchronize ();74 __sync_synchronize ();
75}75}
@@ -77,7 +77,7 @@
7777
78#ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER78#ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER
79#define EPICS_ATOMIC_WRITE_MEMORY_BARRIER79#define EPICS_ATOMIC_WRITE_MEMORY_BARRIER
80EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier ()80EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void)
81{81{
82 __sync_synchronize ();82 __sync_synchronize ();
83}83}
@@ -88,7 +88,7 @@
88#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER88#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER
89#if GCC_ATOMIC_INTRINSICS_MIN_X8689#if GCC_ATOMIC_INTRINSICS_MIN_X86
90#define EPICS_ATOMIC_READ_MEMORY_BARRIER90#define EPICS_ATOMIC_READ_MEMORY_BARRIER
91EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier ()91EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void)
92{92{
93 asm("mfence;");93 asm("mfence;");
94}94}
@@ -98,7 +98,7 @@
98#ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER98#ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER
99#if GCC_ATOMIC_INTRINSICS_MIN_X8699#if GCC_ATOMIC_INTRINSICS_MIN_X86
100#define EPICS_ATOMIC_WRITE_MEMORY_BARRIER100#define EPICS_ATOMIC_WRITE_MEMORY_BARRIER
101EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier ()101EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void)
102{102{
103 asm("mfence;");103 asm("mfence;");
104}104}
105105
=== modified file 'src/libCom/osi/compiler/msvc/compilerSpecific.h'
--- src/libCom/osi/compiler/msvc/compilerSpecific.h 2011-08-31 22:35:18 +0000
+++ src/libCom/osi/compiler/msvc/compilerSpecific.h 2015-02-27 22:36:36 +0000
@@ -20,6 +20,12 @@
20# error compiler/msvc/compilerSpecific.h is only for use with the Microsoft compiler20# error compiler/msvc/compilerSpecific.h is only for use with the Microsoft compiler
21#endif21#endif
2222
23#if _MSC_VER >= 1200
24#define EPICS_ALWAYS_INLINE __forceinline
25#else
26#define EPICS_ALWAYS_INLINE __inline
27#endif
28
23#ifdef __cplusplus29#ifdef __cplusplus
2430
25/*31/*
2632
=== modified file 'src/libCom/osi/compiler/msvc/epicsAtomicCD.h'
--- src/libCom/osi/compiler/msvc/epicsAtomicCD.h 2011-09-01 17:25:53 +0000
+++ src/libCom/osi/compiler/msvc/epicsAtomicCD.h 2015-02-27 22:36:36 +0000
@@ -24,18 +24,14 @@
2424
25#ifdef _MSC_EXTENSIONS25#ifdef _MSC_EXTENSIONS
2626
27#define EPICS_ATOMIC_CMPLR_NAME "MSVC-INTRINSIC"
28
27#include <intrin.h>29#include <intrin.h>
2830
29#if _MSC_VER >= 1200
30# define EPICS_ATOMIC_INLINE __forceinline
31#else
32# define EPICS_ATOMIC_INLINE __inline
33#endif
34
35#if defined ( _M_IX86 )31#if defined ( _M_IX86 )
36# pragma warning( push )32# pragma warning( push )
37# pragma warning( disable : 4793 )33# pragma warning( disable : 4793 )
38 EPICS_ATOMIC_INLINE void epicsAtomicMemoryBarrier ()34 EPICS_ATOMIC_INLINE void epicsAtomicMemoryBarrier (void)
39 {35 {
40 long fence;36 long fence;
41 __asm { xchg fence, eax }37 __asm { xchg fence, eax }
@@ -44,14 +40,14 @@
44#elif defined ( _M_X64 )40#elif defined ( _M_X64 )
45# define MS_ATOMIC_6441# define MS_ATOMIC_64
46# pragma intrinsic ( __faststorefence )42# pragma intrinsic ( __faststorefence )
47 EPICS_ATOMIC_INLINE void epicsAtomicMemoryBarrier () 43 EPICS_ATOMIC_INLINE void epicsAtomicMemoryBarrier (void)
48 { 44 {
49 __faststorefence ();45 __faststorefence ();
50 }46 }
51#elif defined ( _M_IA64 )47#elif defined ( _M_IA64 )
52# define MS_ATOMIC_6448# define MS_ATOMIC_64
53# pragma intrinsic ( __mf )49# pragma intrinsic ( __mf )
54 EPICS_ATOMIC_INLINE void epicsAtomicMemoryBarrier () 50 EPICS_ATOMIC_INLINE void epicsAtomicMemoryBarrier (void)
55 { 51 {
56 __mf (); 52 __mf ();
57 }53 }
@@ -88,13 +84,13 @@
88#endif /* __cplusplus */84#endif /* __cplusplus */
8985
90#define EPICS_ATOMIC_READ_MEMORY_BARRIER86#define EPICS_ATOMIC_READ_MEMORY_BARRIER
91EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier ()87EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void)
92{88{
93 epicsAtomicMemoryBarrier ();89 epicsAtomicMemoryBarrier ();
94}90}
9591
96#define EPICS_ATOMIC_WRITE_MEMORY_BARRIER92#define EPICS_ATOMIC_WRITE_MEMORY_BARRIER
97EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier ()93EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void)
98{94{
99 epicsAtomicMemoryBarrier ();95 epicsAtomicMemoryBarrier ();
100}96}
@@ -108,9 +104,7 @@
108104
109#else /* ifdef _MSC_EXTENSIONS */105#else /* ifdef _MSC_EXTENSIONS */
110106
111#if defined ( __cplusplus )107#define EPICS_ATOMIC_CMPLR_NAME "MSVC-DIRECT"
112# define EPICS_ATOMIC_INLINE inline
113#endif
114108
115/* 109/*
116 * if unavailable as an intrinsic we will try110 * if unavailable as an intrinsic we will try
117111
=== added file 'src/libCom/osi/compiler/solStudio/compilerSpecific.h'
--- src/libCom/osi/compiler/solStudio/compilerSpecific.h 1970-01-01 00:00:00 +0000
+++ src/libCom/osi/compiler/solStudio/compilerSpecific.h 2015-02-27 22:36:36 +0000
@@ -0,0 +1,44 @@
1/*************************************************************************\
2* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne
3* National Laboratory.
4* Copyright (c) 2002 The Regents of the University of California, as
5* Operator of Los Alamos National Laboratory.
6* EPICS BASE is distributed subject to a Software License Agreement found
7* in file LICENSE that is included with this distribution.
8\*************************************************************************/
9
10/*
11 * Author:
12 * Jeffrey O. Hill
13 * johill@lanl.gov
14 */
15
16#ifndef compilerSpecific_h
17#define compilerSpecific_h
18
19#if !defined(__SUNPRO_C) && !defined (__SUNPRO_CC)
20# error Not Solaris Studio
21#endif
22
23#if (defined(__SUNPRO_C) && __SUNPRO_C < 0x590) || \
24 (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
25# define EPICS_ALWAYS_INLINE inline
26#else
27# define EPICS_ALWAYS_INLINE inline __attribute__((always_inline))
28#endif
29
30#ifdef __cplusplus
31
32/*
33 * CXX_PLACEMENT_DELETE - defined if compiler supports placement delete
34 * CXX_THROW_SPECIFICATION - defined if compiler supports throw specification
35 *
36 * (our default guess is that the compiler implements the C++ 97 standard)
37 */
38#define CXX_THROW_SPECIFICATION
39#define CXX_PLACEMENT_DELETE
40
41#endif /* __cplusplus */
42
43
44#endif /* ifndef compilerSpecific_h */
045
=== modified file 'src/libCom/osi/compiler/solStudio/epicsAtomicCD.h'
--- src/libCom/osi/compiler/solStudio/epicsAtomicCD.h 2011-09-01 17:25:53 +0000
+++ src/libCom/osi/compiler/solStudio/epicsAtomicCD.h 2015-02-27 22:36:36 +0000
@@ -16,16 +16,8 @@
16#ifndef epicsAtomicCD_h16#ifndef epicsAtomicCD_h
17#define epicsAtomicCD_h17#define epicsAtomicCD_h
1818
19#if defined ( __cplusplus )19#define EPICS_ATOMIC_CMPLR_NAME "SOLSTUDIO"
20# define EPICS_ATOMIC_INLINE inline
21#else
22# define EPICS_ATOMIC_INLINE __inline
23#endif
2420
25/*
26 * we have an inline keyword so we can proceed
27 * with an os specific inline instantiation
28 */
29#include "epicsAtomicOSD.h"21#include "epicsAtomicOSD.h"
3022
31#endif /* epicsAtomicCD_h */23#endif /* epicsAtomicCD_h */
3224
=== modified file 'src/libCom/osi/epicsAtomic.h'
--- src/libCom/osi/epicsAtomic.h 2013-11-20 17:51:14 +0000
+++ src/libCom/osi/epicsAtomic.h 2015-02-27 22:36:36 +0000
@@ -17,7 +17,9 @@
1717
18#include <stdlib.h> /* define size_t */18#include <stdlib.h> /* define size_t */
1919
20#include "shareLib.h"20#include "compilerSpecific.h"
21
22#define EPICS_ATOMIC_INLINE static EPICS_ALWAYS_INLINE
2123
22#ifdef __cplusplus24#ifdef __cplusplus
23extern "C" {25extern "C" {
@@ -26,10 +28,10 @@
26typedef void * EpicsAtomicPtrT;28typedef void * EpicsAtomicPtrT;
2729
28/* load target into cache */30/* load target into cache */
29epicsShareFunc void epicsAtomicReadMemoryBarrier ();31EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void);
3032
31/* push cache version of target into target */33/* push cache version of target into target */
32epicsShareFunc void epicsAtomicWriteMemoryBarrier ();34EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void);
3335
34/*36/*
35 * lock out other smp processors from accessing the target,37 * lock out other smp processors from accessing the target,
@@ -37,8 +39,8 @@
37 * to target, allow other smp processors to access the target,39 * to target, allow other smp processors to access the target,
38 * return new value of target as modified by this operation40 * return new value of target as modified by this operation
39 */41 */
40epicsShareFunc size_t epicsAtomicIncrSizeT ( size_t * pTarget );42EPICS_ATOMIC_INLINE size_t epicsAtomicIncrSizeT ( size_t * pTarget );
41epicsShareFunc int epicsAtomicIncrIntT ( int * pTarget );43EPICS_ATOMIC_INLINE int epicsAtomicIncrIntT ( int * pTarget );
4244
43/*45/*
44 * lock out other smp processors from accessing the target,46 * lock out other smp processors from accessing the target,
@@ -46,8 +48,8 @@
46 * to target, allow out other smp processors to access the target,48 * to target, allow out other smp processors to access the target,
47 * return new value of target as modified by this operation49 * return new value of target as modified by this operation
48 */50 */
49epicsShareFunc size_t epicsAtomicDecrSizeT ( size_t * pTarget );51EPICS_ATOMIC_INLINE size_t epicsAtomicDecrSizeT ( size_t * pTarget );
50epicsShareFunc int epicsAtomicDecrIntT ( int * pTarget );52EPICS_ATOMIC_INLINE int epicsAtomicDecrIntT ( int * pTarget );
5153
52/*54/*
53 * lock out other smp processors from accessing the target,55 * lock out other smp processors from accessing the target,
@@ -55,23 +57,23 @@
55 * to target, allow other smp processors to access the target,57 * to target, allow other smp processors to access the target,
56 * return new value of target as modified by this operation58 * return new value of target as modified by this operation
57 */59 */
58epicsShareFunc size_t epicsAtomicAddSizeT ( size_t * pTarget, size_t delta );60EPICS_ATOMIC_INLINE size_t epicsAtomicAddSizeT ( size_t * pTarget, size_t delta );
59epicsShareFunc size_t epicsAtomicSubSizeT ( size_t * pTarget, size_t delta );61EPICS_ATOMIC_INLINE size_t epicsAtomicSubSizeT ( size_t * pTarget, size_t delta );
60epicsShareFunc int epicsAtomicAddIntT ( int * pTarget, int delta );62EPICS_ATOMIC_INLINE int epicsAtomicAddIntT ( int * pTarget, int delta );
6163
62/*64/*
63 * set cache version of target, flush cache to target 65 * set cache version of target, flush cache to target
64 */66 */
65epicsShareFunc void epicsAtomicSetSizeT ( size_t * pTarget, size_t newValue ); 67EPICS_ATOMIC_INLINE void epicsAtomicSetSizeT ( size_t * pTarget, size_t newValue );
66epicsShareFunc void epicsAtomicSetIntT ( int * pTarget, int newValue );68EPICS_ATOMIC_INLINE void epicsAtomicSetIntT ( int * pTarget, int newValue );
67epicsShareFunc void epicsAtomicSetPtrT ( EpicsAtomicPtrT * pTarget, EpicsAtomicPtrT newValue );69EPICS_ATOMIC_INLINE void epicsAtomicSetPtrT ( EpicsAtomicPtrT * pTarget, EpicsAtomicPtrT newValue );
6870
69/*71/*
70 * fetch target into cache, return new value of target72 * fetch target into cache, return new value of target
71 */73 */
72epicsShareFunc size_t epicsAtomicGetSizeT ( const size_t * pTarget );74EPICS_ATOMIC_INLINE size_t epicsAtomicGetSizeT ( const size_t * pTarget );
73epicsShareFunc int epicsAtomicGetIntT ( const int * pTarget );75EPICS_ATOMIC_INLINE int epicsAtomicGetIntT ( const int * pTarget );
74epicsShareFunc EpicsAtomicPtrT epicsAtomicGetPtrT ( const EpicsAtomicPtrT * pTarget );76EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicGetPtrT ( const EpicsAtomicPtrT * pTarget );
7577
76/*78/*
77 * lock out other smp processors from accessing the target,79 * lock out other smp processors from accessing the target,
@@ -80,11 +82,11 @@
80 * to access the target, return the original value stored in the82 * to access the target, return the original value stored in the
81 * target83 * target
82 */84 */
83epicsShareFunc size_t epicsAtomicCmpAndSwapSizeT ( size_t * pTarget, 85EPICS_ATOMIC_INLINE size_t epicsAtomicCmpAndSwapSizeT ( size_t * pTarget,
84 size_t oldVal, size_t newVal );86 size_t oldVal, size_t newVal );
85epicsShareFunc int epicsAtomicCmpAndSwapIntT ( int * pTarget, 87EPICS_ATOMIC_INLINE int epicsAtomicCmpAndSwapIntT ( int * pTarget,
86 int oldVal, int newVal );88 int oldVal, int newVal );
87epicsShareFunc EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT ( 89EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT (
88 EpicsAtomicPtrT * pTarget, 90 EpicsAtomicPtrT * pTarget,
89 EpicsAtomicPtrT oldVal, 91 EpicsAtomicPtrT oldVal,
90 EpicsAtomicPtrT newVal );92 EpicsAtomicPtrT newVal );
@@ -111,119 +113,98 @@
111/* 113/*
112 * overloaded c++ interface 114 * overloaded c++ interface
113 */115 */
114epicsShareFunc size_t increment ( size_t & v );
115epicsShareFunc int increment ( int & v );
116epicsShareFunc size_t decrement ( size_t & v );
117epicsShareFunc int decrement ( int & v );
118epicsShareFunc size_t add ( size_t & v, size_t delta );
119epicsShareFunc int add ( int & v, int delta );
120epicsShareFunc size_t subtract ( size_t & v, size_t delta );
121epicsShareFunc int subtract ( int & v, int delta );
122epicsShareFunc void set ( size_t & v , size_t newValue );
123epicsShareFunc void set ( int & v, int newValue );
124epicsShareFunc void set ( EpicsAtomicPtrT & v,
125 EpicsAtomicPtrT newValue );
126epicsShareFunc size_t get ( const size_t & v );
127epicsShareFunc int get ( const int & v );
128epicsShareFunc EpicsAtomicPtrT get ( const EpicsAtomicPtrT & v );
129epicsShareFunc size_t compareAndSwap ( size_t & v, size_t oldVal,
130 size_t newVal );
131epicsShareFunc int compareAndSwap ( int & v, int oldVal, int newVal );
132epicsShareFunc EpicsAtomicPtrT compareAndSwap ( EpicsAtomicPtrT & v,
133 EpicsAtomicPtrT oldVal,
134 EpicsAtomicPtrT newVal );
135116
136/************* incr ***************/117/************* incr ***************/
137inline size_t increment ( size_t & v )118EPICS_ATOMIC_INLINE size_t increment ( size_t & v )
138{119{
139 return epicsAtomicIncrSizeT ( & v );120 return epicsAtomicIncrSizeT ( & v );
140}121}
141122
142inline int increment ( int & v )123EPICS_ATOMIC_INLINE int increment ( int & v )
143{124{
144 return epicsAtomicIncrIntT ( & v );125 return epicsAtomicIncrIntT ( & v );
145}126}
146127
147/************* decr ***************/128/************* decr ***************/
148inline size_t decrement ( size_t & v )129EPICS_ATOMIC_INLINE size_t decrement ( size_t & v )
149{130{
150 return epicsAtomicDecrSizeT ( & v );131 return epicsAtomicDecrSizeT ( & v );
151}132}
152133
153inline int decrement ( int & v )134EPICS_ATOMIC_INLINE int decrement ( int & v )
154{135{
155 return epicsAtomicDecrIntT ( & v );136 return epicsAtomicDecrIntT ( & v );
156}137}
157138
158/************* add ***************/139/************* add ***************/
159inline size_t add ( size_t & v, size_t delta )140EPICS_ATOMIC_INLINE size_t add ( size_t & v, size_t delta )
160{141{
161 return epicsAtomicAddSizeT ( & v, delta );142 return epicsAtomicAddSizeT ( & v, delta );
162}143}
163144
164inline int add ( int & v, int delta )145EPICS_ATOMIC_INLINE int add ( int & v, int delta )
165{146{
166 return epicsAtomicAddIntT ( & v, delta );147 return epicsAtomicAddIntT ( & v, delta );
167}148}
168149
169/************* sub ***************/150/************* sub ***************/
170inline size_t subtract ( size_t & v, size_t delta )151EPICS_ATOMIC_INLINE size_t subtract ( size_t & v, size_t delta )
171{152{
172 return epicsAtomicSubSizeT ( & v, delta );153 return epicsAtomicSubSizeT ( & v, delta );
173}154}
174155
175inline int subtract ( int & v, int delta )156EPICS_ATOMIC_INLINE int subtract ( int & v, int delta )
176{157{
177 return epicsAtomicAddIntT ( & v, -delta );158 return epicsAtomicAddIntT ( & v, -delta );
178}159}
179160
180/************* set ***************/161/************* set ***************/
181inline void set ( size_t & v , size_t newValue ) 162EPICS_ATOMIC_INLINE void set ( size_t & v , size_t newValue )
182{ 163{
183 epicsAtomicSetSizeT ( & v, newValue ); 164 epicsAtomicSetSizeT ( & v, newValue );
184}165}
185166
186inline void set ( int & v, int newValue )167EPICS_ATOMIC_INLINE void set ( int & v, int newValue )
187{168{
188 epicsAtomicSetIntT ( & v, newValue );169 epicsAtomicSetIntT ( & v, newValue );
189}170}
190171
191inline void set ( EpicsAtomicPtrT & v, EpicsAtomicPtrT newValue )172EPICS_ATOMIC_INLINE void set ( EpicsAtomicPtrT & v, EpicsAtomicPtrT newValue )
192{173{
193 epicsAtomicSetPtrT ( & v, newValue );174 epicsAtomicSetPtrT ( & v, newValue );
194}175}
195176
196/************* get ***************/177/************* get ***************/
197inline size_t get ( const size_t & v )178EPICS_ATOMIC_INLINE size_t get ( const size_t & v )
198{179{
199 return epicsAtomicGetSizeT ( & v );180 return epicsAtomicGetSizeT ( & v );
200}181}
201182
202inline int get ( const int & v )183EPICS_ATOMIC_INLINE int get ( const int & v )
203{184{
204 return epicsAtomicGetIntT ( & v );185 return epicsAtomicGetIntT ( & v );
205}186}
206187
207inline EpicsAtomicPtrT get ( const EpicsAtomicPtrT & v )188EPICS_ATOMIC_INLINE EpicsAtomicPtrT get ( const EpicsAtomicPtrT & v )
208{189{
209 return epicsAtomicGetPtrT ( & v );190 return epicsAtomicGetPtrT ( & v );
210}191}
211192
212/************* cas ***************/193/************* cas ***************/
213inline size_t compareAndSwap ( size_t & v, 194EPICS_ATOMIC_INLINE size_t compareAndSwap ( size_t & v,
214 size_t oldVal, size_t newVal )195 size_t oldVal, size_t newVal )
215{196{
216 return epicsAtomicCmpAndSwapSizeT ( & v, oldVal, newVal );197 return epicsAtomicCmpAndSwapSizeT ( & v, oldVal, newVal );
217}198}
218199
219inline int compareAndSwap ( int & v, int oldVal, int newVal )200EPICS_ATOMIC_INLINE int compareAndSwap ( int & v, int oldVal, int newVal )
220{201{
221 return epicsAtomicCmpAndSwapIntT ( & v, oldVal, newVal );202 return epicsAtomicCmpAndSwapIntT ( & v, oldVal, newVal );
222}203}
223204
224inline EpicsAtomicPtrT compareAndSwap ( EpicsAtomicPtrT & v, 205EPICS_ATOMIC_INLINE EpicsAtomicPtrT compareAndSwap ( EpicsAtomicPtrT & v,
225 EpicsAtomicPtrT oldVal, 206 EpicsAtomicPtrT oldVal,
226 EpicsAtomicPtrT newVal )207 EpicsAtomicPtrT newVal )
227{208{
228 return epicsAtomicCmpAndSwapPtrT ( & v, oldVal, newVal );209 return epicsAtomicCmpAndSwapPtrT ( & v, oldVal, newVal );
229}210}
230211
=== added file 'src/libCom/osi/os/RTEMS/epicsAtomicOSD.h'
--- src/libCom/osi/os/RTEMS/epicsAtomicOSD.h 1970-01-01 00:00:00 +0000
+++ src/libCom/osi/os/RTEMS/epicsAtomicOSD.h 2015-02-27 22:36:36 +0000
@@ -0,0 +1,65 @@
1
2/*************************************************************************\
3* Copyright (c) 2011 LANS LLC, as Operator of
4* Los Alamos National Laboratory.
5* Copyright (c) 2011 UChicago Argonne LLC, as Operator of Argonne
6* National Laboratory.
7* EPICS BASE is distributed subject to a Software License Agreement found
8* in file LICENSE that is included with this distribution.
9\*************************************************************************/
10
11/*
12 * Author Jeffrey O. Hill
13 * johill@lanl.gov
14 */
15
16#ifndef epicsAtomicOSD_h
17#define epicsAtomicOSD_h
18
19#include <shareLib.h>
20#include "epicsMMIO.h"
21#include "compilerSpecific.h"
22#include "epicsInterrupt.h"
23
24#define EPICS_ATOMIC_OS_NAME "RTEMS"
25
26typedef struct EpicsAtomicLockKey {
27 int key;
28} EpicsAtomicLockKey;
29
30#ifdef __cplusplus
31extern "C" {
32#endif /* __cplusplus */
33
34#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER
35EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void)
36{
37 epicsAtomicMemoryBarrierFallback();
38}
39#endif
40
41#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER
42EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void)
43{
44 rwbarr();
45}
46#endif
47
48EPICS_ATOMIC_INLINE void epicsAtomicLock ( struct EpicsAtomicLockKey * pkey )
49{
50 pkey->key = epicsInterruptLock();
51}
52
53EPICS_ATOMIC_INLINE void epicsAtomicUnlock ( struct EpicsAtomicLockKey * pkey )
54{
55 epicsInterruptUnlock(pkey->key);
56}
57
58#ifdef __cplusplus
59} /* end of extern "C" */
60#endif /* __cplusplus */
61
62#include "epicsAtomicDefault.h"
63
64#endif /* epicsAtomicOSD_h */
65
066
=== removed file 'src/libCom/osi/os/WIN32/epicsAtomicOSD.cpp'
--- src/libCom/osi/os/WIN32/epicsAtomicOSD.cpp 2011-09-01 17:25:53 +0000
+++ src/libCom/osi/os/WIN32/epicsAtomicOSD.cpp 1970-01-01 00:00:00 +0000
@@ -1,22 +0,0 @@
1
2/*************************************************************************\
3* Copyright (c) 2011 LANS LLC, as Operator of
4* Los Alamos National Laboratory.
5* EPICS BASE is distributed subject to a Software License Agreement found
6* in file LICENSE that is included with this distribution.
7\*************************************************************************/
8
9/*
10 * Author Jeffrey O. Hill
11 * johill@lanl.gov
12 */
13
14#define epicsExportSharedSymbols
15#include "epicsAtomic.h"
16
17// if the compiler is unable to inline then instantiate out-of-line
18#ifndef EPICS_ATOMIC_INLINE
19# define EPICS_ATOMIC_INLINE
20# include "epicsAtomicOSD.h"
21#endif
22
230
=== modified file 'src/libCom/osi/os/WIN32/epicsAtomicOSD.h'
--- src/libCom/osi/os/WIN32/epicsAtomicOSD.h 2014-11-19 19:16:56 +0000
+++ src/libCom/osi/os/WIN32/epicsAtomicOSD.h 2015-02-27 22:36:36 +0000
@@ -16,6 +16,8 @@
16#ifndef epicsAtomicOSD_h16#ifndef epicsAtomicOSD_h
17#define epicsAtomicOSD_h17#define epicsAtomicOSD_h
1818
19#define EPICS_ATOMIC_OS_NAME "WIN32"
20
19#ifdef VC_EXTRALEAN21#ifdef VC_EXTRALEAN
20# define VC_EXTRALEAN_DETECTED_epicsAtomicOSD_h22# define VC_EXTRALEAN_DETECTED_epicsAtomicOSD_h
21#else23#else
2224
=== added file 'src/libCom/osi/os/default/epicsAtomicOSD.c'
=== modified file 'src/libCom/osi/os/posix/epicsAtomicOSD.cpp'
--- src/libCom/osi/os/posix/epicsAtomicOSD.cpp 2013-11-20 17:51:14 +0000
+++ src/libCom/osi/os/posix/epicsAtomicOSD.cpp 2015-02-27 22:36:36 +0000
@@ -19,14 +19,6 @@
19#include "epicsAssert.h"19#include "epicsAssert.h"
20#include "epicsAtomic.h"20#include "epicsAtomic.h"
2121
22// if the compiler is unable to inline then instantiate out-of-line
23#ifndef EPICS_ATOMIC_INLINE
24# define EPICS_ATOMIC_INLINE
25# include "epicsAtomicOSD.h"
26#endif
27
28#ifndef EPICS_ATOMIC_LOCK
29
30/*22/*
31 * Slow, but probably correct on all systems.23 * Slow, but probably correct on all systems.
32 * Useful only if something more efficient isn`t 24 * Useful only if something more efficient isn`t
@@ -69,31 +61,14 @@
69 assert ( status == 0 );61 assert ( status == 0 );
70}62}
7163
72#endif // ifndef EPICS_ATOMIC_LOCK64
7365// Slow, but probably correct on all systems.
74#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER66// Useful only if something more efficient isn`t
75// Slow, but probably correct on all systems.67// provided based on knowledge of the compiler
76// Useful only if something more efficient isn`t 68// or OS
77// provided based on knowledge of the compiler 69void epicsAtomicMemoryBarrierFallback (void)
78// or OS 70{
79void epicsAtomicReadMemoryBarrier ()71 EpicsAtomicLockKey key;
80{72 epicsAtomicLock ( & key );
81 EpicsAtomicLockKey key;73 epicsAtomicUnlock ( & key );
82 epicsAtomicLock ( & key );74}
83 epicsAtomicUnlock ( & key );
84}
85#endif
86
87#ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER
88// Slow, but probably correct on all systems.
89// Useful only if something more efficient isn`t
90// provided based on knowledge of the compiler
91// or OS
92void epicsAtomicWriteMemoryBarrier ()
93{
94 EpicsAtomicLockKey key;
95 epicsAtomicLock ( & key );
96 epicsAtomicUnlock ( & key );
97}
98#endif
99
10075
=== modified file 'src/libCom/osi/os/posix/epicsAtomicOSD.h'
--- src/libCom/osi/os/posix/epicsAtomicOSD.h 2014-07-25 20:05:58 +0000
+++ src/libCom/osi/os/posix/epicsAtomicOSD.h 2015-02-27 22:36:36 +0000
@@ -16,14 +16,33 @@
16#ifndef epicsAtomicOSD_h16#ifndef epicsAtomicOSD_h
17#define epicsAtomicOSD_h17#define epicsAtomicOSD_h
1818
19#include <shareLib.h>
20
21#define EPICS_ATOMIC_OS_NAME "POSIX"
22
19typedef struct EpicsAtomicLockKey {} EpicsAtomicLockKey;23typedef struct EpicsAtomicLockKey {} EpicsAtomicLockKey;
2024
21#ifdef __cplusplus25#ifdef __cplusplus
22extern "C" {26extern "C" {
23#endif /* __cplusplus */27#endif /* __cplusplus */
2428
29#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER
30EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void)
31{
32 epicsAtomicMemoryBarrierFallback();
33}
34#endif
35
36#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER
37EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void)
38{
39 epicsAtomicMemoryBarrierFallback();
40}
41#endif
42
25epicsShareFunc void epicsAtomicLock ( struct EpicsAtomicLockKey * );43epicsShareFunc void epicsAtomicLock ( struct EpicsAtomicLockKey * );
26epicsShareFunc void epicsAtomicUnlock ( struct EpicsAtomicLockKey * );44epicsShareFunc void epicsAtomicUnlock ( struct EpicsAtomicLockKey * );
45epicsShareFunc void epicsAtomicMemoryBarrierFallback ( void );
2746
28#ifdef __cplusplus47#ifdef __cplusplus
29} /* end of extern "C" */48} /* end of extern "C" */
3049
=== modified file 'src/libCom/osi/os/solaris/epicsAtomicOSD.h'
--- src/libCom/osi/os/solaris/epicsAtomicOSD.h 2014-09-11 14:10:44 +0000
+++ src/libCom/osi/os/solaris/epicsAtomicOSD.h 2015-02-27 22:36:36 +0000
@@ -13,9 +13,13 @@
13 * johill@lanl.gov13 * johill@lanl.gov
14 */14 */
1515
16#include "shareLib.h"
17
16#ifndef epicsAtomicOSD_h18#ifndef epicsAtomicOSD_h
17#define epicsAtomicOSD_h19#define epicsAtomicOSD_h
1820
21#define EPICS_ATOMIC_OS_NAME "Solaris"
22
19#if defined ( __SunOS_5_10 )23#if defined ( __SunOS_5_10 )
2024
21/* 25/*
@@ -31,7 +35,7 @@
3135
32#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER36#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER
33#define EPICS_ATOMIC_READ_MEMORY_BARRIER37#define EPICS_ATOMIC_READ_MEMORY_BARRIER
34EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier () 38EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void)
35{39{
36 membar_consumer ();40 membar_consumer ();
37}41}
@@ -39,7 +43,7 @@
3943
40#ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER44#ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER
41#define EPICS_ATOMIC_WRITE_MEMORY_BARRIER45#define EPICS_ATOMIC_WRITE_MEMORY_BARRIER
42EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier () 46EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void)
43{47{
44 membar_producer ();48 membar_producer ();
45}49}
@@ -47,7 +51,7 @@
4751
48#ifndef EPICS_ATOMIC_CAS_INTT52#ifndef EPICS_ATOMIC_CAS_INTT
49#define EPICS_ATOMIC_CAS_INTT53#define EPICS_ATOMIC_CAS_INTT
50EPICS_ATOMIC_INLINE int epicsAtomicCmpAndSwapIntT ( int * pTarget, 54EPICS_ATOMIC_INLINE int epicsAtomicCmpAndSwapIntT ( int * pTarget,
51 int oldVal, int newVal )55 int oldVal, int newVal )
52{56{
53 STATIC_ASSERT ( sizeof ( int ) == sizeof ( unsigned ) );57 STATIC_ASSERT ( sizeof ( int ) == sizeof ( unsigned ) );
@@ -59,7 +63,7 @@
5963
60#ifndef EPICS_ATOMIC_CAS_SIZET64#ifndef EPICS_ATOMIC_CAS_SIZET
61#define EPICS_ATOMIC_CAS_SIZET65#define EPICS_ATOMIC_CAS_SIZET
62EPICS_ATOMIC_INLINE size_t epicsAtomicCmpAndSwapSizeT ( 66EPICS_ATOMIC_INLINE size_t epicsAtomicCmpAndSwapSizeT (
63 size_t * pTarget,67 size_t * pTarget,
64 size_t oldVal, size_t newVal )68 size_t oldVal, size_t newVal )
65{69{
@@ -71,7 +75,7 @@
7175
72#ifndef EPICS_ATOMIC_CAS_PTRT76#ifndef EPICS_ATOMIC_CAS_PTRT
73#define EPICS_ATOMIC_CAS_PTRT77#define EPICS_ATOMIC_CAS_PTRT
74EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT ( 78EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT (
75 EpicsAtomicPtrT * pTarget, 79 EpicsAtomicPtrT * pTarget,
76 EpicsAtomicPtrT oldVal, 80 EpicsAtomicPtrT oldVal,
77 EpicsAtomicPtrT newVal )81 EpicsAtomicPtrT newVal )
@@ -132,7 +136,7 @@
132136
133#ifndef EPICS_ATOMIC_ADD_SIZET137#ifndef EPICS_ATOMIC_ADD_SIZET
134#define EPICS_ATOMIC_ADD_SIZET138#define EPICS_ATOMIC_ADD_SIZET
135EPICS_ATOMIC_INLINE size_t epicsAtomicAddSizeT ( size_t * pTarget, 139EPICS_ATOMIC_INLINE size_t epicsAtomicAddSizeT ( size_t * pTarget,
136 size_t delta )140 size_t delta )
137{141{
138 STATIC_ASSERT ( sizeof ( ulong_t ) == sizeof ( size_t ) );142 STATIC_ASSERT ( sizeof ( ulong_t ) == sizeof ( size_t ) );
@@ -143,7 +147,7 @@
143147
144#ifndef EPICS_ATOMIC_SUB_SIZET148#ifndef EPICS_ATOMIC_SUB_SIZET
145#define EPICS_ATOMIC_SUB_SIZET149#define EPICS_ATOMIC_SUB_SIZET
146EPICS_ATOMIC_INLINE size_t epicsAtomicSubSizeT ( size_t * pTarget, 150EPICS_ATOMIC_INLINE size_t epicsAtomicSubSizeT ( size_t * pTarget,
147 size_t delta )151 size_t delta )
148{152{
149 STATIC_ASSERT ( sizeof ( ulong_t ) == sizeof ( size_t ) );153 STATIC_ASSERT ( sizeof ( ulong_t ) == sizeof ( size_t ) );
150154
=== removed file 'src/libCom/osi/os/vxWorks/epicsAtomicOSD.cpp'
--- src/libCom/osi/os/vxWorks/epicsAtomicOSD.cpp 2011-09-01 17:25:53 +0000
+++ src/libCom/osi/os/vxWorks/epicsAtomicOSD.cpp 1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
1
2/*************************************************************************\
3* Copyright (c) 2011 LANS LLC, as Operator of
4* Los Alamos National Laboratory.
5* EPICS BASE is distributed subject to a Software License Agreement found
6* in file LICENSE that is included with this distribution.
7\*************************************************************************/
8
9/*
10 * Author Jeffrey O. Hill
11 * johill@lanl.gov
12 */
13
14#define epicsExportSharedSymbols
15#include "epicsAtomic.h"
16
17// if the compiler is unable to inline then instantiate out-of-line
18#ifndef EPICS_ATOMIC_INLINE
19# define EPICS_ATOMIC_INLINE
20# include "epicsAtomicOSD.h"
21#endif
220
=== modified file 'src/libCom/osi/os/vxWorks/epicsAtomicOSD.h'
--- src/libCom/osi/os/vxWorks/epicsAtomicOSD.h 2011-09-07 15:59:11 +0000
+++ src/libCom/osi/os/vxWorks/epicsAtomicOSD.h 2015-02-27 22:36:36 +0000
@@ -32,13 +32,15 @@
32#include <limits.h>32#include <limits.h>
33#include <vxAtomicLib.h>33#include <vxAtomicLib.h>
3434
35#define EPICS_ATOMIC_OS_NAME "VX-ATOMICLIB"
36
35#ifdef __cplusplus37#ifdef __cplusplus
36extern "C" {38extern "C" {
37#endif /* __cplusplus */39#endif /* __cplusplus */
3840
39#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER41#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER
40#define EPICS_ATOMIC_READ_MEMORY_BARRIER42#define EPICS_ATOMIC_READ_MEMORY_BARRIER
41EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier () 43EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void)
42{44{
43 VX_MEM_BARRIER_R ();45 VX_MEM_BARRIER_R ();
44}46}
@@ -46,7 +48,7 @@
4648
47#ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER49#ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER
48#define EPICS_ATOMIC_WRITE_MEMORY_BARRIER50#define EPICS_ATOMIC_WRITE_MEMORY_BARRIER
49EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier () 51EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void)
50{52{
51 VX_MEM_BARRIER_W ();53 VX_MEM_BARRIER_W ();
52}54}
@@ -206,6 +208,8 @@
206#include "vxLib.h"208#include "vxLib.h"
207#include "intLib.h"209#include "intLib.h"
208210
211#define EPICS_ATOMIC_OS_NAME "VX-INTLIB"
212
209#ifdef __cplusplus213#ifdef __cplusplus
210extern "C" {214extern "C" {
211#endif /* __cplusplus */215#endif /* __cplusplus */
@@ -232,7 +236,7 @@
232 * no need for memory barrior since prior to vxWorks 6.6 it is a single cpu system 236 * no need for memory barrior since prior to vxWorks 6.6 it is a single cpu system
233 * (we are not protecting against multiple access to memory mapped IO)237 * (we are not protecting against multiple access to memory mapped IO)
234 */238 */
235EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier () {}239EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier (void) {}
236#endif240#endif
237241
238#ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER242#ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER
@@ -241,7 +245,7 @@
241 * no need for memory barrior since prior to vxWorks 6.6 it is a single cpu system 245 * no need for memory barrior since prior to vxWorks 6.6 it is a single cpu system
242 * (we are not protecting against multiple access to memory mapped IO)246 * (we are not protecting against multiple access to memory mapped IO)
243 */247 */
244EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier () {}248EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier (void) {}
245#endif249#endif
246250
247#ifdef __cplusplus251#ifdef __cplusplus
248252
=== modified file 'src/libCom/test/Makefile'
--- src/libCom/test/Makefile 2014-10-07 04:39:23 +0000
+++ src/libCom/test/Makefile 2015-02-27 22:36:36 +0000
@@ -22,6 +22,14 @@
22testHarness_SRCS += epicsTypesTest.cpp22testHarness_SRCS += epicsTypesTest.cpp
23TESTS += epicsTypesTest23TESTS += epicsTypesTest
2424
25TESTPROD_HOST += epicsInlineTest
26epicsInlineTest_SRCS += epicsInlineTest1.c
27epicsInlineTest_SRCS += epicsInlineTest2.c
28epicsInlineTest_SRCS += epicsInlineTest3.cpp
29epicsInlineTest_SRCS += epicsInlineTest4.cpp
30testHarness_SRCS += $(epicsInlineTest_SRCS)
31TESTS += epicsInlineTest
32
25TESTPROD_HOST += epicsCalcTest33TESTPROD_HOST += epicsCalcTest
26epicsCalcTest_SRCS += epicsCalcTest.cpp34epicsCalcTest_SRCS += epicsCalcTest.cpp
27testHarness_SRCS += epicsCalcTest.cpp35testHarness_SRCS += epicsCalcTest.cpp
2836
=== modified file 'src/libCom/test/epicsAtomicTest.cpp'
--- src/libCom/test/epicsAtomicTest.cpp 2012-06-07 18:38:11 +0000
+++ src/libCom/test/epicsAtomicTest.cpp 2015-02-27 22:36:36 +0000
@@ -248,11 +248,89 @@
248# pragma warning ( pop )248# pragma warning ( pop )
249#endif249#endif
250250
251static void testClassify()
252{
253 testDiag("Classify Build conditions");
254#ifdef EPICS_ATOMIC_CMPLR_NAME
255 testDiag("Compiler dependent impl name %s", EPICS_ATOMIC_CMPLR_NAME);
256#else
257 testDiag("Compiler dependent impl name undefined");
258#endif
259#ifdef EPICS_ATOMIC_OS_NAME
260 testDiag("OS dependent impl name %s", EPICS_ATOMIC_OS_NAME);
261#else
262 testDiag("OS dependent impl name undefined");
263#endif
264
265#ifdef __GNUC__
266#if GCC_ATOMIC_INTRINSICS_GCC4_OR_BETTER
267 testDiag("GCC using atomic builtin memory barrier");
268#else
269 testDiag("GCC using asm memory barrier");
270#endif
271#if GCC_ATOMIC_INTRINSICS_AVAIL_INT_T || GCC_ATOMIC_INTRINSICS_AVAIL_EARLIER
272 testDiag("GCC use builtin for int");
273#endif
274#if GCC_ATOMIC_INTRINSICS_AVAIL_SIZE_T || GCC_ATOMIC_INTRINSICS_AVAIL_EARLIER
275 testDiag("GCC use builtin for size_t");
276#endif
277
278#ifndef EPICS_ATOMIC_INCR_INTT
279 testDiag("Use default epicsAtomicIncrIntT()");
280#endif
281#ifndef EPICS_ATOMIC_INCR_SIZET
282 testDiag("Use default epicsAtomicIncrSizeT()");
283#endif
284#ifndef EPICS_ATOMIC_DECR_INTT
285 testDiag("Use default epicsAtomicDecrIntT()");
286#endif
287#ifndef EPICS_ATOMIC_DECR_SIZET
288 testDiag("Use default epicsAtomicDecrSizeT()");
289#endif
290#ifndef EPICS_ATOMIC_ADD_INTT
291 testDiag("Use default epicsAtomicAddIntT()");
292#endif
293#ifndef EPICS_ATOMIC_ADD_SIZET
294 testDiag("Use default epicsAtomicAddSizeT()");
295#endif
296#ifndef EPICS_ATOMIC_SUB_SIZET
297 testDiag("Use default epicsAtomicSubSizeT()");
298#endif
299#ifndef EPICS_ATOMIC_SET_INTT
300 testDiag("Use default epicsAtomicSetIntT()");
301#endif
302#ifndef EPICS_ATOMIC_SET_SIZET
303 testDiag("Use default epicsAtomicSetSizeT()");
304#endif
305#ifndef EPICS_ATOMIC_SET_PTRT
306 testDiag("Use default epicsAtomicSetPtrT()");
307#endif
308#ifndef EPICS_ATOMIC_GET_INTT
309 testDiag("Use default epicsAtomicGetIntT()");
310#endif
311#ifndef EPICS_ATOMIC_GET_SIZET
312 testDiag("Use default epicsAtomicGetSizeT()");
313#endif
314#ifndef EPICS_ATOMIC_GET_PTRT
315 testDiag("Use default epicsAtomicGetPtrT()");
316#endif
317#ifndef EPICS_ATOMIC_CAS_INTT
318 testDiag("Use default epicsAtomicCmpAndSwapIntT()");
319#endif
320#ifndef EPICS_ATOMIC_CAS_SIZET
321 testDiag("Use default epicsAtomicCmpAndSwapSizeT()");
322#endif
323#ifndef EPICS_ATOMIC_CAS_PTRT
324 testDiag("Use default epicsAtomicCmpAndSwapPtrT()");
325#endif
326#endif /* __GNUC__ */
327}
251328
252MAIN ( epicsAtomicTest )329MAIN ( epicsAtomicTest )
253{330{
254331
255 testPlan ( 31 );332 testPlan ( 31 );
333 testClassify ();
256334
257 testIncrDecr < int > ();335 testIncrDecr < int > ();
258 testIncrDecr < size_t > ();336 testIncrDecr < size_t > ();
259337
=== added file 'src/libCom/test/epicsInlineTest1.c'
--- src/libCom/test/epicsInlineTest1.c 1970-01-01 00:00:00 +0000
+++ src/libCom/test/epicsInlineTest1.c 2015-02-27 22:36:36 +0000
@@ -0,0 +1,64 @@
1/*************************************************************************\
2* Copyright (c) 2015 Brookhaven Science Associates, as Operator of
3* Brookhaven National Laboratory.
4* EPICS BASE is distributed subject to a Software License Agreement found
5* in file LICENSE that is included with this distribution.
6\*************************************************************************/
7
8/* This test checks the variations on inline function defintions.
9 *
10 * "static inline int func(void) {...}"
11 *
12 * Consistent meaning in C89, C99, and C++ (98 and 11).
13 * If not inline'd results in a private symbol in each compilation unit.
14 * Thus the non-inline'd version is duplicated in each compilation unit.
15 * However, definitions in different compilation units may be different.
16 *
17 * "inline int func(void) {...}"
18 * Warning: Not consistent, avoid use in headers meant for C or C++
19 *
20 * In C++ this may be safely defined in more than one compilation unit.
21 * Where not inlined it will result in a weak public symbol.
22 * Thus non-inline'd version isn't duplicated, but must be the same
23 * in all compilation units.
24 *
25 */
26
27#include "compilerSpecific.h"
28#include "epicsUnitTest.h"
29
30#include "testMain.h"
31
32static EPICS_ALWAYS_INLINE int epicsInlineTestFn1(void)
33{
34 return 1;
35}
36
37/* Fails to link in C99
38inline int epicsInlineTestFn2(void)
39{
40 return 42;
41}
42*/
43
44void epicsInlineTest1(void)
45{
46 testDiag("epicsInlineTest1()");
47 testOk1(epicsInlineTestFn1()==1);
48 /*testOk1(epicsInlineTestFn2()==42);*/
49}
50
51void epicsInlineTest2(void);
52void epicsInlineTest3(void);
53void epicsInlineTest4(void);
54
55MAIN(epicsInlineTest)
56{
57 testPlan(6);
58 testDiag("Test variation on inline int func()");
59 epicsInlineTest1();
60 epicsInlineTest2();
61 epicsInlineTest3();
62 epicsInlineTest4();
63 return testDone();
64}
065
=== added file 'src/libCom/test/epicsInlineTest2.c'
--- src/libCom/test/epicsInlineTest2.c 1970-01-01 00:00:00 +0000
+++ src/libCom/test/epicsInlineTest2.c 2015-02-27 22:36:36 +0000
@@ -0,0 +1,28 @@
1/*************************************************************************\
2* Copyright (c) 2015 Brookhaven Science Associates, as Operator of
3* Brookhaven National Laboratory.
4* EPICS BASE is distributed subject to a Software License Agreement found
5* in file LICENSE that is included with this distribution.
6\*************************************************************************/
7
8#include "compilerSpecific.h"
9#include "epicsUnitTest.h"
10
11static EPICS_ALWAYS_INLINE int epicsInlineTestFn1(void)
12{
13 return 2;
14}
15
16/* Fails to link in C99
17inline int epicsInlineTestFn2(void)
18{
19 return 42;
20}
21*/
22
23void epicsInlineTest2(void)
24{
25 testDiag("epicsInlineTest2()");
26 testOk1(epicsInlineTestFn1()==2);
27 /*testOk1(epicsInlineTestFn2()==42);*/
28}
029
=== added file 'src/libCom/test/epicsInlineTest3.cpp'
--- src/libCom/test/epicsInlineTest3.cpp 1970-01-01 00:00:00 +0000
+++ src/libCom/test/epicsInlineTest3.cpp 2015-02-27 22:36:36 +0000
@@ -0,0 +1,27 @@
1/*************************************************************************\
2* Copyright (c) 2015 Brookhaven Science Associates, as Operator of
3* Brookhaven National Laboratory.
4* EPICS BASE is distributed subject to a Software License Agreement found
5* in file LICENSE that is included with this distribution.
6\*************************************************************************/
7
8#include "compilerSpecific.h"
9#include "epicsUnitTest.h"
10
11static EPICS_ALWAYS_INLINE int epicsInlineTestFn1(void)
12{
13 return 3;
14}
15
16inline int epicsInlineTestFn2(void)
17{
18 return 42;
19}
20
21extern "C"
22void epicsInlineTest3(void)
23{
24 testDiag("epicsInlineTest3()");
25 testOk1(epicsInlineTestFn1()==3);
26 testOk1(epicsInlineTestFn2()==42);
27}
028
=== added file 'src/libCom/test/epicsInlineTest4.cpp'
--- src/libCom/test/epicsInlineTest4.cpp 1970-01-01 00:00:00 +0000
+++ src/libCom/test/epicsInlineTest4.cpp 2015-02-27 22:36:36 +0000
@@ -0,0 +1,27 @@
1/*************************************************************************\
2* Copyright (c) 2015 Brookhaven Science Associates, as Operator of
3* Brookhaven National Laboratory.
4* EPICS BASE is distributed subject to a Software License Agreement found
5* in file LICENSE that is included with this distribution.
6\*************************************************************************/
7
8#include "compilerSpecific.h"
9#include "epicsUnitTest.h"
10
11static EPICS_ALWAYS_INLINE int epicsInlineTestFn1(void)
12{
13 return 4;
14}
15
16inline int epicsInlineTestFn2(void)
17{
18 return 42;
19}
20
21extern "C"
22void epicsInlineTest4(void)
23{
24 testDiag("epicsInlineTest4()");
25 testOk1(epicsInlineTestFn1()==4);
26 testOk1(epicsInlineTestFn2()==42);
27}
028
=== modified file 'src/libCom/test/epicsRunLibComTests.c'
--- src/libCom/test/epicsRunLibComTests.c 2014-10-07 04:39:23 +0000
+++ src/libCom/test/epicsRunLibComTests.c 2015-02-27 22:36:36 +0000
@@ -44,6 +44,7 @@
44int epicsTimerTest(void);44int epicsTimerTest(void);
45int epicsTimeTest(void);45int epicsTimeTest(void);
46int epicsTypesTest(void);46int epicsTypesTest(void);
47int epicsInlineTest(void);
47int macDefExpandTest(void);48int macDefExpandTest(void);
48int macLibTest(void);49int macLibTest(void);
49int ringBytesTest(void);50int ringBytesTest(void);
@@ -92,6 +93,7 @@
92 runTest(epicsThreadPrivateTest);93 runTest(epicsThreadPrivateTest);
93 runTest(epicsTimeTest);94 runTest(epicsTimeTest);
94 runTest(epicsTypesTest);95 runTest(epicsTypesTest);
96 runTest(epicsInlineTest);
95 runTest(macDefExpandTest);97 runTest(macDefExpandTest);
96 runTest(macLibTest);98 runTest(macLibTest);
97 runTest(ringBytesTest);99 runTest(ringBytesTest);

Subscribers

People subscribed via source and target branches