o improved comments

o dont include epicsAtomicOSD.h from any of the implementations of epicsAtomicCD.h unless the compiler has support for an inline keyword
o removed superfluous ifdef on EPICS_ATOMIC_INLINE all versions of epicsAtomicDefault.h and epicsAtomicOSD.h
o In the implementations of epicsAtomicOSD.cpp if EPICS_ATOMIC_INLINE isnt defined define it to be empty and then include epicsAtomicOSD.h
o fixing some compile time issues for solaris version of epicsAtomicOSD.h (so that Janet can run another compile on that os)
This commit is contained in:
Jeff Hill
2011-09-01 11:25:53 -06:00
committed by Andrew Johnson
parent 3bae2a470f
commit f5c374c556
13 changed files with 57 additions and 54 deletions

View File

@@ -22,6 +22,10 @@
# define EPICS_ATOMIC_INLINE __inline__
#endif
/*
* we have an inline keyword so we can proceed
* with an os specific inline instantiation
*/
#include "epicsAtomicOSD.h"
#endif /* epicsAtomicCD_h */

View File

@@ -18,8 +18,13 @@
#if __STDC_VERSION__ >= 199901L || defined ( __cplusplus )
# define EPICS_ATOMIC_INLINE inline
/*
* We have already defined the public interface in epicsAtomic.h
* so there is nothing more to implement if there isnt an inline
* keyword available. Otherwise, if we have an inline keyword
* we will proceed with an os specific inline implementation.
*/
# include "epicsAtomicOSD.h"
#endif
#include "epicsAtomicOSD.h"
#endif /* epicsAtomicCD_h */

View File

@@ -114,7 +114,7 @@ EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier ()
/*
* if unavailable as an intrinsic we will try
* for os specific solution
* for os specific inline solution
*/
#include "epicsAtomicOSD.h"

View File

@@ -22,6 +22,10 @@
# define EPICS_ATOMIC_INLINE __inline
#endif
/*
* we have an inline keyword so we can proceed
* with an os specific inline instantiation
*/
#include "epicsAtomicOSD.h"
#endif /* epicsAtomicCD_h */

View File

