From 67166266c423fda607b05df82b34bca65211bc8b Mon Sep 17 00:00:00 2001 From: CodeLongAndProsper90 <50145141+CodeLongAndProsper90@users.noreply.github.com> Date: Mon, 17 Feb 2020 15:27:18 -0600 Subject: [PATCH] Add optional parameter to syscall reboot/shutdown (#22) * Add optional parameter to syscall reboot/shutdown Added a optional parameter to tlib::shutdown and tlib::reboot that waits the number of seconds, to enable timed shutdowns/reboots --- tlib/src/system.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tlib/src/system.cpp b/tlib/src/system.cpp index 01ebf485..b8c932a7 100644 --- a/tlib/src/system.cpp +++ b/tlib/src/system.cpp @@ -99,7 +99,10 @@ std::expected tlib::exec_and_wait(const char* executable, const std::vec return std::move(result); } -void tlib::reboot(){ +void tlib::reboot(int delay=0) { + if (delay != 0) { + tlib::sleep_ms(1000 * delay); + } asm volatile("mov rax, 0x50; int 50" : //No outputs : //No inputs @@ -108,7 +111,10 @@ void tlib::reboot(){ __builtin_unreachable(); } -void tlib::shutdown(){ +void tlib::shutdown(int delay=0){ + if (delay != 0) { + tlib::sleep_ms(1000 * delay); + } asm volatile("mov rax, 0x51; int 50" : //No outputs : //No inputs