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

Side by Side Diff: src/common/memory.h

Issue 2065493006: linux-syscall-support: pull in latest version (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « src/common/linux/memory_mapped_file.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009, Google Inc. 1 // Copyright (c) 2009, 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 26 matching lines...) Expand all
37 37
38 #include <memory> 38 #include <memory>
39 #include <vector> 39 #include <vector>
40 40
41 #if defined(MEMORY_SANITIZER) 41 #if defined(MEMORY_SANITIZER)
42 #include <sanitizer/msan_interface.h> 42 #include <sanitizer/msan_interface.h>
43 #endif 43 #endif
44 44
45 #ifdef __APPLE__ 45 #ifdef __APPLE__
46 #define sys_mmap mmap 46 #define sys_mmap mmap
47 #define sys_mmap2 mmap
48 #define sys_munmap munmap 47 #define sys_munmap munmap
49 #define MAP_ANONYMOUS MAP_ANON 48 #define MAP_ANONYMOUS MAP_ANON
50 #else 49 #else
51 #include "third_party/lss/linux_syscall_support.h" 50 #include "third_party/lss/linux_syscall_support.h"
52 #endif 51 #endif
53 52
54 namespace google_breakpad { 53 namespace google_breakpad {
55 54
56 // This is very simple allocator which fetches pages from the kernel directly. 55 // This is very simple allocator which fetches pages from the kernel directly.
57 // Thus, it can be used even when the heap may be corrupted. 56 // Thus, it can be used even when the heap may be corrupted.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 return true; 109 return true;
111 } 110 }
112 111
113 return false; 112 return false;
114 } 113 }
115 114
116 unsigned long pages_allocated() { return pages_allocated_; } 115 unsigned long pages_allocated() { return pages_allocated_; }
117 116
118 private: 117 private:
119 uint8_t *GetNPages(size_t num_pages) { 118 uint8_t *GetNPages(size_t num_pages) {
120 #if defined(__x86_64__) || defined(__aarch64__) || defined(__aarch64__) || \
121 ((defined(__mips__) && _MIPS_SIM == _ABI64))
122 void *a = sys_mmap(NULL, page_size_ * num_pages, PROT_READ | PROT_WRITE, 119 void *a = sys_mmap(NULL, page_size_ * num_pages, PROT_READ | PROT_WRITE,
123 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 120 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
124 #else
125 void *a = sys_mmap2(NULL, page_size_ * num_pages, PROT_READ | PROT_WRITE,
126 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
127 #endif
128 if (a == MAP_FAILED) 121 if (a == MAP_FAILED)
129 return NULL; 122 return NULL;
130 123
131 #if defined(MEMORY_SANITIZER) 124 #if defined(MEMORY_SANITIZER)
132 // We need to indicate to MSan that memory allocated through sys_mmap is 125 // We need to indicate to MSan that memory allocated through sys_mmap is
133 // initialized, since linux_syscall_support.h doesn't have MSan hooks. 126 // initialized, since linux_syscall_support.h doesn't have MSan hooks.
134 __msan_unpoison(a, page_size_ * num_pages); 127 __msan_unpoison(a, page_size_ * num_pages);
135 #endif 128 #endif
136 129
137 struct PageHeader *header = reinterpret_cast<PageHeader*>(a); 130 struct PageHeader *header = reinterpret_cast<PageHeader*>(a);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 }; 240 };
248 241
249 } // namespace google_breakpad 242 } // namespace google_breakpad
250 243
251 inline void* operator new(size_t nbytes, 244 inline void* operator new(size_t nbytes,
252 google_breakpad::PageAllocator& allocator) { 245 google_breakpad::PageAllocator& allocator) {
253 return allocator.Alloc(nbytes); 246 return allocator.Alloc(nbytes);
254 } 247 }
255 248
256 #endif // GOOGLE_BREAKPAD_COMMON_MEMORY_H_ 249 #endif // GOOGLE_BREAKPAD_COMMON_MEMORY_H_
OLDNEW
« no previous file with comments | « src/common/linux/memory_mapped_file.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698