xref: /freebsd/contrib/llvm-project/clang/include/clang/Basic/AlignedAllocation.h (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
1 //===--- AlignedAllocation.h - Aligned Allocation ---------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// Defines a function that returns the minimum OS versions supporting
11 /// C++17's aligned allocation functions.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_BASIC_ALIGNEDALLOCATION_H
16 #define LLVM_CLANG_BASIC_ALIGNEDALLOCATION_H
17 
18 #include "llvm/Support/ErrorHandling.h"
19 #include "llvm/Support/VersionTuple.h"
20 #include "llvm/TargetParser/Triple.h"
21 
22 namespace clang {
23 
alignedAllocMinVersion(llvm::Triple::OSType OS)24 inline llvm::VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS) {
25   switch (OS) {
26   default:
27     break;
28   case llvm::Triple::Darwin:
29   case llvm::Triple::MacOSX: // Earliest supporting version is 10.13.
30     return llvm::VersionTuple(10U, 13U);
31   case llvm::Triple::IOS:
32   case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0.
33     return llvm::VersionTuple(11U);
34   case llvm::Triple::WatchOS: // Earliest supporting version is 4.0.0.
35     return llvm::VersionTuple(4U);
36   case llvm::Triple::ZOS:
37     return llvm::VersionTuple(); // All z/OS versions have no support.
38   }
39 
40   llvm_unreachable("Unexpected OS");
41 }
42 
43 } // end namespace clang
44 
45 #endif // LLVM_CLANG_BASIC_ALIGNEDALLOCATION_H
46