llvm/compiler-rt/lib/sanitizer_common/sanitizer_addrhashmap.h

//===-- sanitizer_addrhashmap.h ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Concurrent uptr->T hashmap.
//
//===----------------------------------------------------------------------===//

#ifndef SANITIZER_ADDRHASHMAP_H
#define SANITIZER_ADDRHASHMAP_H

#include "sanitizer_common.h"
#include "sanitizer_mutex.h"
#include "sanitizer_atomic.h"
#include "sanitizer_allocator_internal.h"

namespace __sanitizer {

// Concurrent uptr->T hashmap.
// T must be a POD type, kSize is preferably a prime but can be any number.
// Usage example:
//
// typedef AddrHashMap<uptr, 11> Map;
// Map m;
// {
//   Map::Handle h(&m, addr);
//   use h.operator->() to access the data
//   if h.created() then the element was just created, and the current thread
//     has exclusive access to it
//   otherwise the current thread has only read access to the data
// }
// {
//   Map::Handle h(&m, addr, true);
//   this will remove the data from the map in Handle dtor
//   the current thread has exclusive access to the data
//   if !h.exists() then the element never existed
// }
// {
//   Map::Handle h(&m, addr, false, true);
//   this will create a new element or return a handle to an existing element
//   if !h.created() this thread does *not* have exclusive access to the data
// }
template<typename T, uptr kSize>
class AddrHashMap {};

template <typename T, uptr kSize>
void AddrHashMap<T, kSize>::ForEach(ForEachCallback cb, void *arg) {}

template<typename T, uptr kSize>
AddrHashMap<T, kSize>::Handle::Handle(AddrHashMap<T, kSize> *map, uptr addr) {}

template<typename T, uptr kSize>
AddrHashMap<T, kSize>::Handle::Handle(AddrHashMap<T, kSize> *map, uptr addr,
    bool remove) {}

template<typename T, uptr kSize>
AddrHashMap<T, kSize>::Handle::Handle(AddrHashMap<T, kSize> *map, uptr addr,
    bool remove, bool create) {}

template<typename T, uptr kSize>
AddrHashMap<T, kSize>::Handle::~Handle() {}

template <typename T, uptr kSize>
T *AddrHashMap<T, kSize>::Handle::operator->() {}

template <typename T, uptr kSize>
const T &AddrHashMap<T, kSize>::Handle::operator*() const {}

template <typename T, uptr kSize>
T &AddrHashMap<T, kSize>::Handle::operator*() {}

template<typename T, uptr kSize>
bool AddrHashMap<T, kSize>::Handle::created() const {}

template<typename T, uptr kSize>
bool AddrHashMap<T, kSize>::Handle::exists() const {}

template<typename T, uptr kSize>
AddrHashMap<T, kSize>::AddrHashMap() {}

template <typename T, uptr kSize>
void AddrHashMap<T, kSize>::acquire(Handle *h)
    SANITIZER_NO_THREAD_SAFETY_ANALYSIS {}

 template <typename T, uptr kSize>
 void AddrHashMap<T, kSize>::release(Handle *h)
     SANITIZER_NO_THREAD_SAFETY_ANALYSIS {}

template<typename T, uptr kSize>
uptr AddrHashMap<T, kSize>::calcHash(uptr addr) {}

} // namespace __sanitizer

#endif // SANITIZER_ADDRHASHMAP_H