memory/mozalloc/mozalloc_abort.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/memory/mozalloc/mozalloc_abort.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,42 @@
     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 +#if defined(XP_WIN)
    1.12 +#  define MOZALLOC_EXPORT __declspec(dllexport)
    1.13 +#endif
    1.14 +
    1.15 +#include "mozilla/mozalloc_abort.h"
    1.16 +
    1.17 +#ifdef ANDROID
    1.18 +# include <android/log.h>
    1.19 +#endif
    1.20 +#include <stdio.h>
    1.21 +
    1.22 +#include "mozilla/Assertions.h"
    1.23 +
    1.24 +void
    1.25 +mozalloc_abort(const char* const msg)
    1.26 +{
    1.27 +#ifndef ANDROID
    1.28 +    fputs(msg, stderr);
    1.29 +    fputs("\n", stderr);
    1.30 +#else
    1.31 +    __android_log_print(ANDROID_LOG_ERROR, "Gecko", "mozalloc_abort: %s", msg);
    1.32 +#endif
    1.33 +    MOZ_CRASH();
    1.34 +}
    1.35 +
    1.36 +#if defined(XP_UNIX)
    1.37 +// Define abort() here, so that it is used instead of the system abort(). This
    1.38 +// lets us control the behavior when aborting, in order to get better results
    1.39 +// on *NIX platforms. See mozalloc_abort for details.
    1.40 +void abort(void)
    1.41 +{
    1.42 +    mozalloc_abort("Redirecting call to abort() to mozalloc_abort\n");
    1.43 +}
    1.44 +#endif
    1.45 +

mercurial