Skip to content

Commit f6e8b26

Browse files
[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.
1 parent 8d5b81a commit f6e8b26

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

libc/src/__support/StringUtil/platform_errors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_PLATFORM_ERRORS_H
1010
#define LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_PLATFORM_ERRORS_H
1111

12-
#if defined(__linux__) || defined(__Fuchsia__)
12+
#if defined(__linux__) || defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
1313
#include "tables/linux_platform_errors.h"
1414
#else
1515
#include "tables/minimal_platform_errors.h"

libc/src/__support/macros/properties/architectures.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
#define LIBC_TARGET_ARCH_IS_ARM
4242
#endif
4343

44+
#if defined(__wasm__)
45+
#define LIBC_TARGET_ARCH_IS_WASM
46+
#endif
47+
4448
#if defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64)
4549
#define LIBC_TARGET_ARCH_IS_AARCH64
4650
#endif

libc/src/setjmp/wasm/sigsetjmp.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Implementation of sigsetjmp ---------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/setjmp/sigsetjmp.h"
10+
#include "hdr/offsetof_macros.h"
11+
#include "src/__support/common.h"
12+
13+
namespace LIBC_NAMESPACE_DECL {
14+
[[gnu::returns_twice]] int sigsetjmp(jmp_buf sigjmp_buf,
15+
[[maybe_unused]] int savesigs) {
16+
return setjmp(sigjmp_buf);
17+
}
18+
} // namespace LIBC_NAMESPACE_DECL

0 commit comments

Comments
 (0)