Deleted Added
sdiff udiff text old ( 13414:1b5387dccec3 ) new ( 13415:dfba7ea400e2 )
full compact
1/*
2 * Copyright (c) 2015, 2018 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 271 unchanged lines hidden (view full) ---

280
281template <class T>
282void
283showParam(CheckpointOut &os, const T &value)
284{
285 os << value;
286}
287
288// Treat 8-bit ints (chars) as ints on output, not as chars
289template <>
290inline void
291showParam(CheckpointOut &os, const char &value)
292{
293 os << (int)value;
294}
295

--- 53 unchanged lines hidden (view full) ---

349void
350paramOut(CheckpointOut &os, const std::string &name, const T &param)
351{
352 os << name << "=";
353 showParam(os, param);
354 os << "\n";
355}
356
357template <typename T>
358void
359paramOut(CheckpointOut &cp, const std::string &name, const BitUnionType<T> &p)
360{
361 paramOut(cp, name, static_cast<BitUnionBaseType<T> >(p));
362}
363
364template <class T>
365void
366paramIn(CheckpointIn &cp, const std::string &name, T &param)
367{
368 const std::string &section(Serializable::currentSection());
369 std::string str;
370 if (!cp.find(section, name, str) || !parseParam(str, param)) {
371 fatal("Can't unserialize '%s:%s'\n", section, name);
372 }
373}
374
375template <typename T>
376void
377paramIn(CheckpointIn &cp, const std::string &name, BitUnionType<T> &p)
378{
379 BitUnionBaseType<T> b;
380 paramIn(cp, name, b);
381 p = b;
382}
383
384template <class T>
385bool
386optParamIn(CheckpointIn &cp, const std::string &name,
387 T &param, bool warn = true)
388{
389 const std::string &section(Serializable::currentSection());
390 std::string str;
391 if (!cp.find(section, name, str) || !parseParam(str, param)) {
392 if (warn)
393 warn("optional parameter %s:%s not present\n", section, name);
394 return false;
395 } else {
396 return true;
397 }
398}
399
400template <typename T>
401bool
402optParamIn(CheckpointIn &cp, const std::string &name,
403 BitUnionType<T> &p, bool warn = true)
404{
405 BitUnionBaseType<T> b;
406 if (optParamIn(cp, name, b, warn)) {
407 p = b;
408 return true;
409 } else {
410 return false;
411 }
412}
413
414template <class T>
415void
416arrayParamOut(CheckpointOut &os, const std::string &name,
417 const std::vector<T> &param)
418{
419 typename std::vector<T>::size_type size = param.size();
420 os << name << "=";
421 if (size > 0)

--- 201 unchanged lines hidden (view full) ---

623 fatal(err);
624 }
625
626 // assign parsed value to vector
627 param.insert(scalar_value);
628 }
629}
630
631template <class T>
632static void
633arrayParamOut(CheckpointOut &cp, const std::string &name,
634 const BitUnionType<T> *param, unsigned size)
635{
636 // We copy the array into a vector. This is needed since we cannot
637 // directly typecast a pointer to BitUnionType<T> into a pointer
638 // of BitUnionBaseType<T> but we can typecast BitUnionType<T>
639 // to BitUnionBaseType<T> since we overloaded the typecast operator
640 std::vector<BitUnionBaseType<T>> bitunion_vec(param, param + size);
641
642 arrayParamOut(cp, name, bitunion_vec);
643}
644
645template <class T>
646static void
647arrayParamIn(CheckpointIn &cp, const std::string &name,
648 BitUnionType<T> *param, unsigned size)
649{
650 std::vector<BitUnionBaseType<T>> bitunion_vec(size);
651
652 arrayParamIn(cp, name, bitunion_vec);
653 std::copy(bitunion_vec.begin(), bitunion_vec.end(), param);
654}
655
656void
657debug_serialize(const std::string &cpt_dir);
658
659void
660objParamIn(CheckpointIn &cp, const std::string &name, SimObject * &param);
661
662//
663// These macros are streamlined to use in serialize/unserialize

--- 50 unchanged lines hidden ---