mirror of
https://github.com/InstanceBrick/nightcap.git
synced 2026-10-18 02:00:48 +02:00
47 lines
1.8 KiB
C++
47 lines
1.8 KiB
C++
// Copyright 2026 Mocktail Project Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#ifndef MOCKTAIL_COMPAT_BIONIC_PTHREAD_CREATE_RUNTIME_H_
|
|
#define MOCKTAIL_COMPAT_BIONIC_PTHREAD_CREATE_RUNTIME_H_
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <cstddef>
|
|
|
|
namespace mocktail::compat {
|
|
|
|
using NativeThreadInitializer = void (*)();
|
|
|
|
// Bionic reserves 32 KiB of its 1 MiB thread allocation for the signal stack.
|
|
inline constexpr size_t kBionicLp64DefaultThreadStackSize =
|
|
(1U * 1024U * 1024U) - (32U * 1024U);
|
|
static_assert(kBionicLp64DefaultThreadStackSize == 1015808U);
|
|
|
|
// Retry floor when the host rejects the Bionic-sized stack.
|
|
inline constexpr size_t kBionicLp64FallbackThreadStackSize = 2U * 1024U * 1024U;
|
|
|
|
// nullptr restores host behavior.
|
|
void ConfigureBionicPthreadThreadInitializer(
|
|
NativeThreadInitializer initializer) noexcept;
|
|
|
|
} // namespace mocktail::compat
|
|
|
|
// Rebuilds attributes instead of passing Android pthread_attr_t to glibc.
|
|
extern "C" int mocktail_bionic_pthread_create(pthread_t* thread,
|
|
const pthread_attr_t* attr,
|
|
void* (*start_routine)(void*),
|
|
void* argument);
|
|
|
|
#endif // MOCKTAIL_COMPAT_BIONIC_PTHREAD_CREATE_RUNTIME_H_
|