Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[travis] detect linux as we should
[simgrid.git] / src / mc / mc_xbt.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 <xbt/sysdep.h>
8
9 #include "mc/AddressSpace.hpp"
10 #include "mc_xbt.hpp"
11
12 namespace simgrid {
13 namespace mc {
14
15 void read_element(AddressSpace const& as,
16   void* local, remote_ptr<s_xbt_dynar_t> addr, size_t i, size_t len)
17 {
18   s_xbt_dynar_t d;
19   as.read_bytes(&d, sizeof(d), addr);
20   if (i >= d.used)
21     xbt_die("Out of bound index %zi/%lu", i, d.used);
22   if (len != d.elmsize)
23     xbt_die("Bad size in simgrid::mc::read_element");
24   as.read_bytes(local, len, remote(xbt_dynar_get_ptr(&d, i)));
25 }
26
27 std::size_t read_length(AddressSpace const& as, remote_ptr<s_xbt_dynar_t> addr)
28 {
29   if (!addr)
30     return 0;
31   unsigned long res;
32   as.read_bytes(&res, sizeof(res),
33     remote(&((xbt_dynar_t)addr.address())->used));
34   return res;
35 }
36
37 }
38 }