From a0f880ec4ae79f12d4ed1358f34338d861aad32b Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> Date: Mon, 13 Feb 2023 19:37:32 +1000 Subject: Fix build for Haiku diff --git a/Source/JavaScriptCore/API/glib/JSCOptions.cpp b/Source/JavaScriptCore/API/glib/JSCOptions.cpp index dd46ff5..54f6dac 100644 --- a/Source/JavaScriptCore/API/glib/JSCOptions.cpp +++ b/Source/JavaScriptCore/API/glib/JSCOptions.cpp @@ -73,7 +73,7 @@ static void valueToGValue(int32_t value, GValue* gValue) g_value_set_int(gValue, value); } -#if CPU(ADDRESS64) +#if CPU(ADDRESS64) || OS(HAIKU) static bool valueFromGValue(const GValue* gValue, unsigned& value) { value = g_value_get_uint(gValue); @@ -556,7 +556,7 @@ static JSCOptionType jscOptionsType(int) return JSC_OPTION_INT; } -#if CPU(ADDRESS64) +#if CPU(ADDRESS64) || OS(HAIKU) static JSCOptionType jscOptionsType(unsigned) { return JSC_OPTION_UINT; diff --git a/Source/JavaScriptCore/heap/BlockDirectory.cpp b/Source/JavaScriptCore/heap/BlockDirectory.cpp index f9df6f0..b456f9a 100644 --- a/Source/JavaScriptCore/heap/BlockDirectory.cpp +++ b/Source/JavaScriptCore/heap/BlockDirectory.cpp @@ -60,7 +60,7 @@ void BlockDirectory::setSubspace(Subspace* subspace) void BlockDirectory::updatePercentageOfPagedOutPages(SimpleStats& stats) { // FIXME: We should figure out a solution for Windows. -#if OS(UNIX) +#if OS(UNIX) && !OS(HAIKU) size_t pageSize = WTF::pageSize(); ASSERT(!(MarkedBlock::blockSize % pageSize)); auto numberOfPagesInMarkedBlock = MarkedBlock::blockSize / pageSize; diff --git a/Source/JavaScriptCore/inspector/remote/Socket.cmake b/Source/JavaScriptCore/inspector/remote/Socket.cmake index e52143c..4ac504c 100644 --- a/Source/JavaScriptCore/inspector/remote/Socket.cmake +++ b/Source/JavaScriptCore/inspector/remote/Socket.cmake @@ -33,3 +33,9 @@ else () wsock32 ) endif () + +if (HAIKU) + list(APPEND JavaScriptCore_LIBRARIES + network + ) +endif () diff --git a/Source/JavaScriptCore/runtime/Options.cpp b/Source/JavaScriptCore/runtime/Options.cpp index c94723d..eb09ee1 100644 --- a/Source/JavaScriptCore/runtime/Options.cpp +++ b/Source/JavaScriptCore/runtime/Options.cpp @@ -92,7 +92,7 @@ std::optional parse(const char* string) return std::nullopt; } -#if CPU(ADDRESS64) || OS(DARWIN) +#if CPU(ADDRESS64) || OS(DARWIN) || OS(HAIKU) template<> std::optional parse(const char* string) { @@ -101,7 +101,7 @@ std::optional parse(const char* string) return value; return std::nullopt; } -#endif // CPU(ADDRESS64) || OS(DARWIN) +#endif // CPU(ADDRESS64) || OS(DARWIN) || OS(HAIKU) template<> std::optional parse(const char* string) diff --git a/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp b/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp index 0674973..7f6c924 100644 --- a/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp +++ b/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp @@ -360,7 +360,11 @@ CodePtr WebAssemblyFunction::jsCallEntrypointSlow() #if !CPU(ARM) // ARM has no pinned registers for Wasm Memory, so no need to set them up if (!!instance()->instance().module().moduleInformation().memory) { auto mode = instance()->memoryMode(); +#if ENABLE(WEBASSEMBLY_SIGNALING_MEMORY) if (mode == MemoryMode::Signaling || (mode == MemoryMode::BoundsChecking && instance()->instance().memory()->sharingMode() == MemorySharingMode::Shared)) { +#else + if (mode == MemoryMode::BoundsChecking && instance()->instance().memory()->sharingMode() == MemorySharingMode::Shared) { +#endif // Capacity and basePointer will not be changed. if (mode == MemoryMode::BoundsChecking) jit.move(CCallHelpers::TrustedImm64(instance()->instance().memory()->mappedCapacity()), GPRInfo::wasmBoundsCheckingSizeRegister); diff --git a/Source/ThirdParty/ANGLE/src/common/system_utils_posix.cpp b/Source/ThirdParty/ANGLE/src/common/system_utils_posix.cpp index 952f09e..c1e524f 100644 --- a/Source/ThirdParty/ANGLE/src/common/system_utils_posix.cpp +++ b/Source/ThirdParty/ANGLE/src/common/system_utils_posix.cpp @@ -210,10 +210,12 @@ void *OpenSystemLibraryWithExtensionAndGetError(const char *libraryName, } int extraFlags = 0; +#ifndef __HAIKU__ if (searchType == SearchType::AlreadyLoaded) { extraFlags = RTLD_NOLOAD; } +#endif std::string fullPath = directory + libraryName; return OpenPosixLibrary(fullPath, extraFlags, errorOut); diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/Context.cpp b/Source/ThirdParty/ANGLE/src/libANGLE/Context.cpp index 0b8387e..3e11f12 100644 --- a/Source/ThirdParty/ANGLE/src/libANGLE/Context.cpp +++ b/Source/ThirdParty/ANGLE/src/libANGLE/Context.cpp @@ -443,7 +443,7 @@ void SetCurrentValidContextTLS(Context *context) SetTLSValue(CurrentValidContextIndex, context); } #else -thread_local Context *gCurrentValidContext = nullptr; +__thread Context *gCurrentValidContext = nullptr; #endif Context::Context(egl::Display *display, diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/Context.h b/Source/ThirdParty/ANGLE/src/libANGLE/Context.h index 9350bda..054fff2 100644 --- a/Source/ThirdParty/ANGLE/src/libANGLE/Context.h +++ b/Source/ThirdParty/ANGLE/src/libANGLE/Context.h @@ -895,7 +895,7 @@ class [[nodiscard]] ScopedContextRef extern Context *GetCurrentValidContextTLS(); extern void SetCurrentValidContextTLS(Context *context); #else -extern thread_local Context *gCurrentValidContext; +extern __thread Context *gCurrentValidContext; #endif } // namespace gl diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/global_state.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/global_state.cpp index f807cd2..3d975f0 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/global_state.cpp +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/global_state.cpp @@ -147,7 +147,7 @@ void SetCurrentThreadTLS(Thread *thread) SetTLSValue(CurrentThreadIndex, thread); } #else -thread_local Thread *gCurrentThread = nullptr; +__thread Thread *gCurrentThread = nullptr; #endif angle::GlobalMutex &GetGlobalMutex() diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/global_state.h b/Source/ThirdParty/ANGLE/src/libGLESv2/global_state.h index 344eb45..bf2b437 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/global_state.h +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/global_state.h @@ -104,7 +104,7 @@ class Thread; extern Thread *GetCurrentThreadTLS(); extern void SetCurrentThreadTLS(Thread *thread); #else -extern thread_local Thread *gCurrentThread; +extern __thread Thread *gCurrentThread; #endif angle::GlobalMutex &GetGlobalMutex(); diff --git a/Source/ThirdParty/xdgmime/CMakeLists.txt b/Source/ThirdParty/xdgmime/CMakeLists.txt index 3478d2d..8a439b3 100644 --- a/Source/ThirdParty/xdgmime/CMakeLists.txt +++ b/Source/ThirdParty/xdgmime/CMakeLists.txt @@ -16,8 +16,10 @@ set(XDGMIME_SOURCES ${XDGMIME_DIR}/src/xdgmimeglob.c ) +set(XDGMIME_BYTE_ORDER $) + include_directories("${XDGMIME_INCLUDE_DIRECTORIES}") -add_definitions(-DXDG_PREFIX=_wk_xdg) +add_definitions(-DXDG_PREFIX=_wk_xdg -DLITTLE_ENDIAN=${XDGMIME_BYTE_ORDER}) add_library(xdgmime STATIC ${XDGMIME_SOURCES}) if (COMPILER_IS_GCC_OR_CLANG) diff --git a/Source/WTF/wtf/CheckedArithmetic.h b/Source/WTF/wtf/CheckedArithmetic.h index c9d31d5..25b90a3 100644 --- a/Source/WTF/wtf/CheckedArithmetic.h +++ b/Source/WTF/wtf/CheckedArithmetic.h @@ -34,7 +34,7 @@ /* On Linux with clang, libgcc is usually used instead of compiler-rt, and it does * not provide the __mulodi4 symbol used by clang for __builtin_mul_overflow */ -#if COMPILER(GCC) || (COMPILER(CLANG) && !(CPU(ARM) && OS(LINUX))) && !PLATFORM(IOS_FAMILY_SIMULATOR) +#if COMPILER(GCC) || (COMPILER(CLANG) && !(CPU(ARM) && OS(LINUX)) && !OS(HAIKU)) && !PLATFORM(IOS_FAMILY_SIMULATOR) #define USE_MUL_OVERFLOW 1 #endif diff --git a/Source/WTF/wtf/CurrentTime.cpp b/Source/WTF/wtf/CurrentTime.cpp index c042a0f..2d253f5 100644 --- a/Source/WTF/wtf/CurrentTime.cpp +++ b/Source/WTF/wtf/CurrentTime.cpp @@ -271,7 +271,7 @@ MonotonicTime MonotonicTime::now() return fromMachAbsoluteTime(mach_absolute_time()); #elif OS(FUCHSIA) return fromRawSeconds(zx_clock_get_monotonic() / static_cast(ZX_SEC(1))); -#elif OS(LINUX) || OS(FREEBSD) || OS(OPENBSD) || OS(NETBSD) +#elif OS(LINUX) || OS(FREEBSD) || OS(OPENBSD) || OS(NETBSD) || OS(HAIKU) struct timespec ts { }; clock_gettime(CLOCK_MONOTONIC, &ts); return fromRawSeconds(static_cast(ts.tv_sec) + ts.tv_nsec / 1.0e9); diff --git a/Source/WTF/wtf/FastMalloc.cpp b/Source/WTF/wtf/FastMalloc.cpp index 48b0c31..6ed66c8 100644 --- a/Source/WTF/wtf/FastMalloc.cpp +++ b/Source/WTF/wtf/FastMalloc.cpp @@ -58,8 +58,8 @@ namespace WTF { #if ASSERT_ENABLED -thread_local static unsigned forbidMallocUseScopeCount; -thread_local static unsigned disableMallocRestrictionScopeCount; +__thread unsigned forbidMallocUseScopeCount; +__thread unsigned disableMallocRestrictionScopeCount; ForbidMallocUseForCurrentThreadScope::ForbidMallocUseForCurrentThreadScope() { diff --git a/Source/WTF/wtf/FileSystem.cpp b/Source/WTF/wtf/FileSystem.cpp index bcce638..f89c0ab 100644 --- a/Source/WTF/wtf/FileSystem.cpp +++ b/Source/WTF/wtf/FileSystem.cpp @@ -41,6 +41,10 @@ #include #endif +#if OS(HAIKU) +#define MAP_FILE 0 +#endif + #if USE(GLIB) #include #include @@ -724,9 +728,13 @@ bool createSymbolicLink(const String& targetPath, const String& symbolicLinkPath bool hardLink(const String& targetPath, const String& linkPath) { +#if OS(HAIKU) + return hardLinkOrCopyFile(targetPath, linkPath); +#else std::error_code ec; std::filesystem::create_hard_link(toStdFileSystemPath(targetPath), toStdFileSystemPath(linkPath), ec); return !ec; +#endif } bool hardLinkOrCopyFile(const String& targetPath, const String& linkPath) diff --git a/Source/WTF/wtf/InlineASM.h b/Source/WTF/wtf/InlineASM.h index 8379a69..04f2529 100644 --- a/Source/WTF/wtf/InlineASM.h +++ b/Source/WTF/wtf/InlineASM.h @@ -43,7 +43,7 @@ #define THUMB_FUNC_PARAM(name) #endif -#if (OS(LINUX) || OS(FREEBSD)) && CPU(X86_64) +#if (OS(LINUX) || OS(FREEBSD) || OS(HAIKU)) && CPU(X86_64) #define GLOBAL_REFERENCE(name) #name "@plt" #elif CPU(X86) && COMPILER(MINGW) #define GLOBAL_REFERENCE(name) "@" #name "@4" @@ -69,6 +69,7 @@ || OS(FREEBSD) \ || OS(FUCHSIA) \ || OS(OPENBSD) \ + || OS(HAIKU) \ || OS(HPUX) \ || OS(NETBSD) // ELF platform @@ -87,6 +88,7 @@ || OS(FUCHSIA) \ || OS(OPENBSD) \ || OS(HURD) \ + || OS(HAIKU) \ || OS(NETBSD) \ || COMPILER(MINGW) // GNU as-compatible syntax. diff --git a/Source/WTF/wtf/NumberOfCores.cpp b/Source/WTF/wtf/NumberOfCores.cpp index 7636865..dd2128e 100644 --- a/Source/WTF/wtf/NumberOfCores.cpp +++ b/Source/WTF/wtf/NumberOfCores.cpp @@ -30,6 +30,8 @@ #if OS(DARWIN) #include +#elif OS(HAIKU) +#include #elif OS(LINUX) || OS(AIX) || OS(OPENBSD) || OS(NETBSD) || OS(FREEBSD) #include #elif OS(WINDOWS) @@ -65,6 +67,10 @@ int numberOfProcessorCores() int sysctlResult = sysctl(name, sizeof(name) / sizeof(int), &result, &length, 0, 0); s_numberOfCores = sysctlResult < 0 ? defaultIfUnavailable : result; +#elif OS(HAIKU) + system_info info; + status_t result = get_system_info(&info); + s_numberOfCores = result == B_OK ? info.cpu_count : defaultIfUnavailable; #elif OS(LINUX) || OS(AIX) || OS(OPENBSD) || OS(NETBSD) || OS(FREEBSD) long sysconfResult = sysconf(_SC_NPROCESSORS_ONLN); diff --git a/Source/WTF/wtf/Packed.h b/Source/WTF/wtf/Packed.h index 274b963..6a28e74 100644 --- a/Source/WTF/wtf/Packed.h +++ b/Source/WTF/wtf/Packed.h @@ -151,7 +151,7 @@ public: if (isAlignmentShiftProfitable) value <<= alignmentShiftSize; -#if CPU(X86_64) && !(OS(DARWIN) || OS(LINUX) || OS(WINDOWS)) +#if CPU(X86_64) && !(OS(DARWIN) || OS(LINUX) || OS(HAIKU) || OS(WINDOWS)) // The AMD specification requires that the most significant 16 // bits of any virtual address, bits 48 through 63, must be // copies of bit 47 (in a manner akin to sign extension). diff --git a/Source/WTF/wtf/PlatformEnable.h b/Source/WTF/wtf/PlatformEnable.h index e30a3d8..f2af1cf 100644 --- a/Source/WTF/wtf/PlatformEnable.h +++ b/Source/WTF/wtf/PlatformEnable.h @@ -664,7 +664,7 @@ #if !defined(ENABLE_DFG_JIT) && ENABLE(JIT) /* Enable the DFG JIT on X86 and X86_64. */ -#if CPU(X86_64) && (OS(DARWIN) || OS(LINUX) || OS(FREEBSD) || OS(HURD) || OS(WINDOWS)) +#if CPU(X86_64) && (OS(DARWIN) || OS(LINUX) || OS(HAIKU) || OS(FREEBSD) || OS(HURD) || OS(WINDOWS)) #define ENABLE_DFG_JIT 1 #endif diff --git a/Source/WTF/wtf/PlatformHave.h b/Source/WTF/wtf/PlatformHave.h index 949977f..8f56f56 100644 --- a/Source/WTF/wtf/PlatformHave.h +++ b/Source/WTF/wtf/PlatformHave.h @@ -389,7 +389,7 @@ #define HAVE_STACK_BOUNDS_FOR_NEW_THREAD 1 #endif -#if !OS(WINDOWS) && !PLATFORM(PLAYSTATION) +#if !OS(WINDOWS) && !PLATFORM(PLAYSTATION) && !OS(HAIKU) #define HAVE_MEMMEM 1 #endif diff --git a/Source/WTF/wtf/PlatformOS.h b/Source/WTF/wtf/PlatformOS.h index f0d3cb5..85a57c2 100644 --- a/Source/WTF/wtf/PlatformOS.h +++ b/Source/WTF/wtf/PlatformOS.h @@ -57,6 +57,11 @@ #define WTF_OS_DARWIN 1 #endif +/* OS(HAIKU) - Haiku */ +#if defined(__HAIKU__) +#define WTF_OS_HAIKU 1 +#endif + /* OS(IOS_FAMILY) - iOS family, including iOS, iPadOS, macCatalyst, tvOS, watchOS */ #if OS(DARWIN) && TARGET_OS_IPHONE #define WTF_OS_IOS_FAMILY 1 @@ -125,6 +130,7 @@ || OS(FUCHSIA) \ || OS(HURD) \ || OS(LINUX) \ + || OS(HAIKU) \ || OS(NETBSD) \ || OS(OPENBSD) \ || defined(unix) \ diff --git a/Source/WTF/wtf/PlatformRegisters.h b/Source/WTF/wtf/PlatformRegisters.h index b981c13..76cfd55 100644 --- a/Source/WTF/wtf/PlatformRegisters.h +++ b/Source/WTF/wtf/PlatformRegisters.h @@ -34,6 +34,8 @@ #include #elif OS(WINDOWS) #include +#elif OS(HAIKU) +#include #elif OS(OPENBSD) typedef ucontext_t mcontext_t; #else diff --git a/Source/WTF/wtf/RAMSize.cpp b/Source/WTF/wtf/RAMSize.cpp index 164de5e..c1d5524 100644 --- a/Source/WTF/wtf/RAMSize.cpp +++ b/Source/WTF/wtf/RAMSize.cpp @@ -33,6 +33,8 @@ #elif USE(SYSTEM_MALLOC) #if OS(LINUX) || OS(FREEBSD) #include +#elif OS(HAIKU) +#include #elif OS(UNIX) #include #endif // OS(LINUX) || OS(FREEBSD) || OS(UNIX) @@ -60,6 +62,10 @@ static size_t computeRAMSize() struct sysinfo si; sysinfo(&si); return si.totalram * si.mem_unit; +#elif OS(HAIKU) + system_info info; + get_system_info(&info); + return info.max_pages * B_PAGE_SIZE; #elif OS(UNIX) long pages = sysconf(_SC_PHYS_PAGES); long pageSize = sysconf(_SC_PAGE_SIZE); diff --git a/Source/WTF/wtf/StackBounds.cpp b/Source/WTF/wtf/StackBounds.cpp index e9d9d58..bc4d1c7 100644 --- a/Source/WTF/wtf/StackBounds.cpp +++ b/Source/WTF/wtf/StackBounds.cpp @@ -42,6 +42,12 @@ #include #endif +#if OS(HAIKU) +extern "C" { + int pthread_attr_get_np(pthread_t thread, pthread_attr_t *_attr); +} +#endif + #endif namespace WTF { @@ -95,7 +101,7 @@ StackBounds StackBounds::newThreadStackBounds(PlatformThreadHandle thread) pthread_attr_t sattr; pthread_attr_init(&sattr); -#if HAVE(PTHREAD_NP_H) || OS(NETBSD) +#if HAVE(PTHREAD_NP_H) || OS(NETBSD) || OS(HAIKU) // e.g. on FreeBSD 5.4, neundorf@kde.org pthread_attr_get_np(thread, &sattr); #else diff --git a/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp b/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp index 396de82..97159c3 100644 --- a/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp +++ b/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp @@ -115,7 +115,7 @@ void* OSAllocator::tryReserveAndCommit(size_t bytes, Usage usage, bool writable, void* OSAllocator::tryReserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages) { -#if OS(LINUX) +#if OS(LINUX) || OS(HAIKU) UNUSED_PARAM(usage); UNUSED_PARAM(jitCageEnabled); UNUSED_PARAM(includesGuardPages); @@ -232,7 +232,7 @@ void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bo void OSAllocator::commit(void* address, size_t bytes, bool writable, bool executable) { -#if OS(LINUX) +#if OS(LINUX) || OS(HAIKU) UNUSED_PARAM(writable); UNUSED_PARAM(executable); while (madvise(address, bytes, MADV_WILLNEED) == -1 && errno == EAGAIN) { } @@ -251,7 +251,7 @@ void OSAllocator::commit(void* address, size_t bytes, bool writable, bool execut void OSAllocator::decommit(void* address, size_t bytes) { -#if OS(LINUX) +#if OS(LINUX) || OS(HAIKU) while (madvise(address, bytes, MADV_DONTNEED) == -1 && errno == EAGAIN) { } #elif HAVE(MADV_FREE_REUSE) while (madvise(address, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { } diff --git a/Source/WTF/wtf/posix/ThreadingPOSIX.cpp b/Source/WTF/wtf/posix/ThreadingPOSIX.cpp index e5cac15..5dabd58 100644 --- a/Source/WTF/wtf/posix/ThreadingPOSIX.cpp +++ b/Source/WTF/wtf/posix/ThreadingPOSIX.cpp @@ -42,6 +42,10 @@ #include #include +#if OS(HAIKU) +#include +#endif + #if OS(LINUX) #include #include @@ -318,6 +322,8 @@ void Thread::initializeCurrentThreadInternal(const char* threadName) { #if HAVE(PTHREAD_SETNAME_NP) pthread_setname_np(normalizeThreadName(threadName)); +#elif OS(HAIKU) + rename_thread(find_thread(NULL), normalizeThreadName(threadName)); #elif OS(LINUX) prctl(PR_SET_NAME, normalizeThreadName(threadName)); #else diff --git a/Source/WebCore/Modules/mediastream/gstreamer/GStreamerWebRTCUtils.cpp b/Source/WebCore/Modules/mediastream/gstreamer/GStreamerWebRTCUtils.cpp index fb4b3eb..9371e52 100644 --- a/Source/WebCore/Modules/mediastream/gstreamer/GStreamerWebRTCUtils.cpp +++ b/Source/WebCore/Modules/mediastream/gstreamer/GStreamerWebRTCUtils.cpp @@ -22,13 +22,14 @@ #if ENABLE(WEB_RTC) && USE(GSTREAMER_WEBRTC) #include "GStreamerWebRTCUtils.h" -#include "OpenSSLCryptoUniquePtr.h" #include "RTCIceCandidate.h" #include "RTCIceProtocol.h" + #include #include #include #include +#include #include #include #include @@ -292,16 +293,20 @@ std::optional parseIceCandidateSDP(const String& sdp) static String x509Serialize(X509* x509) { - auto bio = BIOPtr(BIO_new(BIO_s_mem())); + BIO* bio = BIO_new(BIO_s_mem()); if (!bio) return { }; - if (!PEM_write_bio_X509(bio.get(), x509)) + auto scopeExit = WTF::makeScopeExit([&] { + BIO_free(bio); + }); + + if (!PEM_write_bio_X509(bio, x509)) return { }; Vector buffer; buffer.reserveCapacity(4096); - int length = BIO_read(bio.get(), buffer.data(), 4096); + int length = BIO_read(bio, buffer.data(), 4096); if (!length) return { }; @@ -310,16 +315,20 @@ static String x509Serialize(X509* x509) static String privateKeySerialize(EVP_PKEY* privateKey) { - auto bio = BIOPtr(BIO_new(BIO_s_mem())); + BIO* bio = BIO_new(BIO_s_mem()); if (!bio) return { }; - if (!PEM_write_bio_PrivateKey(bio.get(), privateKey, nullptr, nullptr, 0, nullptr, nullptr)) + auto scopeExit = WTF::makeScopeExit([&] { + BIO_free(bio); + }); + + if (!PEM_write_bio_PrivateKey(bio, privateKey, nullptr, nullptr, 0, nullptr, nullptr)) return { }; Vector buffer; buffer.reserveCapacity(4096); - int length = BIO_read(bio.get(), buffer.data(), 4096); + int length = BIO_read(bio, buffer.data(), 4096); if (!length) return { }; @@ -329,74 +338,66 @@ static String privateKeySerialize(EVP_PKEY* privateKey) std::optional> generateCertificate(Ref&& origin, const PeerConnectionBackend::CertificateInformation& info) { ensureDebugCategoryInitialized(); - EvpPKeyPtr privateKey; + EVP_PKEY* privateKey = EVP_PKEY_new(); + if (!privateKey) { + GST_WARNING("Failed to create private key"); + return { }; + } + + auto scopeExit = WTF::makeScopeExit([&] { + EVP_PKEY_free(privateKey); + }); switch (info.type) { case PeerConnectionBackend::CertificateInformation::Type::ECDSAP256: { - privateKey.reset(EVP_EC_gen("prime256v1")); - if (!privateKey) + EC_KEY* ecKey = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); + // Ensure curve name is included when EC key is serialized. + // Without this call, OpenSSL versions before 1.1.0 will create + // certificates that don't work for TLS. + // This is a no-op for BoringSSL and OpenSSL 1.1.0+ + EC_KEY_set_asn1_flag(ecKey, OPENSSL_EC_NAMED_CURVE); + if (!privateKey || !ecKey || !EC_KEY_generate_key(ecKey) || !EVP_PKEY_assign_EC_KEY(privateKey, ecKey)) { + EC_KEY_free(ecKey); return { }; + } break; } case PeerConnectionBackend::CertificateInformation::Type::RSASSAPKCS1v15: { - int publicExponent = info.rsaParameters ? info.rsaParameters->publicExponent : 65537; - auto modulusLength = info.rsaParameters ? info.rsaParameters->modulusLength : 2048; - - auto ctx = EvpPKeyCtxPtr(EVP_PKEY_CTX_new_from_name(nullptr, "RSA", nullptr)); - if (!ctx) - return { }; - - EVP_PKEY_keygen_init(ctx.get()); - - auto paramsBuilder = OsslParamBldPtr(OSSL_PARAM_BLD_new()); - if (!paramsBuilder) - return { }; - - auto exponent = BIGNUMPtr(BN_new()); - if (!BN_set_word(exponent.get(), publicExponent)) - return { }; - - auto modulus = BIGNUMPtr(BN_new()); - if (!BN_set_word(modulus.get(), modulusLength)) - return { }; - - if (!OSSL_PARAM_BLD_push_BN(paramsBuilder.get(), "n", modulus.get())) - return { }; - - if (!OSSL_PARAM_BLD_push_BN(paramsBuilder.get(), "e", exponent.get())) - return { }; - - if (!OSSL_PARAM_BLD_push_BN(paramsBuilder.get(), "d", nullptr)) + RSA* rsa = RSA_new(); + if (!rsa) return { }; - auto params = OsslParamPtr(OSSL_PARAM_BLD_to_param(paramsBuilder.get())); - if (!params) - return { }; - - EVP_PKEY_CTX_set_params(ctx.get(), params.get()); - - EVP_PKEY* pkey = nullptr; - EVP_PKEY_generate(ctx.get(), &pkey); - if (!pkey) + BIGNUM* exponent = BN_new(); + int publicExponent = info.rsaParameters ? info.rsaParameters->publicExponent : 65537; + auto modulusLength = info.rsaParameters ? info.rsaParameters->modulusLength : 2048; + if (!BN_set_word(exponent, publicExponent) || !RSA_generate_key_ex(rsa, modulusLength, exponent, nullptr) + || !EVP_PKEY_assign_RSA(privateKey, rsa)) { + RSA_free(rsa); return { }; - privateKey.reset(pkey); + } + BN_free(exponent); break; } } - auto x509 = X509Ptr(X509_new()); + X509* x509 = X509_new(); if (!x509) { GST_WARNING("Failed to create certificate"); return { }; } - X509_set_version(x509.get(), 2); + auto certScopeExit = WTF::makeScopeExit([&] { + X509_free(x509); + }); + + X509_set_version(x509, 2); // Set a random 64 bit integer as serial number. - auto serialNumber = BIGNUMPtr(BN_new()); - BN_rand(serialNumber.get(), 64, 0, 0); - ASN1_INTEGER* asn1SerialNumber = X509_get_serialNumber(x509.get()); - BN_to_ASN1_INTEGER(serialNumber.get(), asn1SerialNumber); + BIGNUM* serialNumber = BN_new(); + BN_pseudo_rand(serialNumber, 64, 0, 0); + ASN1_INTEGER* asn1SerialNumber = X509_get_serialNumber(x509); + BN_to_ASN1_INTEGER(serialNumber, asn1SerialNumber); + BN_free(serialNumber); // Set a random 8 byte base64 string as issuer/subject. X509_NAME* name = X509_NAME_new(); @@ -404,25 +405,25 @@ std::optional> generateCertificate(Ref&& ori WTF::cryptographicallyRandomValues(buffer.data(), buffer.size()); auto commonName = base64EncodeToString(buffer); X509_NAME_add_entry_by_NID(name, NID_commonName, MBSTRING_ASC, (const guchar*)commonName.ascii().data(), -1, -1, 0); - X509_set_subject_name(x509.get(), name); - X509_set_issuer_name(x509.get(), name); + X509_set_subject_name(x509, name); + X509_set_issuer_name(x509, name); X509_NAME_free(name); // Fallback to 30 days, max out at one year. uint64_t expires = info.expires.value_or(2592000); expires = std::min(expires, 31536000000); - X509_gmtime_adj(X509_getm_notBefore(x509.get()), 0); - X509_gmtime_adj(X509_getm_notAfter(x509.get()), expires); - X509_set_pubkey(x509.get(), privateKey.get()); + X509_gmtime_adj(X509_getm_notBefore(x509), 0); + X509_gmtime_adj(X509_getm_notAfter(x509), expires); + X509_set_pubkey(x509, privateKey); - if (!X509_sign(x509.get(), privateKey.get(), EVP_sha256())) { + if (!X509_sign(x509, privateKey, EVP_sha256())) { GST_WARNING("Failed to sign certificate"); return { }; } - auto pem = x509Serialize(x509.get()); + auto pem = x509Serialize(x509); GST_DEBUG("Generated certificate PEM: %s", pem.ascii().data()); - auto serializedPrivateKey = privateKeySerialize(privateKey.get()); + auto serializedPrivateKey = privateKeySerialize(privateKey); Vector fingerprints; // FIXME: Fill fingerprints. auto expirationTime = WTF::WallTime::now().secondsSinceEpoch() + WTF::Seconds(expires); diff --git a/Source/WebCore/inspector/InspectorFrontendHost.cpp b/Source/WebCore/inspector/InspectorFrontendHost.cpp index 5c4e75c..18e7db0 100644 --- a/Source/WebCore/inspector/InspectorFrontendHost.cpp +++ b/Source/WebCore/inspector/InspectorFrontendHost.cpp @@ -395,6 +395,8 @@ String InspectorFrontendHost::platform() const return "mac"_s; #elif OS(WINDOWS) return "windows"_s; +#elif OS(HAIKU) + return "haiku"_s; #elif OS(LINUX) return "linux"_s; #elif OS(FREEBSD) diff --git a/Source/WebCore/page/NavigatorBase.cpp b/Source/WebCore/page/NavigatorBase.cpp index bcf4cf6..ab71458 100644 --- a/Source/WebCore/page/NavigatorBase.cpp +++ b/Source/WebCore/page/NavigatorBase.cpp @@ -100,6 +100,8 @@ String NavigatorBase::platform() const return deviceName(); #elif OS(MACOS) return "MacIntel"_s; +#elif OS(HAIKU) + return "Haiku"_s; #elif OS(WINDOWS) return "Win32"_s; #else diff --git a/Source/WebCore/platform/graphics/gbm/GraphicsContextGLANGLELinux.cpp b/Source/WebCore/platform/graphics/gbm/GraphicsContextGLANGLELinux.cpp index f8627d2..1244edb 100644 --- a/Source/WebCore/platform/graphics/gbm/GraphicsContextGLANGLELinux.cpp +++ b/Source/WebCore/platform/graphics/gbm/GraphicsContextGLANGLELinux.cpp @@ -108,7 +108,7 @@ RefPtr GraphicsContextGLANGLE::readCompositedResults() bool GraphicsContextGLANGLE::makeContextCurrent() { - static thread_local TLS_MODEL_INITIAL_EXEC GraphicsContextGLANGLE* s_currentContext { nullptr }; + static __thread GraphicsContextGLANGLE* s_currentContext { nullptr }; if (s_currentContext == this) return true; diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp index 364c699..bb23fc8 100644 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp @@ -2243,6 +2243,8 @@ void MediaPlayerPrivateGStreamer::configureDownloadBuffer(GstElement* element) GUniquePtr defaultValue(g_build_filename(G_DIR_SEPARATOR_S, "var", "tmp", nullptr)); mediaDiskCachePath.swap(defaultValue); } +#elif defined(__HAIKU__) + GUniquePtr mediaDiskCachePath(g_build_filename(G_DIR_SEPARATOR_S, "system", "cache", "tmp", nullptr)); #else GUniquePtr mediaDiskCachePath(g_build_filename(G_DIR_SEPARATOR_S, "var", "tmp", nullptr)); #endif diff --git a/Source/WebKit/CMakeLists.txt b/Source/WebKit/CMakeLists.txt index 8c0b085..c634c4c 100644 --- a/Source/WebKit/CMakeLists.txt +++ b/Source/WebKit/CMakeLists.txt @@ -411,6 +411,10 @@ if (UNIX) endif () endif () +if (HAIKU) + list(APPEND WebKit_PRIVATE_LIBRARIES network) +endif () + macro(ADD_WEBKIT_PREFIX_HEADER _target) if (WebKit_USE_PREFIX_HEADER) get_target_property(OLD_COMPILE_FLAGS ${_target} COMPILE_FLAGS) diff --git a/Source/WebKit/Platform/IPC/Connection.cpp b/Source/WebKit/Platform/IPC/Connection.cpp index 5860827..7c79f77 100644 --- a/Source/WebKit/Platform/IPC/Connection.cpp +++ b/Source/WebKit/Platform/IPC/Connection.cpp @@ -1121,8 +1121,11 @@ void Connection::didFailToSendSyncMessage() { if (!m_shouldExitOnSyncMessageSendFailure) return; - +#if OS(HAIKU) + kill(::getpid(), SIGKILL); +#else exit(0); +#endif } void Connection::enqueueIncomingMessage(std::unique_ptr incomingMessage) diff --git a/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp b/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp index e01364f..355a516 100644 --- a/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp +++ b/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp @@ -230,7 +230,7 @@ bool Connection::processMessage() return true; } -static ssize_t readBytesFromSocket(int socketDescriptor, Vector& buffer, Vector& fileDescriptors) +static ssize_t readBytesFromSocket(int socketDescriptor, Vector& buffer, Vector& fileDescriptors, size_t size) { struct msghdr message; memset(&message, 0, sizeof(message)); @@ -246,7 +246,7 @@ static ssize_t readBytesFromSocket(int socketDescriptor, Vector& buffer size_t previousBufferSize = buffer.size(); buffer.grow(buffer.capacity()); iov[0].iov_base = buffer.data() + previousBufferSize; - iov[0].iov_len = buffer.size() - previousBufferSize; + iov[0].iov_len = size; message.msg_iov = iov; message.msg_iovlen = 1; @@ -297,6 +297,20 @@ static ssize_t readBytesFromSocket(int socketDescriptor, Vector& buffer return -1; } +static ssize_t readBytesFromSocket(int socketDescriptor, Vector& buffer, Vector& fileDescriptors) +{ + ssize_t bytesRead = readBytesFromSocket(socketDescriptor, buffer, fileDescriptors, sizeof(MessageInfo)); + if (bytesRead <= 0) return bytesRead; + uint8_t* messageData = buffer.data(); + MessageInfo messageInfo; + memcpy(static_cast(&messageInfo), messageData, sizeof(messageInfo)); + messageData += sizeof(messageInfo); + size_t messageLength = messageInfo.attachmentCount() * sizeof(AttachmentInfo) + (messageInfo.isBodyOutOfLine() ? 0 : messageInfo.bodySize()); + if (messageLength == 0) return bytesRead; + bytesRead = readBytesFromSocket(socketDescriptor, buffer, fileDescriptors, messageLength); + return bytesRead; +} + void Connection::readyReadHandler() { while (true) { @@ -545,7 +559,11 @@ bool Connection::sendOutputMessage(UnixMessage& outputMessage) SocketPair createPlatformConnection(unsigned options) { int sockets[2]; +#ifdef __HAIKU__ + RELEASE_ASSERT(socketpair(AF_LOCAL, SOCK_STREAM, 0, sockets) != -1); +#else RELEASE_ASSERT(socketpair(AF_UNIX, SOCKET_TYPE, 0, sockets) != -1); +#endif if (options & SetCloexecOnServer) { // Don't expose the child socket to the parent process. diff --git a/Source/WebKit/Shared/AuxiliaryProcess.cpp b/Source/WebKit/Shared/AuxiliaryProcess.cpp index f5a986d..bc0b9fc 100644 --- a/Source/WebKit/Shared/AuxiliaryProcess.cpp +++ b/Source/WebKit/Shared/AuxiliaryProcess.cpp @@ -45,6 +45,10 @@ #include #endif +#if USE(GSTREAMER) +#include +#endif + namespace WebKit { using namespace WebCore; @@ -187,13 +191,24 @@ void AuxiliaryProcess::stopRunLoop() platformStopRunLoop(); } -#if !PLATFORM(COCOA) +#if !PLATFORM(COCOA) && !OS(HAIKU) void AuxiliaryProcess::platformStopRunLoop() { RunLoop::main().stop(); } #endif +#if OS(HAIKU) +void AuxiliaryProcess::platformStopRunLoop() +{ + RunLoop::main().stop(); +#if USE(GSTREAMER) + gst_deinit(); +#endif + _exit(EXIT_SUCCESS); +} +#endif + void AuxiliaryProcess::terminate() { m_connection->invalidate(); diff --git a/Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp b/Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp index d96a09e..581e04e 100644 --- a/Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp +++ b/Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp @@ -122,6 +122,8 @@ static const char* hardwareAccelerationPolicy(WebKitURISchemeRequest* request) { #if PLATFORM(WPE) return "always"; +#elif defined(__HAIKU__) + return "never"; #elif PLATFORM(GTK) auto* webView = webkit_uri_scheme_request_get_web_view(request); ASSERT(webView); @@ -155,6 +157,8 @@ static const char* openGLAPI(bool isEGL) if (epoxy_is_desktop_gl()) return "OpenGL (libepoxy)"; return "OpenGL ES 2 (libepoxy)"; +#elif defined(__HAIKU__) + return "OpenGL"; #else #if USE(EGL) if (isEGL) { diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebWorkerClient.cpp b/Source/WebKit/WebProcess/WebCoreSupport/WebWorkerClient.cpp index 58eb170..ccd190b 100644 --- a/Source/WebKit/WebProcess/WebCoreSupport/WebWorkerClient.cpp +++ b/Source/WebKit/WebProcess/WebCoreSupport/WebWorkerClient.cpp @@ -40,6 +40,8 @@ #include #endif +#include + namespace WebKit { using namespace WebCore; diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp index c50d982..0e5c6f1 100644 --- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp +++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp @@ -504,7 +504,7 @@ void DrawingAreaCoordinatedGraphics::displayDidRefresh() displayTimerFired(); } -#if PLATFORM(GTK) +#if PLATFORM(GTK) && !OS(HAIKU) void DrawingAreaCoordinatedGraphics::adjustTransientZoom(double scale, FloatPoint origin) { if (!m_transientZoom) { @@ -637,7 +637,7 @@ void DrawingAreaCoordinatedGraphics::resumePainting() void DrawingAreaCoordinatedGraphics::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLayer) { -#if PLATFORM(GTK) +#if PLATFORM(GTK) && !OS(HAIKU) if (!m_alwaysUseCompositing) { m_webPage.corePage()->settings().setForceCompositingMode(true); m_alwaysUseCompositing = true; diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h index a5b7915..69c67a7 100644 --- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h +++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h @@ -87,7 +87,7 @@ private: void targetRefreshRateDidChange(unsigned rate) override; void displayDidRefresh() override; -#if PLATFORM(GTK) +#if PLATFORM(GTK) && !OS(HAIKU) void adjustTransientZoom(double scale, WebCore::FloatPoint origin) override; void commitTransientZoom(double scale, WebCore::FloatPoint origin) override; #endif @@ -159,7 +159,7 @@ private: RunLoop::Timer m_displayTimer; -#if PLATFORM(GTK) +#if PLATFORM(GTK) && !OS(HAIKU) bool m_transientZoom { false }; WebCore::FloatPoint m_transientZoomInitialOrigin; #endif diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp index bca4cd1..a4c44fa 100644 --- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp +++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp @@ -149,7 +149,7 @@ void LayerTreeHost::layerFlushTimerFired() m_coordinator.forceFrameSync(); OptionSet flags; -#if PLATFORM(GTK) +#if PLATFORM(GTK) && !OS(HAIKU) if (!m_transientZoom) flags.add(FinalizeRenderingUpdateFlags::ApplyScrollingTreeLayerPositions); #else @@ -158,7 +158,7 @@ void LayerTreeHost::layerFlushTimerFired() bool didSync = m_coordinator.flushPendingLayerChanges(flags); -#if PLATFORM(GTK) +#if PLATFORM(GTK) && !OS(HAIKU) // If we have an active transient zoom, we want the zoom to win over any changes // that WebCore makes to the relevant layers, so re-apply our changes after flushing. if (m_transientZoom) @@ -206,7 +206,7 @@ void LayerTreeHost::forceRepaint() if (!m_isWaitingForRenderer) { OptionSet flags; -#if PLATFORM(GTK) +#if PLATFORM(GTK) && !OS(HAIKU) if (!m_transientZoom) flags.add(FinalizeRenderingUpdateFlags::ApplyScrollingTreeLayerPositions); #else @@ -478,7 +478,7 @@ void LayerTreeHost::renderNextFrame(bool forceRepaint) } } -#if PLATFORM(GTK) +#if PLATFORM(GTK) && !OS(HAIKU) FloatPoint LayerTreeHost::constrainTransientZoomOrigin(double scale, FloatPoint origin) const { FrameView& frameView = *m_webPage.mainFrameView(); diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h index 45e4bbd..d3b5d2d 100644 --- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h +++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h @@ -99,7 +99,7 @@ public: WebCore::PlatformDisplayID displayID() const { return m_displayID; } -#if PLATFORM(GTK) +#if PLATFORM(GTK) && !OS(HAIKU) void adjustTransientZoom(double, WebCore::FloatPoint); void commitTransientZoom(double, WebCore::FloatPoint); #endif @@ -130,7 +130,7 @@ private: void requestDisplayRefreshMonitorUpdate() override; void handleDisplayRefreshMonitorUpdate(bool hasBeenRescheduled) override; -#if PLATFORM(GTK) +#if PLATFORM(GTK) && !OS(HAIKU) WebCore::FloatPoint constrainTransientZoomOrigin(double, WebCore::FloatPoint) const; WebCore::CoordinatedGraphicsLayer* layerForTransientZoom() const; void applyTransientZoomToLayers(double, WebCore::FloatPoint); @@ -168,7 +168,7 @@ private: #endif // USE(COORDINATED_GRAPHICS) WebCore::PlatformDisplayID m_displayID; -#if PLATFORM(GTK) +#if PLATFORM(GTK) && !OS(HAIKU) bool m_transientZoom { false }; double m_transientZoomScale { 1 }; WebCore::FloatPoint m_transientZoomOrigin; @@ -197,7 +197,7 @@ inline void LayerTreeHost::didChangeViewportAttributes(WebCore::ViewportAttribut inline void LayerTreeHost::setIsDiscardable(bool) { } inline void LayerTreeHost::deviceOrPageScaleFactorChanged() { } inline RefPtr LayerTreeHost::createDisplayRefreshMonitor(WebCore::PlatformDisplayID) { return nullptr; } -#if PLATFORM(GTK) +#if PLATFORM(GTK) && !OS(HAIKU) inline void LayerTreeHost::adjustTransientZoom(double, WebCore::FloatPoint) { } inline void LayerTreeHost::commitTransientZoom(double, WebCore::FloatPoint) { } #endif diff --git a/Source/WebKit/WebProcess/WebProcess.cpp b/Source/WebKit/WebProcess/WebProcess.cpp index 54e333b..b1784ed 100644 --- a/Source/WebKit/WebProcess/WebProcess.cpp +++ b/Source/WebKit/WebProcess/WebProcess.cpp @@ -395,7 +395,7 @@ void WebProcess::initializeConnection(IPC::Connection* connection) #endif connection->setDidCloseOnConnectionWorkQueueCallback(callExitCallback); -#if !PLATFORM(GTK) && !PLATFORM(WPE) && !ENABLE(IPC_TESTING_API) +#if (!PLATFORM(GTK) && !PLATFORM(WPE) && !ENABLE(IPC_TESTING_API)) || OS(HAIKU) connection->setShouldExitOnSyncMessageSendFailure(true); #endif diff --git a/Source/bmalloc/bmalloc/AvailableMemory.cpp b/Source/bmalloc/bmalloc/AvailableMemory.cpp index c89de56..c342e71 100644 --- a/Source/bmalloc/bmalloc/AvailableMemory.cpp +++ b/Source/bmalloc/bmalloc/AvailableMemory.cpp @@ -47,6 +47,9 @@ #if BOS(FREEBSD) || BOS(LINUX) #include #endif +#if BOS(HAIKU) +#include +#endif #if BOS(LINUX) #include #include @@ -166,6 +169,11 @@ static size_t computeAvailableMemory() if (!sysinfo(&info)) return info.totalram * info.mem_unit; return availableMemoryGuess; +#elif BOS(HAIKU) + system_info info; + if (get_system_info(&info) != B_OK) + return availableMemoryGuess; + return info.max_pages * B_PAGE_SIZE; #elif BOS(UNIX) long pages = sysconf(_SC_PHYS_PAGES); long pageSize = sysconf(_SC_PAGE_SIZE); diff --git a/Source/bmalloc/bmalloc/BPlatform.h b/Source/bmalloc/bmalloc/BPlatform.h index 00633b6..a243177 100644 --- a/Source/bmalloc/bmalloc/BPlatform.h +++ b/Source/bmalloc/bmalloc/BPlatform.h @@ -48,6 +48,10 @@ #define BOS_LINUX 1 #endif +#ifdef __HAIKU__ +#define BOS_HAIKU 1 +#endif + #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) #define BOS_FREEBSD 1 #endif diff --git a/Source/bmalloc/bmalloc/Scavenger.cpp b/Source/bmalloc/bmalloc/Scavenger.cpp index 86dbb86..b2199d7 100644 --- a/Source/bmalloc/bmalloc/Scavenger.cpp +++ b/Source/bmalloc/bmalloc/Scavenger.cpp @@ -44,6 +44,10 @@ #include #endif +#if BOS(HAIKU) +#include +#endif + #if !BUSE(LIBPAS) namespace bmalloc { @@ -363,6 +367,8 @@ void Scavenger::setThreadName(const char* name) BUNUSED(name); #if BOS(DARWIN) || BPLATFORM(PLAYSTATION) pthread_setname_np(name); +#elif BOS(HAIKU) + rename_thread(find_thread(NULL), name); #elif BOS(LINUX) // Truncate the given name since Linux limits the size of the thread name 16 including null terminator. std::array buf; diff --git a/Source/bmalloc/bmalloc/VMAllocate.h b/Source/bmalloc/bmalloc/VMAllocate.h index 4315b4c..147d766 100644 --- a/Source/bmalloc/bmalloc/VMAllocate.h +++ b/Source/bmalloc/bmalloc/VMAllocate.h @@ -39,13 +39,17 @@ #include #endif +#if BOS(HAIKU) +#include +#endif + namespace bmalloc { #ifndef BMALLOC_VM_TAG #define BMALLOC_VM_TAG VM_TAG_FOR_TCMALLOC_MEMORY #endif -#if BOS(LINUX) +#if BOS(LINUX) || BOS(HAIKU) #define BMALLOC_NORESERVE MAP_NORESERVE #else #define BMALLOC_NORESERVE 0 @@ -53,6 +57,9 @@ namespace bmalloc { inline size_t vmPageSize() { +#if BOS(HAIKU) + return B_PAGE_SIZE; +#else static size_t cached; if (!cached) { long pageSize = sysconf(_SC_PAGESIZE); @@ -61,6 +68,7 @@ inline size_t vmPageSize() cached = pageSize; } return cached; +#endif } inline size_t vmPageShift() @@ -96,6 +104,8 @@ inline size_t vmPageSizePhysical() { #if BOS(DARWIN) && (BCPU(ARM64) || BCPU(ARM)) return vm_kernel_page_size; +#elif BOS(HAIKU) + return B_PAGE_SIZE; #else static size_t cached; if (!cached) diff --git a/Source/cmake/GStreamerChecks.cmake b/Source/cmake/GStreamerChecks.cmake index ba8423e..f8e72e1 100644 --- a/Source/cmake/GStreamerChecks.cmake +++ b/Source/cmake/GStreamerChecks.cmake @@ -73,7 +73,7 @@ if (ENABLE_MEDIA_STREAM AND ENABLE_WEB_RTC) SET_AND_EXPOSE_TO_BUILD(USE_LIBWEBRTC FALSE) find_package(OpenSSL) - if (NOT OPENSSL_FOUND OR OPENSSL_VERSION VERSION_LESS "3.0.0") + if (NOT OPENSSL_FOUND OR OPENSSL_VERSION VERSION_LESS "1.0.0") message(FATAL_ERROR "OpenSSL 3 is needed for USE_GSTREAMER_WEBRTC.") endif () else () diff --git a/Source/cmake/WebKitCommon.cmake b/Source/cmake/WebKitCommon.cmake index cc96551..74b0dff 100644 --- a/Source/cmake/WebKitCommon.cmake +++ b/Source/cmake/WebKitCommon.cmake @@ -158,7 +158,9 @@ if (NOT HAS_RUN_WEBKIT_COMMON) set(WebKit_LIBRARY_TYPE SHARED) set(WebCoreTestSupport_LIBRARY_TYPE STATIC) - set(CMAKE_POSITION_INDEPENDENT_CODE True) + if (NOT HAIKU) + set(CMAKE_POSITION_INDEPENDENT_CODE True) + endif () # ----------------------------------------------------------------------------- # Install JavaScript shell -- 2.37.3 From 785393e38d10de96f9d5ffd96086aa2a767d975c Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> Date: Fri, 24 Feb 2023 18:36:15 +1000 Subject: Fix build without MACHINE_CONTEXT diff --git a/Source/JavaScriptCore/wasm/WasmFaultSignalHandler.cpp b/Source/JavaScriptCore/wasm/WasmFaultSignalHandler.cpp index d1a5e8b..4e0efd5 100644 --- a/Source/JavaScriptCore/wasm/WasmFaultSignalHandler.cpp +++ b/Source/JavaScriptCore/wasm/WasmFaultSignalHandler.cpp @@ -53,7 +53,7 @@ static constexpr bool verbose = false; static SignalAction trapHandler(Signal signal, SigInfo& sigInfo, PlatformRegisters& context) { RELEASE_ASSERT(signal == Signal::AccessFault); - +#if HAVE(MACHINE_CONTEXT) auto instructionPointer = MachineContext::instructionPointer(context); if (!instructionPointer) return SignalAction::NotHandled; @@ -97,6 +97,7 @@ static SignalAction trapHandler(Signal signal, SigInfo& sigInfo, PlatformRegiste } } } +#endif return SignalAction::NotHandled; } -- 2.37.3