sysutils.pp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1998 by Florian Klaempfl
  5. member of the Free Pascal development team
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit sysutils;
  13. interface
  14. {$MODE objfpc}
  15. uses
  16. {$ifdef linux}
  17. linux
  18. {$else}
  19. dos
  20. {$ifdef go32v2}
  21. ,go32
  22. {$endif go32v2}
  23. {$endif linux}
  24. {$ifndef AUTOOBJPAS}
  25. ,objpas
  26. {$endif}
  27. ;
  28. type
  29. { some helpful data types }
  30. tprocedure = procedure;
  31. tfilename = string;
  32. longrec = packed record
  33. lo,hi : word;
  34. end;
  35. wordrec = packed record
  36. lo,hi : byte;
  37. end;
  38. { exceptions }
  39. exception = class(TObject)
  40. private
  41. fmessage : string;
  42. fhelpcontext : longint;
  43. public
  44. constructor create(const msg : string);
  45. //!! No array of const yet.
  46. // constructor createfmt(const msg; const args : array of const);
  47. constructor createres(indent : longint);
  48. { !!!! }
  49. property helpcontext : longint read fhelpcontext write fhelpcontext;
  50. property message : string read fmessage write fmessage;
  51. end;
  52. exceptclass = class of exception;
  53. { math. exceptions }
  54. einterror = class(exception);
  55. edivbyzero = class(einterror);
  56. erangeerror = class(einterror);
  57. eintoverflow = class(einterror);
  58. ematherror = class(exception);
  59. { Read date & Time function declarations }
  60. {$i datih.inc}
  61. { Read String Handling functions declaration }
  62. {$i sysstrh.inc}
  63. { Read pchar handling functions declration }
  64. {$i syspchh.inc}
  65. { Read filename handling functions declaration }
  66. {$i finah.inc}
  67. implementation
  68. { Read filename handling functions implementation }
  69. {$i fina.inc}
  70. { Read date & Time function implementations }
  71. {$i dati.inc}
  72. { Read String Handling functions implementation }
  73. {$i sysstr.inc}
  74. { Read pchar handling functions implementation }
  75. {$i syspch.inc}
  76. constructor exception.create(const msg : string);
  77. begin
  78. inherited create;
  79. fmessage:=msg;
  80. {!!!!!}
  81. end;
  82. {
  83. constructor exception.createfmt(const msg; const args : array of const);
  84. begin
  85. inherited create;
  86. end;
  87. }
  88. constructor exception.createres(indent : longint);
  89. begin
  90. inherited create;
  91. {!!!!!}
  92. end;
  93. Procedure CatchUnhandledException (Obj : TObject; Addr: Pointer);
  94. Var
  95. Message : String;
  96. begin
  97. {$ifndef USE_WINDOWS}
  98. Writeln ('An unhandled exception occurred at ',HexStr(Longint(Addr),8),' : ');
  99. if Obj is exception then
  100. begin
  101. Message:=Exception(Obj).Message;
  102. Writeln (Message);
  103. end
  104. else
  105. Writeln ('Exception object ',Obj.ClassName,' is not of class Exception.');
  106. Halt(217);
  107. {$else}
  108. {$endif}
  109. end;
  110. Procedure InitExceptions;
  111. {
  112. Must install uncaught exception handler (ExceptProc)
  113. and install exceptions for system exceptions or signals.
  114. (e.g: SIGSEGV -> ESegFault or so.)
  115. }
  116. begin
  117. ExceptProc:=@CatchUnhandledException;
  118. end;
  119. {Initialization code.}
  120. begin
  121. InitExceptions;
  122. end.
  123. {
  124. $Log$
  125. Revision 1.10 1998-09-24 23:45:27 peter
  126. * updated for auto objpas loading
  127. Revision 1.9 1998/09/24 16:13:49 michael
  128. Changes in exception and open array handling
  129. Revision 1.8 1998/09/18 23:57:26 michael
  130. * Changed use_excepions to useexceptions
  131. Revision 1.7 1998/09/16 14:34:38 pierre
  132. * go32v2 did not compile
  133. * wrong code in systr.inc corrected
  134. Revision 1.6 1998/09/16 08:28:44 michael
  135. Update from gertjan Schouten, plus small fix for linux
  136. Revision 1.5 1998/09/04 08:49:07 peter
  137. * 0.99.5 doesn't compile a whole objpas anymore to overcome crashes
  138. Revision 1.4 1998/08/10 15:52:27 peter
  139. * fixed so 0.99.5 compiles it, but no exception class
  140. Revision 1.3 1998/07/29 15:44:32 michael
  141. included sysutils and math.pp as target. They compile now.
  142. }