1// Copyright 2012 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "partition_alloc/partition_alloc_base/ios/ios_util.h"
6
7#include <array>
8
9#include "partition_alloc/partition_alloc_base/system/sys_info.h"
10
11namespace partition_alloc::internal::base::ios {
12
13bool IsRunningOnOrLater(int32_t major, int32_t minor, int32_t bug_fix) {
14  static const class OSVersion {
15   public:
16    OSVersion() {
17      SysInfo::OperatingSystemVersionNumbers(
18          &current_version_[0], &current_version_[1], &current_version_[2]);
19    }
20
21    bool IsRunningOnOrLater(int32_t version[3]) const {
22      for (size_t i = 0; i < std::size(current_version_); ++i) {
23        if (current_version_[i] != version[i]) {
24          return current_version_[i] > version[i];
25        }
26      }
27      return true;
28    }
29
30   private:
31    int32_t current_version_[3];
32  } kOSVersion;
33
34  int32_t version[3] = {major, minor, bug_fix};
35  return kOSVersion.IsRunningOnOrLater(version);
36}
37
38}  // namespace partition_alloc::internal::base::ios
39