Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
code simplification around simgrid::surf::NetCardImpl
[simgrid.git] / src / mc / mc_hash.cpp
1 /* Copyright (c) 2014-2015. 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 "src/mc/mc_private.h"
12 #include "mc/datatypes.h"
13 #include "src/mc/mc_hash.hpp"
14 #include <mc/mc.h>
15
16 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_hash, mc, "Logging specific to mc_hash");
17
18 namespace simgrid {
19 namespace mc {
20
21 namespace {
22
23 class djb_hash {
24   hash_type state_ = 5381ll;
25 public:
26   template<class T>
27   void update(T& x)
28   {
29     state_ = (state_ << 5) + state_ + state_;
30   }
31   hash_type value()
32   {
33     return state_;
34   }
35 };
36
37 }
38
39 hash_type hash(Snapshot const& snapshot)
40 {
41   XBT_DEBUG("START hash %i", snapshot.num_state);
42   djb_hash hash;
43   // TODO, nb_processes
44   // TODO, heap_bytes_used
45   // TODO, root variables
46   // TODO, basic stack frame information
47   // TODO, stack frame local variables
48   XBT_DEBUG("END hash %i", snapshot.num_state);
49   return hash.value();
50 }
51
52 }
53 }