Logo AND Algorithmique Numérique Distribuée

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