folly/folly/test/DeterministicSchedule.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/test/DeterministicSchedule.h>

#include <algorithm>
#include <cassert>
#include <list>
#include <mutex>
#include <random>
#include <unordered_map>
#include <utility>

#include <folly/Random.h>
#include <folly/SingletonThreadLocal.h>

namespace folly {
namespace test {

Sem;

AuxChk DeterministicSchedule::aux_chk;

// access is protected by futexLock
static std::unordered_map<
    const detail::Futex<DeterministicAtomic>*,
    std::list<std::pair<uint32_t, bool*>>>
    futexQueues;

static std::mutex futexLock;

void ThreadTimestamps::sync(const ThreadTimestamps& src) {}

DSchedTimestamp ThreadTimestamps::advance(DSchedThreadId tid) {}

void ThreadTimestamps::setIfNotPresent(DSchedThreadId tid, DSchedTimestamp ts) {}

void ThreadTimestamps::clear() {}

bool ThreadTimestamps::atLeastAsRecentAs(
    DSchedThreadId tid, DSchedTimestamp ts) const {}

bool ThreadTimestamps::atLeastAsRecentAsAny(const ThreadTimestamps& src) const {}

void ThreadSyncVar::acquire() {}

void ThreadSyncVar::release() {}

void ThreadSyncVar::acq_rel() {}

namespace {

struct PerThreadState {};
TLState;

} // namespace

DeterministicSchedule::DeterministicSchedule(
    std::function<size_t(size_t)> scheduler)
    :{}

DeterministicSchedule::~DeterministicSchedule() {}

std::function<size_t(size_t)> DeterministicSchedule::uniform(uint64_t seed) {}

struct UniformSubset {};

bool DeterministicSchedule::isCurrentThreadExiting() {}

bool DeterministicSchedule::isActive() {}

DSchedThreadId DeterministicSchedule::getThreadId() {}

DeterministicSchedule* DeterministicSchedule::getCurrentSchedule() {}

std::function<size_t(size_t)> DeterministicSchedule::uniformSubset(
    uint64_t seed, size_t n, size_t m) {}

void DeterministicSchedule::beforeSharedAccess() {}

void DeterministicSchedule::afterSharedAccess() {}

void DeterministicSchedule::afterSharedAccess(bool success) {}

size_t DeterministicSchedule::getRandNumber(size_t n) {}

int DeterministicSchedule::getcpu(
    unsigned* cpu, unsigned* node, void* /* unused */) {}

void DeterministicSchedule::setAuxAct(AuxAct& aux) {}

void DeterministicSchedule::setAuxChk(AuxChk& aux) {}

void DeterministicSchedule::clearAuxChk() {}

void DeterministicSchedule::reschedule(Sem* sem) {}

Sem* DeterministicSchedule::descheduleCurrentThread() {}

Sem* DeterministicSchedule::beforeThreadCreate() {}

void DeterministicSchedule::afterThreadCreate(Sem* sem) {}

void DeterministicSchedule::beforeThreadExit() {}

void DeterministicSchedule::waitForBeforeThreadExit(std::thread& child) {}

void DeterministicSchedule::joinAll(std::vector<std::thread>& children) {}

void DeterministicSchedule::join(std::thread& child) {}

void DeterministicSchedule::callAux(bool success) {}

static std::unordered_map<Sem*, std::unique_ptr<ThreadSyncVar>> semSyncVar;

void DeterministicSchedule::post(Sem* sem) {}

bool DeterministicSchedule::tryWait(Sem* sem) {}

void DeterministicSchedule::wait(Sem* sem) {}

ThreadInfo& DeterministicSchedule::getCurrentThreadInfo() {}

void DeterministicSchedule::atomic_thread_fence(std::memory_order mo) {}

detail::FutexResult futexWaitImpl(
    const detail::Futex<DeterministicAtomic>* futex,
    uint32_t expected,
    std::chrono::system_clock::time_point const* absSystemTimeout,
    std::chrono::steady_clock::time_point const* absSteadyTimeout,
    uint32_t waitMask) {}

int futexWakeImpl(
    const detail::Futex<DeterministicAtomic>* futex,
    int count,
    uint32_t wakeMask) {}

} // namespace test
} // namespace folly

namespace folly {

template <>
CacheLocality const& CacheLocality::system<test::DeterministicAtomic>() {}

template <>
Getcpu::Func AccessSpreader<test::DeterministicAtomic>::pickGetcpuFunc() {}
} // namespace folly