1 | // Copyright 2019 The Marl Authors. |
2 | // |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | // you may not use this file except in compliance with the License. |
5 | // You may obtain a copy of the License at |
6 | // |
7 | // https://www.apache.org/licenses/LICENSE-2.0 |
8 | // |
9 | // Unless required by applicable law or agreed to in writing, software |
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | // See the License for the specific language governing permissions and |
13 | // limitations under the License. |
14 | |
15 | #include "marl/debug.h" |
16 | #include "marl/scheduler.h" |
17 | |
18 | #include <cstdarg> |
19 | #include <cstdlib> |
20 | |
21 | #include <stdarg.h> |
22 | #include <stdio.h> |
23 | #include <stdlib.h> |
24 | |
25 | namespace marl { |
26 | |
27 | void fatal(const char* msg, ...) { |
28 | va_list vararg; |
29 | va_start(vararg, msg); |
30 | vfprintf(stderr, msg, vararg); |
31 | va_end(vararg); |
32 | abort(); |
33 | } |
34 | |
35 | void warn(const char* msg, ...) { |
36 | va_list vararg; |
37 | va_start(vararg, msg); |
38 | vfprintf(stdout, msg, vararg); |
39 | va_end(vararg); |
40 | } |
41 | |
42 | void assert_has_bound_scheduler(const char* feature) { |
43 | (void)feature; // unreferenced parameter |
44 | MARL_ASSERT(Scheduler::get() != nullptr, |
45 | "%s requires a marl::Scheduler to be bound" , feature); |
46 | } |
47 | |
48 | } // namespace marl |
49 | |