mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Configure the runtime to build with -Wglobal-constructors, and Lazy-fy almost everything that gets flagged. (I gave "swift_isaMask" a pass since that's almost definitely hot enough to warrant a static initialization.) Make some improvements to the Lazy wrapper, using aligned_storage to ensure that it's trivially constructed and destructed. Swift SVN r28199
64 lines
2.1 KiB
C++
64 lines
2.1 KiB
C++
//===--- Config.h - Swift Language Platform Configuration ------*- C++ -*--===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See http://swift.org/LICENSE.txt for license information
|
|
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Definitions of common interest in Swift.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_RUNTIME_CONFIG_H
|
|
#define SWIFT_RUNTIME_CONFIG_H
|
|
|
|
/// Does the current Swift platform support "unbridged" interoperation
|
|
/// with Objective-C? If so, the implementations of various types must
|
|
/// implicitly handle Objective-C pointers.
|
|
///
|
|
/// Apple platforms support this by default.
|
|
#ifndef SWIFT_OBJC_INTEROP
|
|
#ifdef __APPLE__
|
|
#define SWIFT_OBJC_INTEROP 1
|
|
#else
|
|
#define SWIFT_OBJC_INTEROP 0
|
|
#endif
|
|
#endif
|
|
|
|
/// Does the current Swift platform allow information other than the
|
|
/// class pointer to be stored in the isa field? If so, when deriving
|
|
/// the class pointer of an object, we must apply a
|
|
/// dynamically-determined mask to the value loaded from the first
|
|
/// field of the object.
|
|
///
|
|
/// According to the Objective-C ABI, this is true only for 64-bit
|
|
/// platforms.
|
|
#ifndef SWIFT_HAS_ISA_MASKING
|
|
#if SWIFT_OBJC_INTEROP && defined(__LP64__)
|
|
#define SWIFT_HAS_ISA_MASKING 1
|
|
#else
|
|
#define SWIFT_HAS_ISA_MASKING 0
|
|
#endif
|
|
#endif
|
|
|
|
// We try to avoid global constructors in the runtime as much as possible.
|
|
// These macros delimit allowed global ctors.
|
|
#if __clang__
|
|
# define SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_BEGIN \
|
|
_Pragma("clang diagnostic push") \
|
|
_Pragma("clang diagnostic ignored \"-Wglobal-constructors\"")
|
|
# define SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_END \
|
|
_Pragma("clang diagnostic pop")
|
|
#else
|
|
# define SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_BEGIN
|
|
# define SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_END
|
|
#endif
|
|
|
|
#endif // SWIFT_RUNTIME_CONFIG_H
|
|
|