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

Side by Side Diff: third_party/tcmalloc/vendor/src/malloc_hook_mmap_linux.h

Issue 9701040: Revert 126715 - Update the tcmalloc vendor branch to r144 (gperftools 2.0). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2005, Google Inc. 1 // Copyright (c) 2005, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 30 matching lines...) Expand all
41 41
42 #include <unistd.h> 42 #include <unistd.h>
43 #include <syscall.h> 43 #include <syscall.h>
44 #include <sys/mman.h> 44 #include <sys/mman.h>
45 #include <errno.h> 45 #include <errno.h>
46 #include "base/linux_syscall_support.h" 46 #include "base/linux_syscall_support.h"
47 47
48 // The x86-32 case and the x86-64 case differ: 48 // The x86-32 case and the x86-64 case differ:
49 // 32b has a mmap2() syscall, 64b does not. 49 // 32b has a mmap2() syscall, 64b does not.
50 // 64b and 32b have different calling conventions for mmap(). 50 // 64b and 32b have different calling conventions for mmap().
51 51 #if defined(__i386__) || defined(__PPC__)
52 // I test for 64-bit first so I don't have to do things like
53 // '#if (defined(__mips__) && !defined(__MIPS64__))' as a mips32 check.
54 #if defined(__x86_64__) || defined(__PPC64__) || (defined(_MIPS_SIM) && _MIPS_SI M == _ABI64)
55
56 static inline void* do_mmap64(void *start, size_t length,
57 int prot, int flags,
58 int fd, __off64_t offset) __THROW {
59 return sys_mmap(start, length, prot, flags, fd, offset);
60 }
61
62 #define MALLOC_HOOK_HAVE_DO_MMAP64 1
63
64 #elif defined(__i386__) || defined(__PPC__) || defined(__mips__) || \
65 defined(__arm__)
66 52
67 static inline void* do_mmap64(void *start, size_t length, 53 static inline void* do_mmap64(void *start, size_t length,
68 int prot, int flags, 54 int prot, int flags,
69 int fd, __off64_t offset) __THROW { 55 int fd, __off64_t offset) __THROW {
70 void *result; 56 void *result;
71 57
72 // Try mmap2() unless it's not supported 58 // Try mmap2() unless it's not supported
73 static bool have_mmap2 = true; 59 static bool have_mmap2 = true;
74 if (have_mmap2) { 60 if (have_mmap2) {
75 static int pagesize = 0; 61 static int pagesize = 0;
(...skipping 16 matching lines...) Expand all
92 } 78 }
93 79
94 if (((off_t)offset) != offset) { 80 if (((off_t)offset) != offset) {
95 // If we're trying to map a 64-bit offset, fail now since we don't 81 // If we're trying to map a 64-bit offset, fail now since we don't
96 // have 64-bit mmap() support. 82 // have 64-bit mmap() support.
97 result = MAP_FAILED; 83 result = MAP_FAILED;
98 errno = EINVAL; 84 errno = EINVAL;
99 goto out; 85 goto out;
100 } 86 }
101 87
102 #ifdef __NR_mmap
103 { 88 {
104 // Fall back to old 32-bit offset mmap() call 89 // Fall back to old 32-bit offset mmap() call
105 // Old syscall interface cannot handle six args, so pass in an array 90 // Old syscall interface cannot handle six args, so pass in an array
106 int32 args[6] = { (int32) start, (int32) length, prot, flags, fd, 91 int32 args[6] = { (int32) start, length, prot, flags, fd, (off_t) offset };
107 (off_t) offset };
108 result = (void *)syscall(SYS_mmap, args); 92 result = (void *)syscall(SYS_mmap, args);
109 } 93 }
110 #else
111 // Some Linux ports like ARM EABI Linux has no mmap, just mmap2.
112 result = MAP_FAILED;
113 #endif
114
115 out: 94 out:
116 return result; 95 return result;
117 } 96 }
118 97
119 #define MALLOC_HOOK_HAVE_DO_MMAP64 1 98 #define MALLOC_HOOK_HAVE_DO_MMAP64 1
120 99
121 #endif // #if defined(__x86_64__) 100 #elif defined(__x86_64__) || defined(__PPC64__) // #if defined(__i386__) || ...
101
102 static inline void* do_mmap64(void *start, size_t length,
103 int prot, int flags,
104 int fd, __off64_t offset) __THROW {
105 return (void *)syscall(SYS_mmap, start, length, prot, flags, fd, offset);
106 }
107
108 #define MALLOC_HOOK_HAVE_DO_MMAP64 1
109
110 #endif // #if defined(__i386__) || defined(__PPC__)
122 111
123 112
124 #ifdef MALLOC_HOOK_HAVE_DO_MMAP64 113 #ifdef MALLOC_HOOK_HAVE_DO_MMAP64
125 114
126 // We use do_mmap64 abstraction to put MallocHook::InvokeMmapHook 115 // We use do_mmap64 abstraction to put MallocHook::InvokeMmapHook
127 // calls right into mmap and mmap64, so that the stack frames in the caller's 116 // calls right into mmap and mmap64, so that the stack frames in the caller's
128 // stack are at the same offsets for all the calls of memory allocating 117 // stack are at the same offsets for all the calls of memory allocating
129 // functions. 118 // functions.
130 119
131 // Put all callers of MallocHook::Invoke* in this module into 120 // Put all callers of MallocHook::Invoke* in this module into
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 int result; 214 int result;
226 if (!MallocHook::InvokeMunmapReplacement(start, length, &result)) { 215 if (!MallocHook::InvokeMunmapReplacement(start, length, &result)) {
227 result = syscall(SYS_munmap, start, length); 216 result = syscall(SYS_munmap, start, length);
228 } 217 }
229 return result; 218 return result;
230 } 219 }
231 220
232 #undef MALLOC_HOOK_HAVE_DO_MMAP64 221 #undef MALLOC_HOOK_HAVE_DO_MMAP64
233 222
234 #endif // #ifdef MALLOC_HOOK_HAVE_DO_MMAP64 223 #endif // #ifdef MALLOC_HOOK_HAVE_DO_MMAP64
OLDNEW
« no previous file with comments | « third_party/tcmalloc/vendor/src/malloc_hook_mmap_freebsd.h ('k') | third_party/tcmalloc/vendor/src/memfs_malloc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698