1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- S Y S T E M . P U R E _ E X C E P T I O N S --
9 -- Copyright (C) 2000-2009, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 -- This package provides an interface for raising predefined exceptions with
33 -- an exception message. It can be used from Pure units. This unit is for
34 -- internal use only, it is not generally available to applications.
38 package System
.Pure_Exceptions
is
41 type Exception_Type
is limited null record;
42 -- Type used to specify which exception to raise
44 -- Really Exception_Type is Exception_Id, but Exception_Id can't be
45 -- used directly since it is declared in the non-pure unit Ada.Exceptions,
47 -- Exception_Id is in fact simply a pointer to the type Exception_Data
48 -- declared in System.Standard_Library (which is also non-pure). So what
49 -- we do is to define it here as a by reference type (any by reference
50 -- type would do), and then Import the definitions from Standard_Library.
51 -- Since this is a by reference type, these will be passed by reference,
52 -- which has the same effect as passing a pointer.
54 -- This type is not private because keeping it by reference would require
55 -- defining it in a way (e.g a tagged type) that would drag other run time
56 -- files, which is unwanted in the case of e.g ravenscar where we want to
57 -- minimize the number of run time files needed by default.
59 CE
: constant Exception_Type
; -- Constraint_Error
60 PE
: constant Exception_Type
; -- Program_Error
61 SE
: constant Exception_Type
; -- Storage_Error
62 TE
: constant Exception_Type
; -- Tasking_Error
63 -- One of these constants is used in the call to specify the exception
65 procedure Raise_Exception
(E
: Exception_Type
; Message
: String);
66 pragma Import
(Ada
, Raise_Exception
, "__gnat_raise_exception");
67 pragma No_Return
(Raise_Exception
);
68 -- Raise specified exception with specified message
71 pragma Import
(C
, CE
, "constraint_error");
72 pragma Import
(C
, PE
, "program_error");
73 pragma Import
(C
, SE
, "storage_error");
74 pragma Import
(C
, TE
, "tasking_error");
75 -- References to the exception structures in the standard library
77 end System
.Pure_Exceptions
;