1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/sys_info.h"
7 #include <ApplicationServices/ApplicationServices.h>
8 #include <CoreServices/CoreServices.h>
9 #include <mach/mach_host.h>
10 #include <mach/mach_init.h>
12 #include "base/logging.h"
13 #include "base/stringprintf.h"
18 std::string
SysInfo::OperatingSystemName() {
23 std::string
SysInfo::OperatingSystemVersion() {
24 int32 major
, minor
, bugfix
;
25 OperatingSystemVersionNumbers(&major
, &minor
, &bugfix
);
26 return base::StringPrintf("%d.%d.%d", major
, minor
, bugfix
);
30 void SysInfo::OperatingSystemVersionNumbers(int32
* major_version
,
32 int32
* bugfix_version
) {
33 Gestalt(gestaltSystemVersionMajor
,
34 reinterpret_cast<SInt32
*>(major_version
));
35 Gestalt(gestaltSystemVersionMinor
,
36 reinterpret_cast<SInt32
*>(minor_version
));
37 Gestalt(gestaltSystemVersionBugFix
,
38 reinterpret_cast<SInt32
*>(bugfix_version
));
42 int64
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(),
47 reinterpret_cast<host_info_t
>(&hostinfo
),
49 DCHECK_EQ(HOST_BASIC_INFO_COUNT
, count
);
50 if (result
!= KERN_SUCCESS
) {
55 return static_cast<int64
>(hostinfo
.max_mem
);