sysutils.pp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. uses
  15. {$ifdef linux}
  16. linux,
  17. {$else}
  18. dos,
  19. {$ifdef go32v2}
  20. go32,
  21. {$endif go32v2}
  22. {$endif linux}
  23. objpas;
  24. type
  25. { some helpful data types }
  26. tprocedure = procedure;
  27. tfilename = string;
  28. longrec = packed record
  29. lo,hi : word;
  30. end;
  31. wordrec = packed record
  32. lo,hi : byte;
  33. end;
  34. {$ifdef USE_EXCEPTIONS}
  35. { exceptions }
  36. exception = class(TObject)
  37. private
  38. fmessage : string;
  39. fhelpcontext : longint;
  40. public
  41. constructor create(const msg : string);
  42. //!! No array of const yet.
  43. // constructor createfmt(const msg; const args : array of const);
  44. constructor createres(indent : longint);
  45. { !!!! }
  46. property helpcontext : longint read fhelpcontext write fhelpcontext;
  47. property message : string read fmessage write fmessage;
  48. end;
  49. exceptclass = class of exception;
  50. { math. exceptions }
  51. einterror = class(exception);
  52. edivbyzero = class(einterror);
  53. erangeerror = class(einterror);
  54. eintoverflow = class(einterror);
  55. ematherror = class(exception);
  56. {$endif USE_EXCEPTIONS}
  57. { Read date & Time function declarations }
  58. {$i datih.inc}
  59. { Read String Handling functions declaration }
  60. {$i sysstrh.inc}
  61. { Read pchar handling functions declration }
  62. {$i syspchh.inc}
  63. { Read filename handling functions declaration }
  64. {$i finah.inc}
  65. implementation
  66. { Read filename handling functions implementation }
  67. {$i fina.inc}
  68. { Read date & Time function implementations }
  69. {$i dati.inc}
  70. { Read String Handling functions implementation }
  71. {$i sysstr.inc}
  72. { Read pchar handling functions implementation }
  73. {$i syspch.inc}
  74. {$ifdef USE_EXCEPTIONS}
  75. constructor exception.create(const msg : string);
  76. begin
  77. inherited create;
  78. fmessage:=msg;
  79. {!!!!!}
  80. end;
  81. {
  82. constructor exception.createfmt(const msg; const args : array of const);
  83. begin
  84. inherited create;
  85. end;
  86. }
  87. constructor exception.createres(indent : longint);
  88. begin
  89. inherited create;
  90. {!!!!!}
  91. end;
  92. Procedure CatchUnhandledException (Obj : TObject; Addr: Pointer);
  93. Var Message : String;
  94. begin
  95. {$ifndef USE_WINDOWS}
  96. Writeln ('An unhandled exception occurred at ',HexStr(Longint(Addr),8),' : ');
  97. if Obj is exception then
  98. begin
  99. Message:=Exception(Obj).Message;
  100. Writeln (Message);
  101. end
  102. else
  103. Writeln ('Exception object ',Obj.ClassName,' is not of class Exception.');
  104. Halt(217);
  105. {$else}
  106. {$endif}
  107. end;
  108. {$endif USE_EXCEPTIONS}
  109. Procedure InitExceptions;
  110. {
  111. Must install uncaught exception handler (ExceptProc)
  112. and install exceptions for system exceptions or signals.
  113. (e.g: SIGSEGV -> ESegFault or so.)
  114. }
  115. begin
  116. {$ifdef USE_EXCEPTIONS}
  117. ExceptProc:=@CatchUnhandledException;
  118. {$endif}
  119. end;
  120. {Initialization code.}
  121. begin
  122. InitExceptions;
  123. end.
  124. {
  125. $Log$
  126. Revision 1.9 1998-09-24 16:13:49 michael
  127. Changes in exception and open array handling
  128. Revision 1.8 1998/09/18 23:57:26 michael
  129. * Changed use_excepions to useexceptions
  130. Revision 1.7 1998/09/16 14:34:38 pierre
  131. * go32v2 did not compile
  132. * wrong code in systr.inc corrected
  133. Revision 1.6 1998/09/16 08:28:44 michael
  134. Update from gertjan Schouten, plus small fix for linux
  135. Revision 1.5 1998/09/04 08:49:07 peter
  136. * 0.99.5 doesn't compile a whole objpas anymore to overcome crashes
  137. Revision 1.4 1998/08/10 15:52:27 peter
  138. * fixed so 0.99.5 compiles it, but no exception class
  139. Revision 1.3 1998/07/29 15:44:32 michael
  140. included sysutils and math.pp as target. They compile now.
  141. Revision 1.2 1998/04/10 15:18:21 michael
  142. Added a lot of functions donated by GertJan Schouten
  143. Revision 1.1.1.1 1998/03/25 11:18:49 root
  144. * Restored version
  145. Revision 1.1 1998/02/05 11:11:32 michael
  146. + moved to objpas directory
  147. Revision 1.2 1998/02/03 15:27:25 florian
  148. *** empty log message ***
  149. Revision 1.1 1998/02/01 23:32:01 florian
  150. + initial revision
  151. }