mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
f7745f2094
Rather than attempt to use standard C++ type names, create a namespace specifically for environment variable types and require vars to use a type from that namespace. This avoids the annoying collision between this `string` and `std::string`, and makes everything a bit more consistent. Rename the types a bit to be more appropriate for this context: boolean, uint8, and uint32, instead of bool, uint8_t, and uint32_t.
86 lines
3.5 KiB
C++
86 lines
3.5 KiB
C++
//===--- EnvironmentVariables.h - Debug variables. --------------*- C++ -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Debug behavior conditionally enabled using environment variables.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_RUNTIME_ENVIRONMENTVARIABLES_H
|
|
#define SWIFT_RUNTIME_ENVIRONMENTVARIABLES_H
|
|
|
|
#include "swift/Threading/Once.h"
|
|
#include "swift/shims/Visibility.h"
|
|
|
|
namespace swift {
|
|
namespace runtime {
|
|
namespace environment {
|
|
|
|
void initialize(void *);
|
|
|
|
extern swift::once_t initializeToken;
|
|
|
|
// Types that can be used for environment variables.
|
|
namespace types {
|
|
using boolean = bool;
|
|
using string = const char *;
|
|
using uint8 = uint8_t;
|
|
using uint32 = uint32_t;
|
|
} // namespace types
|
|
|
|
// Declare backing variables.
|
|
#define VARIABLE(name, type, defaultValue, help) \
|
|
extern swift::runtime::environment::types::type name##_variable; \
|
|
extern bool name##_isSet_variable;
|
|
#include "../../../stdlib/public/runtime/EnvironmentVariables.def"
|
|
|
|
// Define getter functions. This creates one function with the same name as the
|
|
// variable which returns the value set for that variable, and second function
|
|
// ending in _isSet which returns a boolean indicating whether the variable was
|
|
// set at all, to allow detecting when the variable was explicitly set to the
|
|
// same value as the default.
|
|
#define VARIABLE(name, type, defaultValue, help) \
|
|
inline swift::runtime::environment::types::type name() { \
|
|
swift::once(initializeToken, initialize, nullptr); \
|
|
return name##_variable; \
|
|
} \
|
|
inline bool name##_isSet() { \
|
|
swift::once(initializeToken, initialize, nullptr); \
|
|
return name##_isSet_variable; \
|
|
}
|
|
#include "../../../stdlib/public/runtime/EnvironmentVariables.def"
|
|
|
|
// Wrapper around SWIFT_DEBUG_CONCURRENCY_ENABLE_COOPERATIVE_QUEUES that the
|
|
// Concurrency library can call.
|
|
SWIFT_RUNTIME_STDLIB_SPI bool concurrencyEnableCooperativeQueues();
|
|
|
|
// Wrapper around SWIFT_DEBUG_VALIDATE_UNCHECKED_CONTINUATIONS that the
|
|
// Concurrency library can call.
|
|
SWIFT_RUNTIME_STDLIB_SPI bool concurrencyValidateUncheckedContinuations();
|
|
|
|
// Wrapper around SWIFT_IS_CURRENT_EXECUTOR_LEGACY_MODE_OVERRIDE that the
|
|
// Concurrency library can call.
|
|
SWIFT_RUNTIME_STDLIB_SPI const char *concurrencyIsCurrentExecutorLegacyModeOverride();
|
|
|
|
// Wrapper around SWIFT_DEBUG_ENABLE_TASK_SLAB_ALLOCATOR that the Concurrency
|
|
// library can call.
|
|
SWIFT_RUNTIME_STDLIB_SPI bool concurrencyEnableTaskSlabAllocator();
|
|
|
|
// Wrapper around SWIFT_CONCURRENCY_TRACING_SUBSYSTEM that the Concurrency
|
|
// library can call.
|
|
SWIFT_RUNTIME_STDLIB_SPI const char *concurrencyTracingSubsystem();
|
|
|
|
} // end namespace environment
|
|
} // end namespace runtime
|
|
} // end namespace swift
|
|
|
|
#endif // SWIFT_RUNTIME_ENVIRONMENTVARIABLES_H
|