[libc-commits] [libc] [libc][i386] setjmp/longjmp (PR #112437)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Wed Oct 16 10:00:49 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"(
+ mov %[ebx], %%ebx
+ mov %[esi], %%esi
+ mov %[edi], %%edi
+ mov %[ebp], %%ebp
+ mov %[esp], %%esp
+
+ jmp *%[eip]
+ )" ::[ebx] "m"(buf->ebx),
+ [esi] "m"(buf->esi), [edi] "m"(buf->edi), [ebp] "m"(buf->ebp),
+ [esp] "m"(buf->esp), [eip] "m"(buf->eip), [val] "a"(val == 0 ? 1 : val));
+ __builtin_unreachable();
+}
+#else
+[[noreturn]]
LLVM_LIBC_FUNCTION(void, longjmp, (jmp_buf buf, int val)) {
----------------
nickdesaulniers wrote:
https://github.com/llvm/llvm-project/pull/112581
https://github.com/llvm/llvm-project/pull/112437
More information about the libc-commits
mailing list