michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: sw=4 ts=4 et : michael@0: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_mozalloc_oom_h michael@0: #define mozilla_mozalloc_oom_h michael@0: michael@0: #include "mozalloc.h" michael@0: michael@0: #if defined(MOZALLOC_EXPORT) michael@0: // do nothing: it's been defined to __declspec(dllexport) by michael@0: // mozalloc*.cpp on platforms where that's required michael@0: #elif defined(XP_WIN) michael@0: # define MOZALLOC_EXPORT __declspec(dllimport) michael@0: #elif defined(HAVE_VISIBILITY_ATTRIBUTE) michael@0: /* Make sure symbols are still exported even if we're wrapped in a michael@0: * |visibility push(hidden)| blanket. */ michael@0: # define MOZALLOC_EXPORT __attribute__ ((visibility ("default"))) michael@0: #else michael@0: # define MOZALLOC_EXPORT michael@0: #endif michael@0: michael@0: michael@0: /** michael@0: * Called when memory is critically low. Returns iff it was able to michael@0: * remedy the critical memory situation; if not, it will abort(). michael@0: * michael@0: * We have to re-#define MOZALLOC_EXPORT because this header can be michael@0: * used indepedently of mozalloc.h. michael@0: */ michael@0: MOZALLOC_EXPORT void mozalloc_handle_oom(size_t requestedSize); michael@0: michael@0: /** michael@0: * Called by embedders (specifically Mozilla breakpad) which wants to be michael@0: * notified of an intentional abort, to annotate any crash report with michael@0: * the size of the allocation on which we aborted. michael@0: */ michael@0: typedef void (*mozalloc_oom_abort_handler)(size_t size); michael@0: MOZALLOC_EXPORT void mozalloc_set_oom_abort_handler(mozalloc_oom_abort_handler handler); michael@0: michael@0: /* TODO: functions to query system memory usage and register michael@0: * critical-memory handlers. */ michael@0: michael@0: michael@0: #endif /* ifndef mozilla_mozalloc_oom_h */