@@ -97,9 +97,9 @@ epicsShareFunc EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT (
* options for inline compiler instrinsic or os specific
* implementations of the above function prototypes
*
* its importnat for certaiin compiler to define the
* for some of the compilers we must define the
* inline functions before they get used in the c++
* code below
* inine functions below
*/
#include "epicsAtomicCD.h"

View File

@@ -16,12 +16,6 @@
#ifndef epicsAtomicDefault_h
#define epicsAtomicDefault_h
/*
* EPICS_ATOMIC_INLINE might be defined, but empty for an out-of-line
* instantiation
*/
#ifdef EPICS_ATOMIC_INLINE
#ifdef __cpluplus
extern "C" {
#endif
@@ -228,8 +222,6 @@ EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT (
} /* end of extern "C" */
#endif
#endif /* EPICS_ATOMIC_INLINE */
#endif /* epicsAtomicDefault_h */

View File

@@ -16,7 +16,7 @@
// if the compiler is unable to inline then instantiate out-of-line
#ifndef EPICS_ATOMIC_INLINE
#define EPICS_ATOMIC_INLINE
#include "epicsAtomic.h"
# define EPICS_ATOMIC_INLINE
# include "epicsAtomicOSD.h"
#endif

View File

@@ -40,10 +40,8 @@
# define MS_InterlockedCompareExchange InterlockedCompareExchange64
#endif
#ifdef EPICS_ATOMIC_INLINE
# include "epicsAtomicMS.h"
# include "epicsAtomicDefault.h"
#endif
#include "epicsAtomicMS.h"
#include "epicsAtomicDefault.h"
#endif /* epicsAtomicOSD_h */

View File

@@ -7,31 +7,22 @@
\*************************************************************************/
/*
* Author Jeffrey O. Hill
* Author: Jeffrey O. Hill
* johill@lanl.gov
*/
#define epicsExportSharedSymbols
#include "epicsAtomic.h"
// if the compiler is unable to inline then instantiate out-of-line
#ifndef EPICS_ATOMIC_INLINE
#define EPICS_ATOMIC_INLINE
#include "epicsAtomic.h"
#endif
/* Authors: Jeffrey O. Hill */
#include <errno.h>
#include <unistd.h>
#include <pthread.h>
#define epicsExportSharedSymbols
#include "epicsAssert.h"
#include "epicsAtomic.h"
// if the compiler is unable to inline then instantiate out-of-line
#ifndef EPICS_ATOMIC_INLINE
#define EPICS_ATOMIC_INLINE
#include "epicsAtomic.h"
# define EPICS_ATOMIC_INLINE
# include "epicsAtomicOSD.h"
#endif
#ifndef EPICS_ATOMIC_LOCK

View File

@@ -22,11 +22,7 @@ epicsShareFunc void epicsAtomicWriteMemoryBarrier ();
epicsShareFunc void epicsAtomicLock ( struct EpicsAtomicLockKey * );
epicsShareFunc void epicsAtomicUnlock ( struct EpicsAtomicLockKey * );
#ifdef EPICS_ATOMIC_INLINE
#include "epicsAtomicDefault.h"
#endif /* ifdef EPICS_ATOMIC_INLINE */
#endif /* epicsAtomicOSD_h */

View File

@@ -16,22 +16,22 @@
#ifndef epicsAtomicOSD_h
#define epicsAtomicOSD_h
#if defined ( EPICS_ATOMIC_INLINE )
#if defined ( __SunOS_5_10 )
/*
* atomic.h exists only in Solaris 10 or higher
*/
#if defined ( __SunOS_5_10 )
#include <atomic.h>
#include "epicsAssert.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER
#define EPICS_ATOMIC_READ_MEMORY_BARRIER
EPICS_ATOMIC_INLINE int epicsAtomicReadMemoryBarrier ()
EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier ()
{
membar_consumer ();
}
@@ -39,7 +39,7 @@ EPICS_ATOMIC_INLINE int epicsAtomicReadMemoryBarrier ()
#ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER
#define EPICS_ATOMIC_WRITE_MEMORY_BARRIER
EPICS_ATOMIC_INLINE int epicsAtomicWriteMemoryBarrier ()
EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier ()
{
membar_producer ();
}
@@ -51,19 +51,20 @@ EPICS_ATOMIC_INLINE int epicsAtomicCmpAndSwapIntT ( int * pTarget,
int oldVal, int newVal )
{
STATIC_ASSERT ( sizeof ( int ) == sizeof ( unsigned ) );
return ( int ) atomic_cas_uint ( pTarget, ( unsigned ) oldVal,
unsigned * const pTarg = reinterpret_cast < unsigned * > ( pTarget );
return ( int ) atomic_cas_uint ( pTarg, ( unsigned ) oldVal,
( unsigned ) newVal );
}
#endif
#ifndef EPICS_ATOMIC_CAS_SIZET
#define EPICS_ATOMIC_CAS_SIZET
EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicCmpAndSwapSizeT (
EPICS_ATOMIC_INLINE size_t epicsAtomicCmpAndSwapSizeT (
size_t * pTarget,
size_t oldVal, size_t newVal )
{
STATIC_ASSERT ( sizeof ( void * ) == sizeof ( size_t ) );
void ** ppPtr = (void **) pTarget;
void ** const ppPtr = (void **) pTarget;
return ( size_t ) atomic_cas_ptr ( ppPtr, ( void * )oldVal, ( void * )newVal );
}
#endif
@@ -147,7 +148,7 @@ EPICS_ATOMIC_INLINE size_t epicsAtomicSubSizeT ( size_t * pTarget,
{
STATIC_ASSERT ( sizeof ( void * ) == sizeof ( size_t ) );
void ** const pTarg = ( void ** ) ( pTarget );
ssize_t = sdelta = ( ssize_t ) delta;
ssize_t sdelta = ( ssize_t ) delta;
return ( size_t ) atomic_add_ptr_nv ( pTarg, -sdelta );
}
#endif
@@ -156,11 +157,28 @@ EPICS_ATOMIC_INLINE size_t epicsAtomicSubSizeT ( size_t * pTarget,
} /* end of extern "C" */
#endif /* __cplusplus */
#else /* ifdef __SunOS_5_10 */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* its less than 5.10 so we forward reference to the out-of-line posix
* pthread lock implementation of epicsAtomicLock and epicsAtomicUnlock
* before including "epicsAtomicDefault.h"
*/
struct EpicsAtomicLockKey {};
epicsShareFunc void epicsAtomicLock ( struct EpicsAtomicLockKey * );
epicsShareFunc void epicsAtomicUnlock ( struct EpicsAtomicLockKey * );
#ifdef __cplusplus
} /* end of extern "C" */
#endif /* __cplusplus */
#endif /* ifdef __SunOS_5_10 */
#include "epicsAtomicDefault.h"
#endif /* if defined ( EPICS_ATOMIC_INLINE ) */
#endif /* epicsAtomicOSD_h */

View File

@@ -16,7 +16,6 @@
// if the compiler is unable to inline then instantiate out-of-line
#ifndef EPICS_ATOMIC_INLINE
#define EPICS_ATOMIC_INLINE
#include "epicsAtomic.h"
# define EPICS_ATOMIC_INLINE
# include "epicsAtomicOSD.h"
#endif

View File

@@ -15,8 +15,6 @@
#ifndef epicsAtomicOSD_h
#define epicsAtomicOSD_h
#if defined ( EPICS_ATOMIC_INLINE )
#include "vxWorks.h" /* obtain the version of vxWorks */
#include "epicsAssert.h"
@@ -249,7 +247,5 @@ EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier () {}
#include "epicsAtomicDefault.h"
#endif /* if defined ( EPICS_ATOMIC_INLINE ) */
#endif /* epicsAtomicOSD_h */