mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 14:19:48 +00:00
Tests+Userland: Prefer using __builtin_trap() instead of UD2
This way we don't have to hard-code per-architecture instructions.
This commit is contained in:
parent
7a8206197e
commit
dadf656dc9
Notes:
sideshowbarker
2024-07-17 05:50:21 +09:00
Author: https://github.com/gunnarbeutner
Commit: dadf656dc9
Pull-request: https://github.com/SerenityOS/serenity/pull/15558
Reviewed-by: https://github.com/BertalanD
Reviewed-by: https://github.com/FireFox317
Reviewed-by: https://github.com/awesomekling ✅
Reviewed-by: https://github.com/linusg
3 changed files with 5 additions and 4 deletions
|
@ -113,7 +113,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
if (do_illegal_instruction || do_all_crash_types) {
|
if (do_illegal_instruction || do_all_crash_types) {
|
||||||
any_failures |= !Crash("Illegal instruction", []() {
|
any_failures |= !Crash("Illegal instruction", []() {
|
||||||
asm volatile("ud2");
|
__builtin_trap();
|
||||||
return Crash::Failure::DidNotCrash;
|
return Crash::Failure::DidNotCrash;
|
||||||
}).run(run_type);
|
}).run(run_type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ int main(int, char**)
|
||||||
pthread_create(
|
pthread_create(
|
||||||
&tid, nullptr, [](void*) -> void* {
|
&tid, nullptr, [](void*) -> void* {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
asm volatile("ud2");
|
__builtin_trap();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
},
|
},
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
|
@ -214,8 +214,9 @@ int atexit(void (*handler)())
|
||||||
|
|
||||||
void _abort()
|
void _abort()
|
||||||
{
|
{
|
||||||
asm volatile("ud2");
|
// According to the GCC manual __builtin_trap() can call abort() so using it here might not seem safe at first. However,
|
||||||
__builtin_unreachable();
|
// on all the platforms we support GCC emits an undefined instruction instead of a call.
|
||||||
|
__builtin_trap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void abort()
|
void abort()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue