michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=8 et : michael@0: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include michael@0: #include "Hal.h" michael@0: michael@0: namespace mozilla { michael@0: namespace hal_impl { michael@0: michael@0: uint32_t michael@0: GetTotalSystemMemory() michael@0: { michael@0: static uint32_t sTotalMemory; michael@0: static bool sTotalMemoryObtained = false; michael@0: michael@0: if (!sTotalMemoryObtained) { michael@0: sTotalMemoryObtained = true; michael@0: michael@0: FILE* fd = fopen("/proc/meminfo", "r"); michael@0: if (!fd) { michael@0: return 0; michael@0: } michael@0: michael@0: int rv = fscanf(fd, "MemTotal: %i kB", &sTotalMemory); michael@0: michael@0: if (fclose(fd) || rv != 1) { michael@0: return 0; michael@0: } michael@0: } michael@0: michael@0: return sTotalMemory * 1024; michael@0: } michael@0: michael@0: } // namespace hal_impl michael@0: } // namespace mozilla