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

Unified Diff: third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h

Issue 14859005: Support Android in MallocHook for mmap, munmap and mremap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit fix Created 7 years, 7 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
Index: third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h
diff --git a/third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h b/third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h
index 054b91b257e67974cb10ae824d22943296eab23a..f7387ab8a48a0825526ffc54c22bc3111b7ce09d 100644
--- a/third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h
+++ b/third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h
@@ -40,11 +40,30 @@
#endif
#include <unistd.h>
+#if defined(__ANDROID__) || defined(ANDROID)
+#include <sys/syscall.h>
+#include <sys/linux-syscalls.h>
+#else
#include <syscall.h>
+#endif
#include <sys/mman.h>
#include <errno.h>
#include "base/linux_syscall_support.h"
+// SYS_mmap2, SYS_munmap, SYS_mremap and __off64_t are not defined in Android.
+#if defined(__ANDROID__) || defined(ANDROID)
+#ifndef SYS_mmap2
+#define SYS_mmap2 __NR_mmap2
+#endif
+#ifndef SYS_munmap
+#define SYS_munmap __NR_munmap
+#endif
+#ifndef SYS_mremap
+#define SYS_mremap __NR_mremap
+#endif
+typedef off64_t __off64_t;
+#endif // defined(__ANDROID__) || defined(ANDROID)
+
// The x86-32 case and the x86-64 case differ:
// 32b has a mmap2() syscall, 64b does not.
// 64b and 32b have different calling conventions for mmap().
@@ -149,8 +168,10 @@ extern "C" {
void* mremap(void* old_addr, size_t old_size, size_t new_size,
int flags, ...) __THROW
ATTRIBUTE_SECTION(malloc_hook);
+#if !defined(__ANDROID__) && !defined(ANDROID)
void* sbrk(ptrdiff_t increment) __THROW
ATTRIBUTE_SECTION(malloc_hook);
+#endif
}
extern "C" void* mmap64(void *start, size_t length, int prot, int flags,
@@ -208,6 +229,8 @@ extern "C" void* mremap(void* old_addr, size_t old_size, size_t new_size,
return result;
}
+// Don't hook sbrk in Androis since Android doesn't have __sbrk.
digit1 2013/05/13 16:14:42 Small typo here. Also probably better avoid the re
Dai Mikurube (NOT FULLTIME) 2013/05/13 21:25:52 Thanks. Replaced the comment.
+#if !defined(__ANDROID__) && !defined(ANDROID)
// libc's version:
extern "C" void* __sbrk(ptrdiff_t increment);
@@ -217,6 +240,7 @@ extern "C" void* sbrk(ptrdiff_t increment) __THROW {
MallocHook::InvokeSbrkHook(result, increment);
return result;
}
+#endif // !defined(__ANDROID__) && !defined(ANDROID)
/*static*/void* MallocHook::UnhookedMMap(void *start, size_t length, int prot,
int flags, int fd, off_t offset) {

Powered by Google App Engine
This is Rietveld 408576698