Skip to content

Commit

Permalink
Fix HAVE_CXX11 doesn't imply HAVE_CXX11_ATOMIC and vice versa
Browse files Browse the repository at this point in the history
Travis: fix allow_failures keys
  • Loading branch information
vigsterkr committed Aug 7, 2013
1 parent 8425ef4 commit b485ac9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -39,11 +39,11 @@ matrix:
env: CMAKE_OPTIONS="-DRModular=ON" EXTRA_PACKAGES="r-base-core swig2.0" CC=clang CXX=clang++
allow_failures:
- compiler: clang
env: CMAKE_OPTIONS="-DRModular=ON" EXTRA_PACKAGES="r-base-core swig2.0"
env: CMAKE_OPTIONS="-DRModular=ON" EXTRA_PACKAGES="r-base-core swig2.0" CC=clang CXX=clang++
- compiler: clang
python: 3.3
language: python
env: CMAKE_OPTIONS="-DPythonModular=ON" EXTRA_PACKAGES="python3-scipy swig2.0"
env: CMAKE_OPTIONS="-DPythonModular=ON" EXTRA_PACKAGES="python3-scipy swig2.0" CC=clang CXX=clang++
virtualenv:
system_site_packages: true
before_install:
Expand Down
8 changes: 7 additions & 1 deletion CMakeLists.txt
Expand Up @@ -66,12 +66,18 @@ ENDIF()
# check for supported c++11 features
INCLUDE(CheckCXX11Features)

IF(CXX11_COMPILER_FLAGS)
IF(_HAS_CXX11_FLAG)
LIST(APPEND DEFINES HAVE_CXX11)
SET(HAVE_CXX11 1)
SET(CMAKE_CXX_FLAGS "${CXX11_COMPILER_FLAGS} ${CMAKE_CXX_FLAGS}")
ENDIF()

IF(_HAS_CXX0X_FLAG)
LIST(APPEND DEFINES HAVE_CXX0X)
SET(HAVE_CXX0X 1)
SET(CMAKE_CXX_FLAGS "${CXX11_COMPILER_FLAGS} ${CMAKE_CXX_FLAGS}")
ENDIF()

IF (HAVE_CXX11_ATOMIC)
LIST(APPEND DEFINES HAVE_CXX11_ATOMIC)
ENDIF()
Expand Down
10 changes: 5 additions & 5 deletions src/shogun/lib/SGReferencedData.cpp
Expand Up @@ -3,7 +3,7 @@
#include <shogun/io/SGIO.h>
#include <shogun/lib/Lock.h>

#ifdef HAVE_CXX11
#ifdef HAVE_CXX11_ATOMIC
#include <atomic>
#endif

Expand All @@ -16,7 +16,7 @@ class RefCount
public:
RefCount() : rc(0) {};
/** reference count */
#ifdef HAVE_CXX11
#ifdef HAVE_CXX11_ATOMIC
volatile std::atomic<int> rc;
#else
int32_t rc;
Expand Down Expand Up @@ -62,7 +62,7 @@ int32_t SGReferencedData::ref_count()
if (m_refcount == NULL)
return -1;

#ifdef HAVE_CXX11
#ifdef HAVE_CXX11_ATOMIC
int32_t c = m_refcount->rc.load();
#else
m_refcount->lock.lock();
Expand Down Expand Up @@ -93,7 +93,7 @@ int32_t SGReferencedData::ref()
return -1;
}

#ifdef HAVE_CXX11
#ifdef HAVE_CXX11_ATOMIC
int32_t c = m_refcount->rc.fetch_add(1)+1;
#else
m_refcount->lock.lock();
Expand All @@ -120,7 +120,7 @@ int32_t SGReferencedData::unref()
return -1;
}

#ifdef HAVE_CXX11
#ifdef HAVE_CXX11_ATOMIC
int32_t c = m_refcount->rc.fetch_sub(1)-1;
#else
m_refcount->lock.lock();
Expand Down
1 change: 1 addition & 0 deletions src/shogun/lib/config.h.in
Expand Up @@ -63,6 +63,7 @@

#cmakedefine NARRAY_LIB "@NARRAY_LIB@"

#cmakedefine HAVE_CXX0X 1
#cmakedefine HAVE_CXX11 1
#cmakedefine HAVE_CXX11_ATOMIC 1

Expand Down

0 comments on commit b485ac9

Please sign in to comment.