[libc-commits] [libc] [libc][i386] setjmp/longjmp (PR #112437)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Tue Oct 15 15:46:15 PDT 2024
================
@@ -7,15 +7,34 @@
//===----------------------------------------------------------------------===//
#include "src/setjmp/longjmp.h"
+#include "include/llvm-libc-macros/offsetof-macro.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
-#if !defined(LIBC_TARGET_ARCH_IS_X86_64)
+#if !defined(LIBC_TARGET_ARCH_IS_X86)
#error "Invalid file include"
#endif
namespace LIBC_NAMESPACE_DECL {
+#ifdef __i386__
+[[noreturn]]
+LLVM_LIBC_FUNCTION(void, longjmp, (jmp_buf buf, int val)) {
+ asm(R"(
----------------
nickdesaulniers wrote:
> but I don't think you can validly clobber ebp/esp
You can.
```diff
diff --git a/libc/src/setjmp/x86_64/setjmp.cpp b/libc/src/setjmp/x86_64/setjmp.cpp
index 90532c5654b3..b47db5c63e18 100644
--- a/libc/src/setjmp/x86_64/setjmp.cpp
+++ b/libc/src/setjmp/x86_64/setjmp.cpp
@@ -42,7 +42,7 @@ LLVM_LIBC_FUNCTION(int, setjmp, (jmp_buf buf)) {
[ebp] "i"(offsetof(__jmp_buf, ebp)),
[esp] "i"(offsetof(__jmp_buf, esp)),
[eip] "i"(offsetof(__jmp_buf, eip))
- : "eax", "ecx");
+ : "eax", "ecx", "ebx", "esi", "edi", "ebp", "esp");
}
#else
[[gnu::naked]]
```
compiles just fine.
https://github.com/llvm/llvm-project/pull/112437
More information about the libc-commits
mailing list