#include <pthread.h>
#include <sched.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <cerrno>
#include <cstddef>
#include <cstdint>
#include <memory>
#include "partition_alloc/build_config.h"
#include "partition_alloc/buildflags.h"
#include "partition_alloc/partition_alloc_base/check.h"
#include "partition_alloc/partition_alloc_base/logging.h"
#include "partition_alloc/partition_alloc_base/threading/platform_thread_for_testing.h"
#include "partition_alloc/partition_alloc_base/threading/platform_thread_internal_posix.h"
#if PA_BUILDFLAG(IS_FUCHSIA)
#include <zircon/process.h>
#else
#include <sys/resource.h>
#endif
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#include "partition_alloc/stack/stack.h"
#endif
namespace partition_alloc::internal::base {
void InitThreading();
void TerminateOnThread();
size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes);
namespace {
struct ThreadParams { … };
void* ThreadFunc(void* params) { … }
bool CreateThread(size_t stack_size,
PlatformThreadForTesting::Delegate* delegate,
PlatformThreadHandle* thread_handle) { … }
}
#if !PA_BUILDFLAG(IS_APPLE)
void PlatformThreadForTesting::YieldCurrentThread() { … }
#endif
bool PlatformThreadForTesting::Create(size_t stack_size,
Delegate* delegate,
PlatformThreadHandle* thread_handle) { … }
void PlatformThreadForTesting::Join(PlatformThreadHandle thread_handle) { … }
size_t PlatformThreadForTesting::GetDefaultThreadStackSize() { … }
}