blob: d8210a299932571fd0d41042918daf38e06577e3 [file] [log] [blame]
[email protected]f481221192011-04-07 22:15:341// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]71aa16c2009-02-24 16:37:132// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "base/sys_info.h"
6
[email protected]c8587632009-11-12 02:17:197#include <ApplicationServices/ApplicationServices.h>
[email protected]71aa16c2009-02-24 16:37:138#include <CoreServices/CoreServices.h>
[email protected]c8587632009-11-12 02:17:199#include <mach/mach_host.h>
10#include <mach/mach_init.h>
11
12#include "base/logging.h"
[email protected]6e001bb2011-05-25 20:53:1813#include "base/stringprintf.h"
[email protected]71aa16c2009-02-24 16:37:1314
15namespace base {
16
17// static
[email protected]6e001bb2011-05-25 20:53:1818std::string SysInfo::OperatingSystemName() {
19 return "Mac OS X";
20}
21
22// static
23std::string SysInfo::OperatingSystemVersion() {
24 int32 major, minor, bugfix;
25 OperatingSystemVersionNumbers(&major, &minor, &bugfix);
26 return base::StringPrintf("%d.%d.%d", major, minor, bugfix);
27}
28
29// static
[email protected]f481221192011-04-07 22:15:3430void SysInfo::OperatingSystemVersionNumbers(int32* major_version,
31 int32* minor_version,
32 int32* bugfix_version) {
[email protected]0203ed72009-07-02 13:59:0833 Gestalt(gestaltSystemVersionMajor,
[email protected]3a3e5b32009-08-21 22:30:4734 reinterpret_cast<SInt32*>(major_version));
[email protected]0203ed72009-07-02 13:59:0835 Gestalt(gestaltSystemVersionMinor,
[email protected]3a3e5b32009-08-21 22:30:4736 reinterpret_cast<SInt32*>(minor_version));
[email protected]0203ed72009-07-02 13:59:0837 Gestalt(gestaltSystemVersionBugFix,
[email protected]3a3e5b32009-08-21 22:30:4738 reinterpret_cast<SInt32*>(bugfix_version));
[email protected]71aa16c2009-02-24 16:37:1339}
40
[email protected]c8587632009-11-12 02:17:1941// static
42int64 SysInfo::AmountOfPhysicalMemory() {
43 struct host_basic_info hostinfo;
44 mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
45 int result = host_info(mach_host_self(),
46 HOST_BASIC_INFO,
47 reinterpret_cast<host_info_t>(&hostinfo),
48 &count);
49 DCHECK_EQ(HOST_BASIC_INFO_COUNT, count);
50 if (result != KERN_SUCCESS) {
51 NOTREACHED();
52 return 0;
53 }
54
55 return static_cast<int64>(hostinfo.max_mem);
56}
57
[email protected]71aa16c2009-02-24 16:37:1358} // namespace base