1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/memory/mozalloc/mozalloc_oom.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,48 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * vim: sw=4 ts=4 et : 1.6 + */ 1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +#ifndef mozilla_mozalloc_oom_h 1.12 +#define mozilla_mozalloc_oom_h 1.13 + 1.14 +#include "mozalloc.h" 1.15 + 1.16 +#if defined(MOZALLOC_EXPORT) 1.17 +// do nothing: it's been defined to __declspec(dllexport) by 1.18 +// mozalloc*.cpp on platforms where that's required 1.19 +#elif defined(XP_WIN) 1.20 +# define MOZALLOC_EXPORT __declspec(dllimport) 1.21 +#elif defined(HAVE_VISIBILITY_ATTRIBUTE) 1.22 +/* Make sure symbols are still exported even if we're wrapped in a 1.23 + * |visibility push(hidden)| blanket. */ 1.24 +# define MOZALLOC_EXPORT __attribute__ ((visibility ("default"))) 1.25 +#else 1.26 +# define MOZALLOC_EXPORT 1.27 +#endif 1.28 + 1.29 + 1.30 +/** 1.31 + * Called when memory is critically low. Returns iff it was able to 1.32 + * remedy the critical memory situation; if not, it will abort(). 1.33 + * 1.34 + * We have to re-#define MOZALLOC_EXPORT because this header can be 1.35 + * used indepedently of mozalloc.h. 1.36 + */ 1.37 +MOZALLOC_EXPORT void mozalloc_handle_oom(size_t requestedSize); 1.38 + 1.39 +/** 1.40 + * Called by embedders (specifically Mozilla breakpad) which wants to be 1.41 + * notified of an intentional abort, to annotate any crash report with 1.42 + * the size of the allocation on which we aborted. 1.43 + */ 1.44 +typedef void (*mozalloc_oom_abort_handler)(size_t size); 1.45 +MOZALLOC_EXPORT void mozalloc_set_oom_abort_handler(mozalloc_oom_abort_handler handler); 1.46 + 1.47 +/* TODO: functions to query system memory usage and register 1.48 + * critical-memory handlers. */ 1.49 + 1.50 + 1.51 +#endif /* ifndef mozilla_mozalloc_oom_h */