File tree Expand file tree Collapse file tree 7 files changed +29
-7
lines changed
include/swift/SwiftRemoteMirror
tools/swift-reflection-test Expand file tree Collapse file tree 7 files changed +29
-7
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ extern "C" {
18
18
#endif
19
19
20
20
#if defined(swiftRemoteMirror_EXPORTS )
21
- # if defined(__ELF__ )
21
+ # if defined(__ELF__ ) || defined( __wasm__ )
22
22
# define SWIFT_REMOTE_MIRROR_LINKAGE __attribute__((__visibility__("protected")))
23
23
# elif defined(__MACH__ )
24
24
# define SWIFT_REMOTE_MIRROR_LINKAGE __attribute__((__visibility__("default")))
@@ -30,7 +30,7 @@ extern "C" {
30
30
# endif
31
31
# endif
32
32
#else
33
- # if defined(__ELF__ )
33
+ # if defined(__ELF__ ) || defined( __wasm__ )
34
34
# define SWIFT_REMOTE_MIRROR_LINKAGE __attribute__((__visibility__("default")))
35
35
# elif defined(__MACH__ )
36
36
# define SWIFT_REMOTE_MIRROR_LINKAGE __attribute__((__visibility__("default")))
Original file line number Diff line number Diff line change 26
26
27
27
#include " swift/Runtime/Config.h"
28
28
29
+ // WebAssembly: no signals on WASI yet
30
+ #ifndef __wasi__
31
+
29
32
static void CrashCatcher (int Sig) {
30
33
const char *Msg;
31
34
switch (Sig) {
@@ -65,11 +68,16 @@ VectoredCrashHandler(PEXCEPTION_POINTERS ExceptionInfo) {
65
68
}
66
69
#endif
67
70
71
+ #endif // __wasi__
72
+
68
73
SWIFT_CC (swift) SWIFT_RUNTIME_LIBRARY_VISIBILITY extern "C"
69
74
void installTrapInterceptor() {
70
75
// Disable buffering on stdout so that everything is printed before crashing.
71
76
setbuf (stdout, 0 );
72
77
78
+ // WebAssembly: no signals on WASI
79
+ #ifndef __wasi__
80
+
73
81
#if defined(_WIN32)
74
82
_set_abort_behavior (0 , _WRITE_ABORT_MSG);
75
83
#endif
@@ -85,5 +93,6 @@ void installTrapInterceptor() {
85
93
signal (SIGBUS, CrashCatcher);
86
94
signal (SIGSYS, CrashCatcher);
87
95
#endif
88
- }
89
96
97
+ #endif // __wasi__
98
+ }
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ import SwiftPrivateLibcExtras
41
41
import SwiftPrivateThreadExtras
42
42
#if os(macOS) || os(iOS)
43
43
import Darwin
44
- #elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku)
44
+ #elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku) || os(Wasm)
45
45
import Glibc
46
46
#elseif os(Windows)
47
47
import MSVCRT
@@ -562,7 +562,12 @@ class _InterruptibleSleep {
562
562
return
563
563
}
564
564
565
+ #if os(Wasm)
566
+ // WebAssembly/WASI on wasm32 is the only 32-bit platform with Int64 time_t
567
+ var timeout = timeval ( tv_sec: time_t ( duration) , tv_usec: 0 )
568
+ #else
565
569
var timeout = timeval ( tv_sec: duration, tv_usec: 0 )
570
+ #endif
566
571
567
572
var readFDs = _stdlib_fd_set ( )
568
573
var writeFDs = _stdlib_fd_set ( )
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import SwiftPrivate
14
14
import SwiftPrivateLibcExtras
15
15
#if os(macOS) || os(iOS)
16
16
import Darwin
17
- #elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku)
17
+ #elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku) || os(Wasm)
18
18
import Glibc
19
19
#elseif os(Windows)
20
20
import MSVCRT
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import SwiftPrivateLibcExtras
18
18
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
19
19
import Foundation
20
20
import Darwin
21
- #elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku)
21
+ #elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku) || os(Wasm)
22
22
import Glibc
23
23
#elseif os(Windows)
24
24
import MSVCRT
@@ -748,6 +748,8 @@ extension ProcessTerminationStatus {
748
748
case . signal( let signal) :
749
749
#if os(Windows)
750
750
return CInt ( signal) == SIGILL
751
+ #elseif os(Wasm)
752
+ return false
751
753
#else
752
754
return CInt ( signal) == SIGILL || CInt ( signal) == SIGTRAP
753
755
#endif
@@ -1746,6 +1748,7 @@ public enum OSVersion : CustomStringConvertible {
1746
1748
case windowsCygnus
1747
1749
case windows
1748
1750
case haiku
1751
+ case wasm
1749
1752
1750
1753
public var description : String {
1751
1754
switch self {
@@ -1777,6 +1780,8 @@ public enum OSVersion : CustomStringConvertible {
1777
1780
return " Windows "
1778
1781
case . haiku:
1779
1782
return " Haiku "
1783
+ case . wasm:
1784
+ return " Wasm "
1780
1785
}
1781
1786
}
1782
1787
}
@@ -1821,6 +1826,8 @@ func _getOSVersion() -> OSVersion {
1821
1826
return . windows
1822
1827
#elseif os(Haiku)
1823
1828
return . haiku
1829
+ #elseif os(Wasm)
1830
+ return . wasm
1824
1831
#else
1825
1832
let productVersion = _getSystemVersionPlistProperty ( " ProductVersion " ) !
1826
1833
let ( major, minor, bugFix) = _parseDottedVersionTriple ( productVersion)
Original file line number Diff line number Diff line change @@ -72,5 +72,6 @@ public let ${prefix}_TRUE_MIN = ${type}.leastNonzeroMagnitude
72
72
73
73
#if os(Wasm)
74
74
// WebAssembly's error.h uses a macro that Swift can't import.
75
+ public let EINTR:Int32 = 27
75
76
public let EINVAL:Int32 = 28
76
77
#endif
Original file line number Diff line number Diff line change 27
27
#include <stdio.h>
28
28
#include <stdlib.h>
29
29
#include <string.h>
30
- #if defined(__unix__ ) || (defined(__APPLE__ ) && defined(__MACH__ ))
30
+ #if defined(__unix__ ) || (defined(__APPLE__ ) && defined(__MACH__ )) || defined( __wasi__ )
31
31
#include <unistd.h>
32
32
#elif defined(_WIN32 )
33
33
#include <io.h>
You can’t perform that action at this time.
0 commit comments