Giacomo Travaglini has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/12924

Change subject: sim: Extend (UN)SERIALIZE_ARRAY to BitUnions
......................................................................

sim: Extend (UN)SERIALIZE_ARRAY to BitUnions

This patch is making it possible to use SERIALIZE_ARRAY and UNSERIALIZE
array for serializing arrays of BitUnions.

Change-Id: I682766b472585f70a89338f373fb94dff5db53c3
Signed-off-by: Giacomo Travaglini <[email protected]>
---
M src/sim/serialize.hh
1 file changed, 26 insertions(+), 1 deletion(-)



diff --git a/src/sim/serialize.hh b/src/sim/serialize.hh
index 024d29c..b43da22 100644
--- a/src/sim/serialize.hh
+++ b/src/sim/serialize.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 ARM Limited
+ * Copyright (c) 2015, 2018 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -144,6 +144,31 @@
 void
 objParamIn(CheckpointIn &cp, const std::string &name, SimObject * &param);

+template <class T>
+void
+arrayParamOut(CheckpointOut &cp, const std::string &name,
+              const BitUnionType<T> *param, unsigned size)
+{
+    // We copy the array into a vector. This is needed since we cannot
+    // directly typecast a pointer to BitUnionType<T> into a pointer
+    // of BitUnionBaseType<T> but we can typecast BitUnionType<T>
+    // to BitUnionBaseType<T> since we overloaded the typecast operator
+    std::vector<BitUnionBaseType<T>> bitunion_vec(param, param + size);
+
+    arrayParamOut(cp, name, bitunion_vec);
+}
+
+template <class T>
+void
+arrayParamIn(CheckpointIn &cp, const std::string &name,
+             BitUnionType<T> *param, unsigned size)
+{
+    std::vector<BitUnionBaseType<T>> bitunion_vec(size);
+
+    arrayParamIn(cp, name, bitunion_vec);
+    std::copy(bitunion_vec.begin(), bitunion_vec.end(), param);
+}
+
 //
 // These macros are streamlined to use in serialize/unserialize
 // functions.  It's assumed that serialize() has a parameter 'os' for

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12924
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I682766b472585f70a89338f373fb94dff5db53c3
Gerrit-Change-Number: 12924
Gerrit-PatchSet: 1
Gerrit-Owner: Giacomo Travaglini <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to