|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: sw=4 ts=4 et : |
|
3 */ |
|
4 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
7 |
|
8 #ifndef mozilla_mozalloc_oom_h |
|
9 #define mozilla_mozalloc_oom_h |
|
10 |
|
11 #include "mozalloc.h" |
|
12 |
|
13 #if defined(MOZALLOC_EXPORT) |
|
14 // do nothing: it's been defined to __declspec(dllexport) by |
|
15 // mozalloc*.cpp on platforms where that's required |
|
16 #elif defined(XP_WIN) |
|
17 # define MOZALLOC_EXPORT __declspec(dllimport) |
|
18 #elif defined(HAVE_VISIBILITY_ATTRIBUTE) |
|
19 /* Make sure symbols are still exported even if we're wrapped in a |
|
20 * |visibility push(hidden)| blanket. */ |
|
21 # define MOZALLOC_EXPORT __attribute__ ((visibility ("default"))) |
|
22 #else |
|
23 # define MOZALLOC_EXPORT |
|
24 #endif |
|
25 |
|
26 |
|
27 /** |
|
28 * Called when memory is critically low. Returns iff it was able to |
|
29 * remedy the critical memory situation; if not, it will abort(). |
|
30 * |
|
31 * We have to re-#define MOZALLOC_EXPORT because this header can be |
|
32 * used indepedently of mozalloc.h. |
|
33 */ |
|
34 MOZALLOC_EXPORT void mozalloc_handle_oom(size_t requestedSize); |
|
35 |
|
36 /** |
|
37 * Called by embedders (specifically Mozilla breakpad) which wants to be |
|
38 * notified of an intentional abort, to annotate any crash report with |
|
39 * the size of the allocation on which we aborted. |
|
40 */ |
|
41 typedef void (*mozalloc_oom_abort_handler)(size_t size); |
|
42 MOZALLOC_EXPORT void mozalloc_set_oom_abort_handler(mozalloc_oom_abort_handler handler); |
|
43 |
|
44 /* TODO: functions to query system memory usage and register |
|
45 * critical-memory handlers. */ |
|
46 |
|
47 |
|
48 #endif /* ifndef mozilla_mozalloc_oom_h */ |