Skip to content

Commit

Permalink
add changes for LibFlatArray which are required for MSVC, re #49
Browse files Browse the repository at this point in the history
  • Loading branch information
gentryx committed Feb 20, 2017
1 parent 76ed6f1 commit 342b8a4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
#ifndef FLAT_ARRAY_DETAIL_PREPROCESSOR_HPP
#define FLAT_ARRAY_DETAIL_PREPROCESSOR_HPP

#define LIBFLATARRAY_NIL()
#define LIBFLATARRAY_ELEM_I(INDEX, LIST) LIBFLATARRAY_ELEM_II(LIBFLATARRAY_ELEM_ ## INDEX LIST)
#define LIBFLATARRAY_ELEM_II(ELEMENT) LIBFLATARRAY_ELEM_III(ELEMENT)
#define LIBFLATARRAY_ELEM_III(ELEMENT, _) ELEMENT
#define LIBFLATARRAY_ELEM_0(ELEMENT) ELEMENT, LIBFLATARRAY_PP_NIL
#define LIBFLATARRAY_ELEM_0(ELEMENT) ELEMENT, LIBFLATARRAY_NIL()
#define LIBFLATARRAY_ELEM_1(_) LIBFLATARRAY_ELEM_0
#define LIBFLATARRAY_ELEM_2(_) LIBFLATARRAY_ELEM_1
#define LIBFLATARRAY_ELEM_3(_) LIBFLATARRAY_ELEM_2
Expand Down
6 changes: 3 additions & 3 deletions lib/libflatarray/include/libflatarray/short_vec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ inline bool any(const short_vec<CARGO, ARITY>& vec)
return vec.any();
}

inline bool any(unsigned mask)
inline unsigned any(unsigned mask)
{
return mask;
}

inline bool any(unsigned short mask)
inline unsigned short any(unsigned short mask)
{
return mask;
}

inline bool any(unsigned char mask)
inline unsigned char any(unsigned char mask)
{
return mask;
}
Expand Down
14 changes: 13 additions & 1 deletion lib/libflatarray/include/libflatarray/testbed/benchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
#ifndef FLAT_ARRAY_TESTBED_BENCHMARK_HPP
#define FLAT_ARRAY_TESTBED_BENCHMARK_HPP

#ifdef _WIN32
#include <Windows.h>
#else
#include <sys/time.h>
#endif

namespace LibFlatArray {

Expand All @@ -27,10 +31,18 @@ class benchmark

static double time()
{
#ifdef _WIN32
LARGE_INTEGER time;
LARGE_INTEGER freq;
QueryPerformanceCounter(&time);
QueryPerformanceFrequency(&freq);
return 1.0 * time.QuadPart / freq.QuadPart;
#else
timeval t;
gettimeofday(&t, 0);
return t.tv_sec + t.tv_usec * 1.0e-6;
#endif

return t.tv_sec + t.tv_usec * 1.0e-6;
}

};
Expand Down
3 changes: 3 additions & 0 deletions lib/libflatarray/include/libflatarray/testbed/evaluate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
#include <libflatarray/testbed/benchmark.hpp>
#include <ctime>
#include <iomanip>
#ifdef _WIN32
#else
#include <unistd.h>
#endif

namespace LibFlatArray {

Expand Down
6 changes: 6 additions & 0 deletions lib/libflatarray/test/test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
#include <sstream>

#ifndef BOOST_TEST
// Microsoft Visual Studio doesn't define __PRETTY_FUNCTION__:
#ifdef _MSC_VER
#define BOOST_TEST(ARG) if (!(ARG)) { std::cerr << __FILE__ << "(" << __LINE__ << "): test '" << #ARG << "' failed in function '" << __FUNCSIG__ << "'" << std::endl; }
#else
#define BOOST_TEST(ARG) if (!(ARG)) { std::cerr << __FILE__ << "(" << __LINE__ << "): test '" << #ARG << "' failed in function '" << __PRETTY_FUNCTION__ << "'" << std::endl; }
#endif

#endif


#ifndef BOOST_TEST_EQ
#define BOOST_TEST_EQ(A, B) BOOST_TEST((A) == (B))
Expand Down

0 comments on commit 342b8a4

Please sign in to comment.