Replaced boost::thread/mutex etc. with std equivalents
[pulseview.git] / pv / data / logicsnapshot.cpp
index a1beafb9c4e4e3e3c50a111077e62fd3c2d261d5..3bd43c9208182e92bed8d46b8bea108d1e1af4c5 100644 (file)
 #include <stdlib.h>
 #include <math.h>
 
-#include <boost/foreach.hpp>
-
+#include "config.h"
 #include "logicsnapshot.h"
 
-using boost::lock_guard;
-using boost::recursive_mutex;
+using std::lock_guard;
+using std::recursive_mutex;
 using std::max;
 using std::min;
 using std::pair;
@@ -58,12 +57,15 @@ LogicSnapshot::LogicSnapshot(const sr_datafeed_logic &logic,
 LogicSnapshot::~LogicSnapshot()
 {
        lock_guard<recursive_mutex> lock(_mutex);
-       BOOST_FOREACH(MipMapLevel &l, _mip_map)
+       for (MipMapLevel &l : _mip_map)
                free(l.data);
 }
 
 uint64_t LogicSnapshot::unpack_sample(const uint8_t *ptr) const
 {
+#ifdef HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS
+       return *(uint64_t*)ptr;
+#else
        uint64_t value = 0;
        switch(_unit_size) {
        default:
@@ -94,10 +96,14 @@ uint64_t LogicSnapshot::unpack_sample(const uint8_t *ptr) const
                break;
        }
        return value;
+#endif
 }
 
 void LogicSnapshot::pack_sample(uint8_t *ptr, uint64_t value)
 {
+#ifdef HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS
+       *(uint64_t*)ptr = value;
+#else
        switch(_unit_size) {
        default:
                ptr[7] = value >> 56;
@@ -126,6 +132,7 @@ void LogicSnapshot::pack_sample(uint8_t *ptr, uint64_t value)
        case 0:
                break;
        }
+#endif
 }
 
 void LogicSnapshot::append_payload(
@@ -155,7 +162,7 @@ void LogicSnapshot::get_samples(uint8_t *const data,
        lock_guard<recursive_mutex> lock(_mutex);
 
        const size_t size = (end_sample - start_sample) * _unit_size;
-       memcpy(data, (const uint8_t*)_data + start_sample, size);
+       memcpy(data, (const uint8_t*)_data + start_sample * _unit_size, size);
 }
 
 void LogicSnapshot::reallocate_mipmap_level(MipMapLevel &m)