Skip to content

Commit

Permalink
always use the atomic class from the standard library
Browse files Browse the repository at this point in the history
  • Loading branch information
Coos Baakman committed Oct 16, 2018
1 parent a0894db commit 09f3e22
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 66 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Pre-compiled *old* versions of DSSP are available from the

### Pre-requisites

Compiler:
* Must support at least the c++ 11 standard.

System libraries:

* libzeep version >= 3.0 (for mkhssp --fetch-dbrefs only)
Expand Down
34 changes: 0 additions & 34 deletions src/progress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,47 +29,13 @@
#include "progress.h"


#ifdef _MSC_VER

#include <Windows.h>

uint32 get_terminal_width()
{
return TERM_WIDTH;
}

int64 MCounter::operator++(int)
{
return ::InterlockedExchangeAdd64(&m_value, 1);
}

int64 MCounter::operator+=(int64 inValue)
{
return ::InterlockedExchangeAdd64(&m_value, inValue);
}

int64 MCounter::operator=(int64 inValue)
{
::InterlockedExchange64(&m_value, inValue);
return inValue;
}

// --------------------------------------------------------------------

#define STDOUT_FILENO 1
bool isatty(int) { return true; }

#else

uint32 get_terminal_width()
{
struct winsize w;
ioctl(0, TIOCGWINSZ, &w);
return w.ws_col;
}

#endif

struct MProgressImpl
{
MProgressImpl(int64 inMax, const std::string& inAction)
Expand Down
32 changes: 0 additions & 32 deletions src/progress.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,8 @@

#pragma once

#if defined(__linux__)

#if defined(__INTEL_COMPILER_BUILD_DATE) || \
(defined(__GNUC__) && (__GNUC__ > 4 || \
( __GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
#include <atomic>
typedef std::atomic<int64> MCounter;
#else
#include <boost/detail/atomic_count.hpp>
typedef boost::detail::atomic_count MCounter;
#endif

#else

struct MCounter
{
MCounter(int64 inValue) : m_value(inValue) {}

operator int64() const { return m_value; }

int64 operator++(int);
int64 operator+=(int64 inValue);
int64 operator=(int64 inValue);

int64 m_value;
};


//typedef int64 MCounter;
//
//int64 add(MCounter& ioCounter, int64 inIncrement);
//int64 set(MCounter& ioCounter, int64 inValue);

#endif

// --------------------------------------------------------------------

Expand Down

0 comments on commit 09f3e22

Please sign in to comment.