memory/mozalloc/mozalloc_oom.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial