Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove old wait any simcall
[simgrid.git] / src / simix / popping_generated.cpp
1 /**********************************************************************/
2 /* File generated by src/simix/simcalls.py from src/simix/simcalls.in */
3 /*                                                                    */
4 /*                    DO NOT EVER CHANGE THIS FILE                    */
5 /*                                                                    */
6 /* change simcalls specification in src/simix/simcalls.in             */
7 /* Copyright (c) 2014-2022. The SimGrid Team. All rights reserved.    */
8 /**********************************************************************/
9
10 /*
11  * Note that the name comes from http://en.wikipedia.org/wiki/Popping
12  * Indeed, the control flow is doing a strange dance in there.
13  *
14  * That's not about http://en.wikipedia.org/wiki/Poop, despite the odor :)
15  */
16
17 #include <simgrid/config.h>
18 #include <simgrid/host.h>
19 #include <xbt/base.h>
20 #if SIMGRID_HAVE_MC
21 #include "src/mc/mc_forward.hpp"
22 #endif
23 #include "src/kernel/activity/ConditionVariableImpl.hpp"
24 #include "src/kernel/actor/SimcallObserver.hpp"
25 #include "src/kernel/context/Context.hpp"
26
27 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
28
29 using simgrid::simix::Simcall;
30 /** @brief Simcalls' names (generated from src/simix/simcalls.in) */
31 constexpr std::array<const char*, simgrid::simix::NUM_SIMCALLS> simcall_names{{
32     "Simcall::NONE",
33     "Simcall::RUN_KERNEL",
34     "Simcall::RUN_BLOCKING",
35 }};
36
37 /** @private
38  * @brief (in kernel mode) unpack the simcall and activate the handler
39  *
40  * This function is generated from src/simix/simcalls.in
41  */
42 void simgrid::kernel::actor::ActorImpl::simcall_handle(int times_considered)
43 {
44   XBT_DEBUG("Handling simcall %p: %s", &simcall_, SIMIX_simcall_name(simcall_));
45   if (simcall_.observer_ != nullptr)
46     simcall_.observer_->prepare(times_considered);
47   if (context_->wannadie())
48     return;
49   switch (simcall_.call_) {
50     case Simcall::RUN_KERNEL:
51       SIMIX_run_kernel(simgrid::simix::unmarshal<std::function<void()> const*>(simcall_.args_[0]));
52       simcall_answer();
53       break;
54
55     case Simcall::RUN_BLOCKING:
56       SIMIX_run_blocking(simgrid::simix::unmarshal<std::function<void()> const*>(simcall_.args_[0]));
57       break;
58
59     case Simcall::NONE:
60       throw std::invalid_argument(simgrid::xbt::string_printf("Asked to do the noop syscall on %s@%s",
61                                                               get_cname(),
62                                                               sg_host_get_name(get_host())));
63     default:
64       THROW_IMPOSSIBLE;
65   }
66 }