[libc-commits] [libc] f6e8b26 - [libc] Add wasm support for some submodules in llvm-libc. (#154383)
via libc-commits
libc-commits at lists.llvm.org
Thu Sep 4 08:26:26 PDT 2025
Author: google-yfyang
Date: 2025-09-04T11:26:21-04:00
New Revision: f6e8b26eab8324a60f437fdb3e88e5d5105c9845
URL: https://github.com/llvm/llvm-project/commit/f6e8b26eab8324a60f437fdb3e88e5d5105c9845
DIFF: https://github.com/llvm/llvm-project/commit/f6e8b26eab8324a60f437fdb3e88e5d5105c9845.diff
LOG: [libc] Add wasm support for some submodules in llvm-libc. (#154383)
Introducing several emscripten-specific changes to the llvm-libc headers
as well as adding a wasm sigsetjmp.cpp.
Added:
libc/src/setjmp/wasm/sigsetjmp.cpp
Modified:
libc/src/__support/StringUtil/platform_errors.h
libc/src/__support/macros/properties/architectures.h
Removed:
################################################################################
diff --git a/libc/src/__support/StringUtil/platform_errors.h b/libc/src/__support/StringUtil/platform_errors.h
index 32e8414b3e3de..5f83865482e72 100644
--- a/libc/src/__support/StringUtil/platform_errors.h
+++ b/libc/src/__support/StringUtil/platform_errors.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_PLATFORM_ERRORS_H
#define LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_PLATFORM_ERRORS_H
-#if defined(__linux__) || defined(__Fuchsia__)
+#if defined(__linux__) || defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
#include "tables/linux_platform_errors.h"
#else
#include "tables/minimal_platform_errors.h"
diff --git a/libc/src/__support/macros/properties/architectures.h b/libc/src/__support/macros/properties/architectures.h
index ecc93196be286..21e9bc4288cd7 100644
--- a/libc/src/__support/macros/properties/architectures.h
+++ b/libc/src/__support/macros/properties/architectures.h
@@ -41,6 +41,10 @@
#define LIBC_TARGET_ARCH_IS_ARM
#endif
+#if defined(__wasm__)
+#define LIBC_TARGET_ARCH_IS_WASM
+#endif
+
#if defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64)
#define LIBC_TARGET_ARCH_IS_AARCH64
#endif
diff --git a/libc/src/setjmp/wasm/sigsetjmp.cpp b/libc/src/setjmp/wasm/sigsetjmp.cpp
new file mode 100644
index 0000000000000..e9dfb3f837e75
--- /dev/null
+++ b/libc/src/setjmp/wasm/sigsetjmp.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of sigsetjmp ---------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/setjmp/sigsetjmp.h"
+#include "hdr/offsetof_macros.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE_DECL {
+[[gnu::returns_twice]] int sigsetjmp(jmp_buf sigjmp_buf,
+ [[maybe_unused]] int savesigs) {
+ return setjmp(sigjmp_buf);
+}
+} // namespace LIBC_NAMESPACE_DECL
More information about the libc-commits
mailing list