diff options
author | Scott Torborg <storborg@gmail.com> | 2018-05-22 08:55:35 -0700 |
---|---|---|
committer | Andrej Rode <mail@andrejro.de> | 2019-01-26 14:06:12 +0100 |
commit | 76dd4323a400cd5082290b4738ea1247f1100251 (patch) | |
tree | c2d736f4e331afe0758efa0da8254a615e2fce41 | |
parent | 7074f054c25a69392e7ae4e1f0204a1c5ce242f8 (diff) |
pmt: Add support for serializing/deserializing signed int64s
-rw-r--r-- | gnuradio-runtime/include/pmt/pmt_serial_tags.h | 1 | ||||
-rw-r--r-- | gnuradio-runtime/lib/pmt/pmt_serialize.cc | 23 |
2 files changed, 16 insertions, 8 deletions
diff --git a/gnuradio-runtime/include/pmt/pmt_serial_tags.h b/gnuradio-runtime/include/pmt/pmt_serial_tags.h index ea89693a49..c44247f4c2 100644 --- a/gnuradio-runtime/include/pmt/pmt_serial_tags.h +++ b/gnuradio-runtime/include/pmt/pmt_serial_tags.h @@ -40,6 +40,7 @@ enum pst_tags { PST_UNIFORM_VECTOR = 0x0a, PST_UINT64 = 0x0b, PST_TUPLE = 0x0c, + PST_INT64 = 0x0d, UVI_ENDIAN_MASK = 0x80, UVI_SUBTYPE_MASK = 0x7f, UVI_LITTLE_ENDIAN = 0x00, diff --git a/gnuradio-runtime/lib/pmt/pmt_serialize.cc b/gnuradio-runtime/lib/pmt/pmt_serialize.cc index 12a97b974c..37114139c0 100644 --- a/gnuradio-runtime/lib/pmt/pmt_serialize.cc +++ b/gnuradio-runtime/lib/pmt/pmt_serialize.cc @@ -285,14 +285,16 @@ serialize(pmt_t obj, std::streambuf &sb) } else { if(is_integer(obj)) { - long i = to_long(obj); - if(sizeof(long) > 4) { - if(i < -2147483647 || i > 2147483647) - throw notimplemented("pmt::serialize (64-bit integers)", obj); - } - ok = serialize_untagged_u8(PST_INT32, sb); - ok &= serialize_untagged_u32(i, sb); - return ok; + long i = to_long(obj); + if((sizeof(long) > 4) && ((i < -2147483647 || i > 2147483647))) { + // Serializing as 4 bytes won't work for this value, serialize as 8 bytes + ok = serialize_untagged_u8(PST_INT64, sb); + ok &= serialize_untagged_u64(i, sb); + } else { + ok = serialize_untagged_u8(PST_INT32, sb); + ok &= serialize_untagged_u32(i, sb); + } + return ok; } } @@ -566,6 +568,11 @@ deserialize(std::streambuf &sb) goto error; return from_uint64(u64); + case PST_INT64: + if(!deserialize_untagged_u64(&u64, sb)) + goto error; + return from_long(u64); + case PST_PAIR: return parse_pair(sb); |