LCOV - code coverage report
Current view: directory - objdir/dist/include/mozilla - throw_gcc.h (source / functions) Found Hit Coverage
Test: app.info Lines: 10 0 0.0 %
Date: 2012-06-02 Functions: 5 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2                 :  * vim: sw=4 ts=4 et :
       3                 :  */
       4                 : /* ***** BEGIN LICENSE BLOCK *****
       5                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       6                 :  *
       7                 :  * The contents of this file are subject to the Mozilla Public License Version
       8                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       9                 :  * the License. You may obtain a copy of the License at
      10                 :  * http://www.mozilla.org/MPL/
      11                 :  *
      12                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      13                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      14                 :  * for the specific language governing rights and limitations under the
      15                 :  * License.
      16                 :  *
      17                 :  * The Original Code is Mozilla Code
      18                 :  *
      19                 :  * The Initial Developer of the Original Code is
      20                 :  * The Mozilla Foundation.
      21                 :  * Portions created by the Initial Developer are Copyright (C) 2010
      22                 :  * the Initial Developer. All Rights Reserved.
      23                 :  *
      24                 :  * Contributor(s):
      25                 :  *   Chris Jones <jones.chris.g@gmail.com>
      26                 :  *
      27                 :  * Alternatively, the contents of this file may be used under the terms of
      28                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      29                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      30                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      31                 :  * of those above. If you wish to allow use of your version of this file only
      32                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      33                 :  * use your version of this file under the terms of the MPL, indicate your
      34                 :  * decision by deleting the provisions above and replace them with the notice
      35                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      36                 :  * the provisions above, a recipient may use your version of this file under
      37                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      38                 :  *
      39                 :  * ***** END LICENSE BLOCK ***** */
      40                 : 
      41                 : #ifndef mozilla_throw_gcc_h
      42                 : #define mozilla_throw_gcc_h
      43                 : 
      44                 : #include "mozilla/Attributes.h"
      45                 : #include "mozilla/Util.h"
      46                 : 
      47                 : #include <stdio.h>              // snprintf
      48                 : #include <string.h>             // strerror
      49                 : 
      50                 : // For gcc, we define these inline to abort so that we're absolutely
      51                 : // certain that (i) no exceptions are thrown from Gecko; (ii) these
      52                 : // errors are always terminal and caught by breakpad.
      53                 : 
      54                 : #include "mozilla/mozalloc_abort.h"
      55                 : 
      56                 : namespace std {
      57                 : 
      58                 : // NB: user code is not supposed to touch the std:: namespace.  We're
      59                 : // doing this after careful review because we want to define our own
      60                 : // exception throwing semantics.  Don't try this at home!
      61                 : 
      62                 : MOZ_NORETURN MOZ_ALWAYS_INLINE void
      63                 : __throw_bad_exception(void)
      64                 : {
      65                 :     mozalloc_abort("fatal: STL threw bad_exception");
      66                 : }
      67                 : 
      68                 : MOZ_NORETURN MOZ_ALWAYS_INLINE void
      69               0 : __throw_bad_alloc(void)
      70                 : {
      71               0 :     mozalloc_abort("fatal: STL threw bad_alloc");
      72                 : }
      73                 : 
      74                 : MOZ_NORETURN MOZ_ALWAYS_INLINE void
      75               0 : __throw_bad_cast(void)
      76                 : {
      77               0 :     mozalloc_abort("fatal: STL threw bad_cast");
      78                 : }
      79                 : 
      80                 : MOZ_NORETURN MOZ_ALWAYS_INLINE void
      81                 : __throw_bad_typeid(void)
      82                 : {
      83                 :     mozalloc_abort("fatal: STL threw bad_typeid");
      84                 : }
      85                 : 
      86                 : MOZ_NORETURN MOZ_ALWAYS_INLINE void
      87               0 : __throw_logic_error(const char* msg)
      88                 : {
      89               0 :     mozalloc_abort(msg);
      90                 : }
      91                 : 
      92                 : MOZ_NORETURN MOZ_ALWAYS_INLINE void
      93                 : __throw_domain_error(const char* msg)
      94                 : {
      95                 :     mozalloc_abort(msg);
      96                 : }
      97                 : 
      98                 : MOZ_NORETURN MOZ_ALWAYS_INLINE void
      99                 : __throw_invalid_argument(const char* msg)
     100                 : {
     101                 :     mozalloc_abort(msg);
     102                 : }
     103                 : 
     104                 : MOZ_NORETURN MOZ_ALWAYS_INLINE void
     105               0 : __throw_length_error(const char* msg)
     106                 : {
     107               0 :     mozalloc_abort(msg);
     108                 : }
     109                 : 
     110                 : MOZ_NORETURN MOZ_ALWAYS_INLINE void
     111               0 : __throw_out_of_range(const char* msg)
     112                 : {
     113               0 :     mozalloc_abort(msg);
     114                 : }
     115                 : 
     116                 : MOZ_NORETURN MOZ_ALWAYS_INLINE void
     117                 : __throw_runtime_error(const char* msg)
     118                 : {
     119                 :     mozalloc_abort(msg);
     120                 : }
     121                 : 
     122                 : MOZ_NORETURN MOZ_ALWAYS_INLINE void
     123                 : __throw_range_error(const char* msg)
     124                 : {
     125                 :     mozalloc_abort(msg);
     126                 : }
     127                 : 
     128                 : MOZ_NORETURN MOZ_ALWAYS_INLINE void
     129                 : __throw_overflow_error(const char* msg)
     130                 : {
     131                 :     mozalloc_abort(msg);
     132                 : }
     133                 : 
     134                 : MOZ_NORETURN MOZ_ALWAYS_INLINE void
     135                 : __throw_underflow_error(const char* msg)
     136                 : {
     137                 :     mozalloc_abort(msg);
     138                 : }
     139                 : 
     140                 : MOZ_NORETURN MOZ_ALWAYS_INLINE void
     141                 : __throw_ios_failure(const char* msg)
     142                 : {
     143                 :     mozalloc_abort(msg);
     144                 : }
     145                 : 
     146                 : MOZ_NORETURN MOZ_ALWAYS_INLINE void
     147                 : __throw_system_error(int err)
     148                 : {
     149                 :     char error[128];
     150                 :     snprintf(error, sizeof(error)-1,
     151                 :              "fatal: STL threw system_error: %s (%d)", strerror(err), err);
     152                 :     mozalloc_abort(error);
     153                 : }
     154                 : 
     155                 : } // namespace std
     156                 : 
     157                 : #endif  // mozilla_throw_gcc_h

Generated by: LCOV version 1.7