Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sonar don't like comments ending with ';'
[simgrid.git] / src / mc / mc_hash.cpp
1 /* Copyright (c) 2014-2017. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <cinttypes>
8
9 #include <cstdint>
10
11 #include "xbt/log.h"
12
13 #include "mc/datatypes.h"
14 #include "src/mc/mc_hash.hpp"
15 #include "src/mc/mc_private.hpp"
16 #include "src/mc/mc_snapshot.hpp"
17 #include <mc/mc.h>
18
19 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_hash, mc, "Logging specific to mc_hash");
20
21 namespace simgrid {
22 namespace mc {
23
24 namespace {
25
26 class djb_hash {
27   hash_type state_ = 5381LL;
28
29 public:
30   template<class T>
31   void update(T& x)
32   {
33     state_ = (state_ << 5) + state_ + state_;
34   }
35   hash_type value()
36   {
37     return state_;
38   }
39 };
40
41 }
42
43 hash_type hash(Snapshot const& snapshot)
44 {
45   XBT_DEBUG("START hash %i", snapshot.num_state);
46   djb_hash hash;
47   // TODO, nb_processes
48   // TODO, heap_bytes_used
49   // TODO, root variables
50   // TODO, basic stack frame information
51   // TODO, stack frame local variables
52   XBT_DEBUG("END hash %i", snapshot.num_state);
53   return hash.value();
54 }
55
56 }
57 }