Browse Source

detect 64-bit platform on windows, gcc, clang, arm and ppc

sources:
Use of #ifdef __LP64__ suggested by @brynet.
https://stackoverflow.com/a/40033930
pull/256/head
Nam Nguyen 7 years ago committed by Robin Eklind
parent
commit
7e2bd7c967
  1. 11
      SourceX/dvlnet/frame_queue.cpp
  2. 11
      SourceX/dvlnet/frame_queue.h

11
SourceX/dvlnet/frame_queue.cpp

@ -7,12 +7,12 @@
namespace dvl {
namespace net {
size_t frame_queue::size()
framesize_t frame_queue::size()
{
return current_size;
}
buffer_t frame_queue::read(size_t s)
buffer_t frame_queue::read(framesize_t s)
{
if(current_size < s)
throw frame_queue_exception();
@ -48,12 +48,7 @@ bool frame_queue::packet_ready()
if(size() < sizeof(framesize_t))
return false;
auto szbuf = read(sizeof(framesize_t));
#ifdef __LP64__
std::memcpy(&nextsize, &szbuf[0], sizeof(framesize_t));
nextsize >> 32;
#else
std::memcpy(&nextsize, &szbuf[0], sizeof(nextsize));
#endif
if(!nextsize)
throw frame_queue_exception();
}
@ -77,7 +72,7 @@ buffer_t frame_queue::make_frame(buffer_t packetbuf)
buffer_t ret;
if(packetbuf.size() > max_frame_size)
ABORT();
frame_queue::framesize_t size = packetbuf.size();
framesize_t size = packetbuf.size();
ret.insert(ret.end(), packet_out::begin(size), packet_out::end(size));
ret.insert(ret.end(), packetbuf.begin(), packetbuf.end());
return std::move(ret);

11
SourceX/dvlnet/frame_queue.h

@ -9,17 +9,18 @@ namespace net {
class frame_queue_exception : public dvlnet_exception {};
typedef uint32_t framesize_t;
class frame_queue {
public:
typedef uint32_t framesize_t;
constexpr static framesize_t max_frame_size = 0xFFFF;
private:
size_t current_size = 0;
framesize_t current_size = 0;
std::deque<buffer_t> buffer_deque;
size_t nextsize = 0;
framesize_t nextsize = 0;
size_t size();
buffer_t read(size_t s);
framesize_t size();
buffer_t read(framesize_t s);
public:
bool packet_ready();
buffer_t read_packet();

Loading…
Cancel
Save