Skip to content

Commit 6bed2c5

Browse files
committed
mark noreturn functions
it's not guaranteed that all implementations of `reboot()` are terminating calls. `reboot_os()`, externally defined at `src/arch/{x86_64,i686}/apic_asm.asm` both terminate, but this seems to be an implementation detail of the x86 architecture.
1 parent a5f5982 commit 6bed2c5

6 files changed

Lines changed: 8 additions & 10 deletions

File tree

api/arch.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#include <string>
2828

2929

30-
extern void __arch_poweroff();
31-
extern void __arch_reboot();
30+
[[noreturn]] extern void __arch_poweroff();
31+
[[noreturn]] extern void __arch_reboot();
3232
extern void __arch_enable_legacy_irq(uint8_t);
3333
extern void __arch_disable_legacy_irq(uint8_t);
3434
extern void __arch_system_deactivate();

api/os.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ namespace os {
8686
//
8787

8888
/** Trigger unrecoverable error and output diagnostics **/
89-
__attribute__((noreturn))
89+
[[noreturn]]
9090
void panic(const char* why) noexcept;
9191

9292
/** Default behavior after panic **/

src/kernel/syscalls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ extern kernel::ctor_t __plugin_ctors_end;
118118
* Print EOT character to stderr, to signal outside that PANIC output completed
119119
* If the handler returns, go to (permanent) sleep
120120
**/
121-
void os::panic(const char* why) noexcept
121+
[[noreturn]] void os::panic(const char* why) noexcept
122122
{
123123
cpu_enable_panicking();
124124
if (kernel::panics() > 4) double_fault(why);

src/platform/x86_pc/acpi.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,7 @@ namespace x86 {
393393
}
394394
}
395395

396-
__attribute__((noreturn))
397-
void ACPI::shutdown()
396+
[[noreturn]] void ACPI::shutdown()
398397
{
399398
asm("cli");
400399

src/platform/x86_pc/acpi.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ namespace x86 {
102102
}
103103

104104
static void reboot();
105-
static void shutdown();
105+
[[noreturn]] static void shutdown();
106106

107107
private:
108108
void discover();

src/platform/x86_pc/platform.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,11 @@ void __arch_disable_legacy_irq(uint8_t irq)
147147
x86::APIC::disable_irq(irq);
148148
}
149149

150-
void __arch_poweroff()
150+
[[noreturn]] void __arch_poweroff()
151151
{
152152
x86::ACPI::shutdown();
153-
__builtin_unreachable();
154153
}
155-
void __arch_reboot()
154+
[[noreturn]] void __arch_reboot()
156155
{
157156
x86::ACPI::reboot();
158157
__builtin_unreachable();

0 commit comments

Comments
 (0)