AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
system.h
1#ifndef UTILS_SYSTEM_H
2#define UTILS_SYSTEM_H
3
4#define LINUX 0
5#define OSX 1
6#define WINDOWS 2
7
8#if defined(_WIN32)
9#define OPERATING_SYSTEM WINDOWS
10#include "downward/utils/system_windows.h"
11#elif defined(__APPLE__)
12#define OPERATING_SYSTEM OSX
13#include "downward/utils/system_unix.h"
14#else
15#define OPERATING_SYSTEM LINUX
16#include "downward/utils/system_unix.h"
17#endif
18
19#include <iostream>
20#include <stdlib.h>
21
22#define ABORT(msg) \
23 ((std::cerr << "Critical error in file " << __FILE__ << ", line " \
24 << __LINE__ << ": " << std::endl \
25 << (msg) << std::endl), \
26 (abort()), \
27 (void)0)
28
29namespace utils {
30enum class ExitCode {
31 /*
32 For a full list of exit codes, please see driver/returncodes.py. Here,
33 we only list codes that are used by the search component of the planner.
34 */
35 // 0-9: exit codes denoting a plan was found
36 SUCCESS = 0,
37
38 // 10-19: exit codes denoting no plan was found (without any error)
39 SEARCH_UNSOLVABLE = 11, // Task is provably unsolvable with given bound.
40 SEARCH_UNSOLVED_INCOMPLETE = 12, // Search ended without finding a solution.
41
42 // 20-29: "expected" failures
43 SEARCH_OUT_OF_MEMORY = 22,
44 SEARCH_OUT_OF_TIME = 23,
45
46 // 30-39: unrecoverable errors
47 SEARCH_CRITICAL_ERROR = 32,
48 SEARCH_INPUT_ERROR = 33,
49 SEARCH_UNSUPPORTED = 34,
50 SEARCH_UNIMPLEMENTED = 35
51};
52
53[[noreturn]]
54extern void exit_with(ExitCode returncode);
55[[noreturn]]
56extern void exit_with_reentrant(ExitCode returncode);
57
58int get_peak_memory_in_kb();
59const char* get_exit_code_message_reentrant(ExitCode exitcode);
60bool is_exit_code_error_reentrant(ExitCode exitcode);
61void register_event_handlers();
62void report_exit_code_reentrant(ExitCode exitcode);
63int get_process_id();
64} // namespace utils
65
66#endif