1  /* do not edit automatically generated by mc from M2RTS.  */
       2  /* M2RTS.def Implements the run time system facilities of Modula-2.
       3  
       4  Copyright (C) 2001-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 (_M2RTS_H)
      30  #   define _M2RTS_H
      31  
      32  #   ifdef __cplusplus
      33  extern "C" {
      34  #   endif
      35  #   if !defined (PROC_D)
      36  #      define PROC_D
      37         typedef void (*PROC_t) (void);
      38         typedef struct { PROC_t proc; } PROC;
      39  #   endif
      40  
      41  #   include "GSYSTEM.h"
      42  
      43  #   if defined (_M2RTS_C)
      44  #      define EXTERN
      45  #   else
      46  #      define EXTERN extern
      47  #   endif
      48  
      49  typedef struct M2RTS_ArgCVEnvP_p M2RTS_ArgCVEnvP;
      50  
      51  typedef void (*M2RTS_ArgCVEnvP_t) (int, void *, void *);
      52  struct M2RTS_ArgCVEnvP_p { M2RTS_ArgCVEnvP_t proc; };
      53  
      54  EXTERN void M2RTS_ConstructModules (void * applicationmodule, void * libname, int argc, void * argv, void * envp);
      55  EXTERN void M2RTS_DeconstructModules (void * applicationmodule, void * libname, int argc, void * argv, void * envp);
      56  
      57  /*
      58     RegisterModule - adds module name to the list of outstanding
      59                      modules which need to have their dependencies
      60                      explored to determine initialization order.
      61  */
      62  
      63  EXTERN void M2RTS_RegisterModule (void * name, void * libname, M2RTS_ArgCVEnvP init, M2RTS_ArgCVEnvP fini, PROC dependencies);
      64  
      65  /*
      66     RequestDependant - used to specify that modulename is dependant upon
      67                        module dependantmodule.
      68  */
      69  
      70  EXTERN void M2RTS_RequestDependant (void * modulename, void * libname, void * dependantmodule, void * dependantlibname);
      71  
      72  /*
      73     InstallTerminationProcedure - installs a procedure, p, which will
      74                                   be called when the procedure
      75                                   ExecuteTerminationProcedures
      76                                   is invoked.  It returns TRUE is the
      77                                   procedure is installed.
      78  */
      79  
      80  EXTERN unsigned int M2RTS_InstallTerminationProcedure (PROC p);
      81  
      82  /*
      83     ExecuteInitialProcedures - executes the initial procedures installed
      84                                by InstallInitialProcedure.
      85  */
      86  
      87  EXTERN void M2RTS_ExecuteInitialProcedures (void);
      88  
      89  /*
      90     InstallInitialProcedure - installs a procedure to be executed just
      91                               before the BEGIN code section of the main
      92                               program module.
      93  */
      94  
      95  EXTERN unsigned int M2RTS_InstallInitialProcedure (PROC p);
      96  
      97  /*
      98     ExecuteTerminationProcedures - calls each installed termination procedure
      99                                    in reverse order.
     100  */
     101  
     102  EXTERN void M2RTS_ExecuteTerminationProcedures (void);
     103  
     104  /*
     105     Terminate - provides compatibility for pim.  It call exit with
     106                 the exitcode provided in a prior call to ExitOnHalt
     107                 (or zero if ExitOnHalt was never called).  It does
     108                 not call ExecuteTerminationProcedures.
     109  */
     110  
     111  EXTERN void M2RTS_Terminate (void) __attribute__ ((noreturn));
     112  
     113  /*
     114     HALT - terminate the current program.  The procedure Terminate
     115            is called before the program is stopped.  The parameter
     116            exitcode is optional.  If the parameter is not supplied
     117            HALT will call libc 'abort', otherwise it will exit with
     118            the code supplied.  Supplying a parameter to HALT has the
     119            same effect as calling ExitOnHalt with the same code and
     120            then calling HALT with no parameter.
     121  */
     122  
     123  EXTERN void M2RTS_HALT (int exitcode) __attribute__ ((noreturn));
     124  
     125  /*
     126     Halt - provides a more user friendly version of HALT, which takes
     127             four parameters to aid debugging.  It writes an error message
     128             to stderr and calls exit (1).
     129  */
     130  
     131  EXTERN void M2RTS_Halt (const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high, const char *description_, unsigned int _description_high) __attribute__ ((noreturn));
     132  
     133  /*
     134     HaltC - provides a more user friendly version of HALT, which takes
     135             four parameters to aid debugging.  It writes an error message
     136             to stderr and calls exit (1).
     137  */
     138  
     139  EXTERN void M2RTS_HaltC (void * filename, unsigned int line, void * function, void * description) __attribute__ ((noreturn));
     140  
     141  /*
     142     ExitOnHalt - if HALT is executed then call exit with the exit code, e.
     143  */
     144  
     145  EXTERN void M2RTS_ExitOnHalt (int e);
     146  
     147  /*
     148     ErrorMessage - emits an error message to stderr and then calls exit (1).
     149  */
     150  
     151  EXTERN void M2RTS_ErrorMessage (const char *message_, unsigned int _message_high, const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high) __attribute__ ((noreturn));
     152  
     153  /*
     154     Length - returns the length of a string, a. This is called whenever
     155              the user calls LENGTH and the parameter cannot be calculated
     156              at compile time.
     157  */
     158  
     159  EXTERN unsigned int M2RTS_Length (const char *a_, unsigned int _a_high);
     160  EXTERN void M2RTS_AssignmentException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     161  EXTERN void M2RTS_ReturnException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     162  EXTERN void M2RTS_IncException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     163  EXTERN void M2RTS_DecException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     164  EXTERN void M2RTS_InclException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     165  EXTERN void M2RTS_ExclException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     166  EXTERN void M2RTS_ShiftException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     167  EXTERN void M2RTS_RotateException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     168  EXTERN void M2RTS_StaticArraySubscriptException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     169  EXTERN void M2RTS_DynamicArraySubscriptException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     170  EXTERN void M2RTS_ForLoopBeginException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     171  EXTERN void M2RTS_ForLoopToException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     172  EXTERN void M2RTS_ForLoopEndException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     173  EXTERN void M2RTS_PointerNilException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     174  EXTERN void M2RTS_NoReturnException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     175  EXTERN void M2RTS_CaseException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     176  EXTERN void M2RTS_WholeNonPosDivException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     177  EXTERN void M2RTS_WholeNonPosModException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     178  EXTERN void M2RTS_WholeZeroDivException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     179  EXTERN void M2RTS_WholeZeroRemException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     180  EXTERN void M2RTS_WholeValueException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     181  EXTERN void M2RTS_RealValueException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     182  EXTERN void M2RTS_ParameterException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     183  EXTERN void M2RTS_NoException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
     184  #   ifdef __cplusplus
     185  }
     186  #   endif
     187  
     188  #   undef EXTERN
     189  #endif