Skip to content

Commit 3f6f03b

Browse files
Rio Martinezgladhorn
authored andcommitted
chore: wasi support
This PR adds rudimentary WebAssembly/WASI support by excluding unsupported calls to non-implemented WASI/posix syscalls. This also adds an OS definition for WASI in Qt.
1 parent 8ba7ea4 commit 3f6f03b

5 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/corelib/global/qsystemdetection.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@
130130
#elif defined(__HAIKU__)
131131
# define Q_OS_HAIKU
132132
#elif defined(__MAKEDEPEND__)
133+
#elif defined(__wasi__)
134+
# define Q_OS_WASI
133135
#else
134136
# error "Qt has not been ported to this OS - see http://www.qt-project.org/"
135137
#endif

src/corelib/kernel/qeventdispatcher_unix.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,10 @@ int QThreadPipe::check(const pollfd &pfd)
196196

197197
QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate()
198198
{
199+
#if !defined(Q_OS_WASI)
199200
if (Q_UNLIKELY(threadPipe.init() == false))
200201
qFatal("QEventDispatcherUNIXPrivate(): Cannot continue without a thread pipe");
202+
#endif
201203
}
202204

203205
QEventDispatcherUNIXPrivate::~QEventDispatcherUNIXPrivate()

src/gui/painting/qgrayraster_p.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@
5555

5656
/* Minimum buffer size for raster object, that accounts
5757
for TWorker and TCell sizes.*/
58-
#define MINIMUM_POOL_SIZE 8192
58+
#if !defined(Q_OS_WASI)
59+
# define MINIMUM_POOL_SIZE 8192
60+
#else
61+
# define MINIMUM_POOL_SIZE 81920
62+
#endif
5963

6064
QT_FT_EXPORT_VAR( const QT_FT_Raster_Funcs ) QT_MANGLE_NAMESPACE(qt_ft_grays_raster);
6165

src/testlib/qtestcrashhandler_p.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace CrashHandler {
3939
bool alreadyDebugging();
4040
void blockUnixSignals();
4141

42-
#if !defined(Q_OS_WASM) || QT_CONFIG(thread)
42+
#if !(defined(Q_OS_WASM) || defined(Q_OS_WASI)) || QT_CONFIG(thread)
4343
void printTestRunTime();
4444
void generateStackTrace(quintptr ip = 0);
4545
#endif
@@ -54,7 +54,7 @@ namespace CrashHandler {
5454
WindowsFaultHandler();
5555
};
5656
using FatalSignalHandler = WindowsFaultHandler;
57-
#elif defined(Q_OS_UNIX) && !defined(Q_OS_WASM)
57+
#elif defined(Q_OS_UNIX) && !defined(Q_OS_WASM) && !defined(Q_OS_WASI)
5858
class Q_TESTLIB_EXPORT FatalSignalHandler
5959
{
6060
public:

src/testlib/qtestcrashhandler_unix.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ void generateStackTrace(quintptr ip)
414414
(void) prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
415415
# endif
416416

417-
# if !defined(Q_OS_INTEGRITY) && !defined(Q_OS_VXWORKS)
417+
# if !defined(Q_OS_INTEGRITY) && !defined(Q_OS_VXWORKS) && !defined(Q_OS_WASI)
418418
writeToStderr("\n=== Stack trace ===\n");
419419

420420
// execlp() requires null-termination, so call the default constructor
@@ -488,7 +488,7 @@ void generateStackTrace(quintptr ip)
488488
# endif // !Q_OS_INTEGRITY && !Q_OS_VXWORKS
489489
}
490490

491-
#ifndef Q_OS_WASM // no signal handling for WASM
491+
#if !(defined(Q_OS_WASM) || defined(Q_OS_WASI)) // no signal handling for WASM or WASI
492492
void blockUnixSignals()
493493
{
494494
// Block most Unix signals so the WatchDog thread won't be called when
@@ -827,7 +827,7 @@ void actionHandler(int signum, siginfo_t *info, void *ucontext)
827827
// we shouldn't reach here!
828828
std::abort();
829829
}
830-
#endif // !defined(Q_OS_WASM)
830+
#endif // !(defined(Q_OS_WASM) || defined(Q_OS_WASI))
831831

832832
} // namespace CrashHandler
833833
} // namespace QTest

0 commit comments

Comments
 (0)