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

Side by Side Diff: base/process/memory.h

Issue 1852143002: win: Remove GetModuleFromAddress, deduplicate __ImageBase code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_PROCESS_MEMORY_H_ 5 #ifndef BASE_PROCESS_MEMORY_H_
6 #define BASE_PROCESS_MEMORY_H_ 6 #define BASE_PROCESS_MEMORY_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
11 #include "base/process/process_handle.h" 11 #include "base/process/process_handle.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 13
14 #if defined(OS_WIN)
15 #include <windows.h>
16 #endif
17
18 #ifdef PVALLOC_AVAILABLE 14 #ifdef PVALLOC_AVAILABLE
19 // Build config explicitly tells us whether or not pvalloc is available. 15 // Build config explicitly tells us whether or not pvalloc is available.
20 #elif defined(LIBC_GLIBC) && !defined(USE_TCMALLOC) 16 #elif defined(LIBC_GLIBC) && !defined(USE_TCMALLOC)
21 #define PVALLOC_AVAILABLE 1 17 #define PVALLOC_AVAILABLE 1
22 #else 18 #else
23 #define PVALLOC_AVAILABLE 0 19 #define PVALLOC_AVAILABLE 0
24 #endif 20 #endif
25 21
26 namespace base { 22 namespace base {
27 23
28 // Enables 'terminate on heap corruption' flag. Helps protect against heap 24 // Enables 'terminate on heap corruption' flag. Helps protect against heap
29 // overflow. Has no effect if the OS doesn't provide the necessary facility. 25 // overflow. Has no effect if the OS doesn't provide the necessary facility.
30 BASE_EXPORT void EnableTerminationOnHeapCorruption(); 26 BASE_EXPORT void EnableTerminationOnHeapCorruption();
31 27
32 // Turns on process termination if memory runs out. 28 // Turns on process termination if memory runs out.
33 BASE_EXPORT void EnableTerminationOnOutOfMemory(); 29 BASE_EXPORT void EnableTerminationOnOutOfMemory();
34 30
35 // Terminates process. Should be called only for out of memory errors. 31 // Terminates process. Should be called only for out of memory errors.
36 // Crash reporting classifies such crashes as OOM. 32 // Crash reporting classifies such crashes as OOM.
37 BASE_EXPORT void TerminateBecauseOutOfMemory(size_t size); 33 BASE_EXPORT void TerminateBecauseOutOfMemory(size_t size);
38 34
39 #if defined(OS_WIN)
40 // Returns the module handle to which an address belongs. The reference count
41 // of the module is not incremented.
42 BASE_EXPORT HMODULE GetModuleFromAddress(void* address);
43 #endif
44
45 #if defined(OS_LINUX) || defined(OS_ANDROID) 35 #if defined(OS_LINUX) || defined(OS_ANDROID)
46 BASE_EXPORT extern size_t g_oom_size; 36 BASE_EXPORT extern size_t g_oom_size;
47 37
48 // The maximum allowed value for the OOM score. 38 // The maximum allowed value for the OOM score.
49 const int kMaxOomScore = 1000; 39 const int kMaxOomScore = 1000;
50 40
51 // This adjusts /proc/<pid>/oom_score_adj so the Linux OOM killer will 41 // This adjusts /proc/<pid>/oom_score_adj so the Linux OOM killer will
52 // prefer to kill certain process types over others. The range for the 42 // prefer to kill certain process types over others. The range for the
53 // adjustment is [-1000, 1000], with [0, 1000] being user accessible. 43 // adjustment is [-1000, 1000], with [0, 1000] being user accessible.
54 // If the Linux system doesn't support the newer oom_score_adj range 44 // If the Linux system doesn't support the newer oom_score_adj range
(...skipping 15 matching lines...) Expand all
70 // set to NULL, otherwise it holds the memory address. 60 // set to NULL, otherwise it holds the memory address.
71 BASE_EXPORT WARN_UNUSED_RESULT bool UncheckedMalloc(size_t size, 61 BASE_EXPORT WARN_UNUSED_RESULT bool UncheckedMalloc(size_t size,
72 void** result); 62 void** result);
73 BASE_EXPORT WARN_UNUSED_RESULT bool UncheckedCalloc(size_t num_items, 63 BASE_EXPORT WARN_UNUSED_RESULT bool UncheckedCalloc(size_t num_items,
74 size_t size, 64 size_t size,
75 void** result); 65 void** result);
76 66
77 } // namespace base 67 } // namespace base
78 68
79 #endif // BASE_PROCESS_MEMORY_H_ 69 #endif // BASE_PROCESS_MEMORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698