folly/folly/fibers/FiberManager.cpp

/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * 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.
 */

#include <folly/fibers/FiberManagerInternal.h>

#include <csignal>

#include <cassert>
#include <stdexcept>

#include <glog/logging.h>

#include <folly/fibers/Fiber.h>
#include <folly/fibers/LoopController.h>

#include <folly/ConstexprMath.h>
#include <folly/SingletonThreadLocal.h>
#include <folly/memory/SanitizeAddress.h>
#include <folly/portability/Config.h>
#include <folly/portability/SysSyscall.h>
#include <folly/portability/Unistd.h>
#include <folly/synchronization/SanitizeThread.h>

namespace std {
template <>
struct hash<folly::fibers::FiberManager::Options> {};
} // namespace std

namespace folly {
namespace fibers {

void FiberManager::defaultExceptionCallback(
    const std::exception_ptr& eptr, StringPiece context) {}

auto FiberManager::FrozenOptions::create(const Options& options) -> ssize_t {}

/* static */ FiberManager*& FiberManager::getCurrentFiberManager() {}

FiberManager::FiberManager(
    std::unique_ptr<LoopController> loopController, Options options)
    :{}

FiberManager::~FiberManager() {}

LoopController& FiberManager::loopController() {}

const LoopController& FiberManager::loopController() const {}

bool FiberManager::hasTasks() const {}

bool FiberManager::isRemoteScheduled() const {}

Fiber* FiberManager::getFiber() {}

void FiberManager::setExceptionCallback(FiberManager::ExceptionCallback ec) {}

size_t FiberManager::fibersAllocated() const {}

size_t FiberManager::fibersPoolSize() const {}

size_t FiberManager::stackHighWatermark() const {}

void FiberManager::remoteReadyInsert(Fiber* fiber) {}

void FiberManager::addObserver(ExecutionObserver* observer) {}

void FiberManager::removeObserver(ExecutionObserver* observer) {}

ExecutionObserver::List& FiberManager::getObserverList() {}

void FiberManager::setPreemptRunner(InlineFunctionRunner* preemptRunner) {}

void FiberManager::doFibersPoolResizing() {}

void FiberManager::FibersPoolResizer::run() {}

void FiberManager::registerStartSwitchStackWithAsan(
    void** saveFakeStack, const void* stackBottom, size_t stackSize) {}

void FiberManager::registerFinishSwitchStackWithAsan(
    void* saveFakeStack, const void** saveStackBottom, size_t* saveStackSize) {}

void FiberManager::freeFakeStack(void* fakeStack) {}

void FiberManager::unpoisonFiberStack(const Fiber* fiber) {}

// TVOS and WatchOS platforms have SIGSTKSZ but not sigaltstack
#if defined(SIGSTKSZ) && !FOLLY_APPLE_TVOS && !FOLLY_APPLE_WATCHOS

namespace {

bool hasAlternateStack() {}

int setAlternateStack(char* sp, size_t size) {}

int unsetAlternateStack() {}

class ScopedAlternateSignalStack {};
} // namespace

void FiberManager::maybeRegisterAlternateSignalStack() {}

#else

void FiberManager::maybeRegisterAlternateSignalStack() {
  // no-op
}

#endif

} // namespace fibers
} // namespace folly