llvm/compiler-rt/lib/scudo/standalone/allocator_config.h

//===-- allocator_config.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
//
//===----------------------------------------------------------------------===//

#ifndef SCUDO_ALLOCATOR_CONFIG_H_
#define SCUDO_ALLOCATOR_CONFIG_H_

#include "combined.h"
#include "common.h"
#include "condition_variable.h"
#include "flags.h"
#include "primary32.h"
#include "primary64.h"
#include "secondary.h"
#include "size_class_map.h"
#include "tsd_exclusive.h"
#include "tsd_shared.h"

// To import a custom configuration, define `SCUDO_USE_CUSTOM_CONFIG` and
// aliasing the `Config` like:
//
// namespace scudo {
//   // The instance of Scudo will be initiated with `Config`.
//   typedef CustomConfig Config;
//   // Aliasing as default configuration to run the tests with this config.
//   typedef CustomConfig DefaultConfig;
// } // namespace scudo
//
// Put them in the header `custom_scudo_config.h` then you will be using the
// custom configuration and able to run all the tests as well.
#ifdef SCUDO_USE_CUSTOM_CONFIG
#include "custom_scudo_config.h"
#endif

namespace scudo {

// Scudo uses a structure as a template argument that specifies the
// configuration options for the various subcomponents of the allocator. See the
// following configs as examples and check `allocator_config.def` for all the
// available options.

#ifndef SCUDO_USE_CUSTOM_CONFIG

// Default configurations for various platforms. Note this is only enabled when
// there's no custom configuration in the build system.
struct DefaultConfig {};

#endif // SCUDO_USE_CUSTOM_CONFIG

struct AndroidConfig {};

#if SCUDO_CAN_USE_PRIMARY64
struct FuchsiaConfig {};

struct TrustyConfig {};
#endif

#ifndef SCUDO_USE_CUSTOM_CONFIG

#if SCUDO_ANDROID
typedef AndroidConfig Config;
#elif SCUDO_FUCHSIA
typedef FuchsiaConfig Config;
#elif SCUDO_TRUSTY
typedef TrustyConfig Config;
#else
Config;
#endif

#endif // SCUDO_USE_CUSTOM_CONFIG

} // namespace scudo

#endif // SCUDO_ALLOCATOR_CONFIG_H_