diff --git a/src/sim/serialize.hh b/src/sim/serialize.hh index 024d29cbbd..b3081ad5a0 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 @@ -51,6 +51,7 @@ #define __SERIALIZE_HH__ +#include #include #include #include @@ -144,6 +145,31 @@ void arrayParamIn(CheckpointIn &cp, const std::string &name, void objParamIn(CheckpointIn &cp, const std::string &name, SimObject * ¶m); +template +static void +arrayParamOut(CheckpointOut &cp, const std::string &name, + const BitUnionType *param, unsigned size) +{ + // We copy the array into a vector. This is needed since we cannot + // directly typecast a pointer to BitUnionType into a pointer + // of BitUnionBaseType but we can typecast BitUnionType + // to BitUnionBaseType since we overloaded the typecast operator + std::vector> bitunion_vec(param, param + size); + + arrayParamOut(cp, name, bitunion_vec); +} + +template +static void +arrayParamIn(CheckpointIn &cp, const std::string &name, + BitUnionType *param, unsigned size) +{ + std::vector> 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