1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Fix examples so they build on gcc 4.6

This commit is contained in:
Matias Fontanini
2016-02-21 14:59:19 -08:00
parent fa4178de09
commit 8bf0c355f4
2 changed files with 14 additions and 8 deletions

View File

@@ -31,6 +31,9 @@
#define NOMINMAX #define NOMINMAX
#endif // _WIN32 #endif // _WIN32
// Fix for gcc 4.6
#define _GLIBCXX_USE_NANOSLEEP
#include <iostream> #include <iostream>
#include <mutex> #include <mutex>
#include <chrono> #include <chrono>
@@ -65,8 +68,8 @@ using namespace Tins;
template<typename Duration> template<typename Duration>
class statistics { class statistics {
public: public:
using duration_type = Duration; typedef Duration duration_type;
using locker_type = lock_guard<mutex>; typedef lock_guard<mutex> locker_type;
struct information { struct information {
duration_type average, worst; duration_type average, worst;
@@ -108,18 +111,18 @@ private:
class dns_monitor { class dns_monitor {
public: public:
// The response times are measured in milliseconds // The response times are measured in milliseconds
using duration_type = milliseconds; typedef milliseconds duration_type;
// The statistics type used. // The statistics type used.
using statistics_type = statistics<duration_type>; typedef statistics<duration_type> statistics_type;
void run(BaseSniffer& sniffer); void run(BaseSniffer& sniffer);
const statistics_type& stats() const { const statistics_type& stats() const {
return m_stats; return m_stats;
} }
private: private:
using packet_info = tuple<IPv4Address, IPv4Address, uint16_t>; typedef tuple<IPv4Address, IPv4Address, uint16_t> packet_info;
using clock_type = system_clock; typedef system_clock clock_type;
using time_point_type = clock_type::time_point; typedef clock_type::time_point time_point_type;
bool callback(const PDU& pdu); bool callback(const PDU& pdu);
static packet_info make_packet_info(const PDU& pdu, const DNS& dns); static packet_info make_packet_info(const PDU& pdu, const DNS& dns);

View File

@@ -31,6 +31,9 @@
#define NOMINMAX #define NOMINMAX
#endif // _WIN32 #endif // _WIN32
// Fix for gcc 4.6
#define _GLIBCXX_USE_NANOSLEEP
#include <iostream> #include <iostream>
#include <chrono> #include <chrono>
#include <thread> #include <thread>
@@ -128,7 +131,7 @@ private:
} }
sender.send(ip); sender.send(ip);
// Give him a little time // Give it a little time
sleep_for(milliseconds(100)); sleep_for(milliseconds(100));
} }
running = false; running = false;