$NetBSD$ * Part of patchset to build chromium on NetBSD * Based on OpenBSD's chromium patches, and pkgsrc's qt5-qtwebengine patches --- v8/src/base/platform/platform-openbsd.cc.orig 2025-09-08 23:21:33.000000000 +0000 +++ v8/src/base/platform/platform-openbsd.cc @@ -6,6 +6,9 @@ // POSIX-compatible parts, the implementation is in platform-posix.cc. #include +#if !defined(__NetBSD__) +#include +#endif #include #include #include @@ -122,6 +125,34 @@ void OS::SignalCodeMovingGC() { void OS::AdjustSchedulingParams() {} +// static +Stack::StackSlot Stack::ObtainCurrentThreadStackStart() { +#if defined(__NetBSD__) + pthread_attr_t attr; + int error; + pthread_attr_init(&attr); + error = pthread_attr_get_np(pthread_self(), &attr); + if (!error) { + void* base; + size_t size; + error = pthread_attr_getstack(&attr, &base, &size); + CHECK(!error); + pthread_attr_destroy(&attr); + return reinterpret_cast(base) + size; + } + pthread_attr_destroy(&attr); + return nullptr; +#else + stack_t ss; + void *base; + if (pthread_stackseg_np(pthread_self(), &ss) != 0) + return nullptr; + + base = (void*)((size_t) ss.ss_sp - ss.ss_size); + return reinterpret_cast(base) + ss.ss_size; +#endif +} + std::optional OS::GetFirstFreeMemoryRangeWithin( OS::Address boundary_start, OS::Address boundary_end, size_t minimum_size, size_t alignment) {