Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Unified Diff: src/base/platform/platform-fuchsia.cc

Issue 2930343002: Fuchsia: implement OS::Allocate (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/platform/platform-fuchsia.cc
diff --git a/src/base/platform/platform-fuchsia.cc b/src/base/platform/platform-fuchsia.cc
index 149ca037e47dedb69c9fe1a987a3600486a43c3d..dc39297a6d9dcc8584edda575cce25165f02cfed 100644
--- a/src/base/platform/platform-fuchsia.cc
+++ b/src/base/platform/platform-fuchsia.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <sys/mman.h>
+
#include "src/base/macros.h"
#include "src/base/platform/platform-posix.h"
#include "src/base/platform/platform.h"
@@ -11,6 +13,17 @@ namespace base {
TimezoneCache* OS::CreateTimezoneCache() { return new PosixTimezoneCache(); }
+void* OS::Allocate(const size_t requested, size_t* allocated,
+ OS::MemoryPermission access) {
+ const size_t msize = RoundUp(requested, AllocateAlignment());
+ int prot = GetProtectionFromMemoryPermission(access);
+ void* addr = OS::GetRandomMmapAddr();
+ void* mbase = mmap(addr, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (mbase == MAP_FAILED) return NULL;
+ *allocated = msize;
+ return mbase;
+}
+
std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
CHECK(false); // TODO(fuchsia): Port, https://crbug.com/731217.
return std::vector<SharedLibraryAddress>();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698