summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-11-30 09:26:05 +0100
committerDaniel Friesel <derf@finalrewind.org>2018-11-30 09:26:05 +0100
commitfd34ebda2f2d2858b5f0fe96feae53ae6a2c268f (patch)
tree184b29f63403f0e062526d7e978d5907b92bb415
parentd5636b932e111056e852316cdbe6a711a9643183 (diff)
XDR: Add float and double support
-rw-r--r--include/object/xdrinput.h2
-rw-r--r--src/os/object/xdrinput.cc12
2 files changed, 14 insertions, 0 deletions
diff --git a/include/object/xdrinput.h b/include/object/xdrinput.h
index f869a13..7b8ac40 100644
--- a/include/object/xdrinput.h
+++ b/include/object/xdrinput.h
@@ -15,6 +15,8 @@ class XDRInput {
int32_t get_int32();
uint64_t get_uint64();
int64_t get_int64();
+ float get_float();
+ double get_double();
uint32_t get_opaque_length();
char* get_opaque(uint32_t length);
};
diff --git a/src/os/object/xdrinput.cc b/src/os/object/xdrinput.cc
index 561c779..077f695 100644
--- a/src/os/object/xdrinput.cc
+++ b/src/os/object/xdrinput.cc
@@ -35,6 +35,18 @@ int64_t XDRInput::get_int64()
return (ret0 << 32) | ret1;
}
+float XDRInput::get_float()
+{
+ uint32_t val = get_uint32();
+ return *(float*)&val;
+}
+
+double XDRInput::get_double()
+{
+ uint64_t val = get_uint64();
+ return *(double*)&val;
+}
+
uint32_t XDRInput::get_opaque_length()
{
return get_uint32();