1  /* do not edit automatically generated by mc from RTExceptions.  */
       2  /* RTExceptions.def runtime exception handler routines.
       3  
       4  Copyright (C) 2008-2023 Free Software Foundation, Inc.
       5  Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
       6  
       7  This file is part of GNU Modula-2.
       8  
       9  GNU Modula-2 is free software; you can redistribute it and/or modify
      10  it under the terms of the GNU General Public License as published by
      11  the Free Software Foundation; either version 3, or (at your option)
      12  any later version.
      13  
      14  GNU Modula-2 is distributed in the hope that it will be useful, but
      15  WITHOUT ANY WARRANTY; without even the implied warranty of
      16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17  General Public License for more details.
      18  
      19  Under Section 7 of GPL version 3, you are granted additional
      20  permissions described in the GCC Runtime Library Exception, version
      21  3.1, as published by the Free Software Foundation.
      22  
      23  You should have received a copy of the GNU General Public License and
      24  a copy of the GCC Runtime Library Exception along with this program;
      25  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
      26  <http://www.gnu.org/licenses/>.  */
      27  
      28  
      29  #if !defined (_RTExceptions_H)
      30  #   define _RTExceptions_H
      31  
      32  #include "config.h"
      33  #include "system.h"
      34  #   ifdef __cplusplus
      35  extern "C" {
      36  #   endif
      37  #include <stdbool.h>
      38  #   if !defined (PROC_D)
      39  #      define PROC_D
      40         typedef void (*PROC_t) (void);
      41         typedef struct { PROC_t proc; } PROC;
      42  #   endif
      43  
      44  #   include "GSYSTEM.h"
      45  
      46  #   if defined (_RTExceptions_C)
      47  #      define EXTERN
      48  #   else
      49  #      define EXTERN extern
      50  #   endif
      51  
      52  #if !defined (RTExceptions_EHBlock_D)
      53  #  define RTExceptions_EHBlock_D
      54     typedef void *RTExceptions_EHBlock;
      55  #endif
      56  
      57  typedef struct RTExceptions_ProcedureHandler_p RTExceptions_ProcedureHandler;
      58  
      59  typedef void (*RTExceptions_ProcedureHandler_t) (void);
      60  struct RTExceptions_ProcedureHandler_p { RTExceptions_ProcedureHandler_t proc; };
      61  
      62  
      63  /*
      64     Raise - invoke the exception handler associated with, number,
      65             in the active EHBlock.  It keeps a record of the number
      66             and message in the EHBlock for later use.
      67  */
      68  
      69  EXTERN void RTExceptions_Raise (unsigned int number, void * file, unsigned int line, unsigned int column, void * function, void * message) __attribute__ ((noreturn));
      70  
      71  /*
      72     SetExceptionBlock - sets, source, as the active EHB.
      73  */
      74  
      75  EXTERN void RTExceptions_SetExceptionBlock (RTExceptions_EHBlock source);
      76  
      77  /*
      78     GetExceptionBlock - returns the active EHB.
      79  */
      80  
      81  EXTERN RTExceptions_EHBlock RTExceptions_GetExceptionBlock (void);
      82  
      83  /*
      84     GetTextBuffer - returns the address of the EHB buffer.
      85  */
      86  
      87  EXTERN void * RTExceptions_GetTextBuffer (RTExceptions_EHBlock e);
      88  
      89  /*
      90     GetTextBufferSize - return the size of the EHB text buffer.
      91  */
      92  
      93  EXTERN unsigned int RTExceptions_GetTextBufferSize (RTExceptions_EHBlock e);
      94  
      95  /*
      96     GetNumber - return the exception number associated with,
      97                 source.
      98  */
      99  
     100  EXTERN unsigned int RTExceptions_GetNumber (RTExceptions_EHBlock source);
     101  
     102  /*
     103     InitExceptionBlock - creates and returns a new exception block.
     104  */
     105  
     106  EXTERN RTExceptions_EHBlock RTExceptions_InitExceptionBlock (void);
     107  
     108  /*
     109     KillExceptionBlock - destroys the EHB, e, and all its handlers.
     110  */
     111  
     112  EXTERN RTExceptions_EHBlock RTExceptions_KillExceptionBlock (RTExceptions_EHBlock e);
     113  
     114  /*
     115     PushHandler - install a handler in EHB, e.
     116  */
     117  
     118  EXTERN void RTExceptions_PushHandler (RTExceptions_EHBlock e, unsigned int number, RTExceptions_ProcedureHandler p);
     119  
     120  /*
     121     PopHandler - removes the handler associated with, number, from
     122                  EHB, e.
     123  */
     124  
     125  EXTERN void RTExceptions_PopHandler (RTExceptions_EHBlock e, unsigned int number);
     126  
     127  /*
     128     DefaultErrorCatch - displays the current error message in
     129                         the current exception block and then
     130                         calls HALT.
     131  */
     132  
     133  EXTERN void RTExceptions_DefaultErrorCatch (void);
     134  
     135  /*
     136     BaseExceptionsThrow - configures the Modula-2 exceptions to call
     137                           THROW which in turn can be caught by an
     138                           exception block.  If this is not called then
     139                           a Modula-2 exception will simply call an
     140                           error message routine and then HALT.
     141  */
     142  
     143  EXTERN void RTExceptions_BaseExceptionsThrow (void);
     144  
     145  /*
     146     IsInExceptionState - returns TRUE if the program is currently
     147                          in the exception state.
     148  */
     149  
     150  EXTERN bool RTExceptions_IsInExceptionState (void);
     151  
     152  /*
     153     SetExceptionState - returns the current exception state and
     154                         then sets the current exception state to,
     155                         to.
     156  */
     157  
     158  EXTERN bool RTExceptions_SetExceptionState (bool to);
     159  
     160  /*
     161     SwitchExceptionState - assigns, from, with the current exception
     162                            state and then assigns the current exception
     163                            to, to.
     164  */
     165  
     166  EXTERN void RTExceptions_SwitchExceptionState (bool *from, bool to);
     167  
     168  /*
     169     GetBaseExceptionBlock - returns the initial language exception block
     170                             created.
     171  */
     172  
     173  EXTERN RTExceptions_EHBlock RTExceptions_GetBaseExceptionBlock (void);
     174  
     175  /*
     176     SetExceptionSource - sets the current exception source to, source.
     177  */
     178  
     179  EXTERN void RTExceptions_SetExceptionSource (void * source);
     180  
     181  /*
     182     GetExceptionSource - returns the current exception source.
     183  */
     184  
     185  EXTERN void * RTExceptions_GetExceptionSource (void);
     186  #   ifdef __cplusplus
     187  }
     188  #   endif
     189  
     190  #   undef EXTERN
     191  #endif